Centos 7 install loopback network card and virtual network card to realize virtual machine and host ping to access external network

Centos 7 install loopback network card and virtual network card to realize virtual machine and host ping to access external network

1. Install the loopback network card and configure the bridge mode

1. Experimental environment
( 1 ) Notebook
( 2 ) Windows 10  operating system
3VMware8
4 CentOS-7-x86_64
2. Experimental steps
( 1 ) Install KM-TEST network card under windows, take win10  as an example
Press the win + R keys, type in it: hdwwiz , and then click "OK"

The following installation interface appears:

 

( 2 ) Configure the static IP address of the loopback network card

The Ethernet 4 in the figure is the Mircrosoft KM-TEST loopback adapter. Click its properties to configure the static IP address of the loopback network card.

( 3 ) Open the virtual machine, select "Edit" -> "Virtual Network Editor", make sure to "bridge to " Microsoft KM-TEST loopback adapter".

( 4 ) Configure the IP address of Linux in bridge mode, assuming the first network card is used to bridge

Then configure the configuration file of the first network card /etc/sysconfig/network-scripts/ifcfg-ens33

vi /etc/sysconfig/network-scripts/ifcfg-ens33

Configure network card information

Exit and save the configuration file, restart the network card ens33
# ifdown ens33
# ifup ens33
# ifconfig ens33
( 4 ) Test whether the network is connected under Linux
# ping 172.16.68.100 -c 4
If the packet loss is equal to 0% , the network is connected. (If the ping fails, it may be windows fire prevention
The reason for the wall, remember to close)

2. Select settings, add a virtual network card and set it to net mode to achieve external network access.

Ifconfig view the generated network card, there is information about the added network card, which is ens37. The name may be different, but there will be a new network card name, just check in.

Command to realize copying, adding and modifying ifcfg-ens37 file

cd /etc/sysconfig/network-scripts/

ls

Note: After the network card is added, the configuration file of the ifcfg-ens37 network card is not generated. You need to manually copy and add changes.

cp ifcfg-ens33 ifcfg-ens37

Modify the copied configuration file, which can be set to static or dynamic. This article chooses to obtain an IP address dynamically.

vi /etc/sysconfig/network-scripts/ifcfg-ens37

After the configuration file is modified, it needs to be executed

The #systemctl restart NetworkManager command makes the modification of this file effective.

Click Edit, and then click Virtual Network Editor.

ping www.baidu.com

If the packet loss is equal to 0% , the network is connected.

I love to learn haha! Look forward to more exciting articles! ! !

Guess you like

Origin blog.csdn.net/weixin_41987016/article/details/109010948