Linux network card configuration

Time:2021-7-22
 
 

1. Network card settings

1.1 bridge mode

(1) Input command: VI / etc / sysconfig / network scripts / ifcfg-eth0
Centos7 does not have ifcfg-eth0 file, but uses ifcfg-ens33 file
0
(2) Enter edit mode (press I key)
0
(3) Edit NIC configuration
To set dynamic IP, just change onboot to yes
NM_ The control LED indicates whether the modification will take effect in real time, that is, the modification will take effect immediately without restarting the network card. It is recommended to change it to no, otherwise the remote server will not be able to be connected after the parameter is corrected
0
If you need to set static IP, change bootproto to static and specify IP address
IPADDR = IP address
Netmask = subnet mask
Gateway = default gateway
0
(4) Press ESC to return to command mode
(5) Press Shift +: key combination, enter WQ, and then press enter to save and exit
(6) Restart the network card and enter the command service network restart
0
 
(7) If the startup fails, delete the network card generation rule file, and then restart the virtual machine.
0
 

1.2. NAT mode

(1) View Linux routing address
View the status of VMnet8 network card on the window, right-click status details
0
 
Find the corresponding routing address 192.168.56.1
(2) View gateway
0
The gateway is 192.168.56.2
 
(3) Edit NIC configuration
vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
/Etc / sysconfig / network scripts is the storage directory of network card configuration files.
When you enter the path and file name, you can press tab to complete it.
(4) Press lowercase I on the keyboard to enter edit mode
Modify the network card file as follows:
0
 
(5) Save, exit
i) Press ESC
II) in English keyboard mode, shift + colon
III) in the bottom cursor bar, enter: WQ
(6) Restart NIC
Restart command: service network restart
 

 
 
 
 

2. Configure DNS

(1) Edit the DNS configuration file VI / etc / resolv.conf (2) and insert the following in the blank space
nameserver 8.8.8.8                 # Google domain name server
nameserver 114.114.114.114       # Domestic domain name server (China Telecom)

3. Test network

(1) Ping virtual machine router address
(2) Ping IP on Windows
(3)ping www.baidu.com
 
 

 

Link to the original text:https://www.cnblogs.com/gaojinshun/p/14529195.html