Linux network card configuration


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
(2) Enter edit mode (press I key)
(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
If you need to set static IP, change bootproto to static and specify IP address
IPADDR = IP address
Netmask = subnet mask
Gateway = default gateway
(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
(7) If the startup fails, delete the network card generation rule file, and then restart the virtual machine.

1.2. NAT mode

(1) View Linux routing address
View the status of VMnet8 network card on the window, right-click status details
Find the corresponding routing address
(2) View gateway
The gateway is
(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:
(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                 # Google domain name server
nameserver       # Domestic domain name server (China Telecom)

3. Test network

(1) Ping virtual machine router address
(2) Ping IP on Windows


Link to the original text: