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
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.
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
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! ! !