Centos7 dual network card configuration
Because the network configuration of centos7 is different from that of previous versions, I have taken many detours in the process of configuration, so I can sum up as follows:
There are two network services in centos7: NetworkManger.service and network.service. NetworkManager.service is often called to configure the network information through the interface, but if the two are used at the same time, sometimes there will be conflicts and the network will be blocked.
Therefore, here we first use NetworkManager.service to configure the network card to generate a configuration file, then turn off the NetworkManager.service service and turn on the network.service service, and finally set the former to boot off and the latter to boot startup.
Check the status of the service first
Systemctl status NetworkManager.service
If it is not open, please execute
Systemctl restart NetworkManager.service
In order to facilitate the configuration of network information, we configure the network card information directly through the interface.
The premise is that two network cards have been created, one of which is a 172.16.x.x network segment and is connected to the external network. Another network card is the 192.168.x.x network segment, which connects to the intranet. The following is the network card information that I configured according to my own external network environment.
At this point, we go to the terminal to view the configuration files of these two network cards.
Cd / etc/sysconfig/network-scriptsls
You can see the two files that start with ifcfg-. Of course, ifcfg-ens33 and ifcfg-ens34 are the files I have changed (the original files are ifcfg-Wired_connection_1 and _ 2 in the picture). The name of the file name, which needs to be viewed using ifconfig.
Ifconfig
Once you know the name of the network card, you can change the original file, but you should know which network card corresponds to the internal network or the external network, through the
Cp ifcfg-Wired_connection_1 ifcfg-ens33cp ifcfg-Wired_connection_2 ifcfg-ens34vi / etc/sysconfig/network-scripts/ifcfg-ens34
Change the NAME name to ens34, and then save it by ctrl+c: wq
The other file is changed in the same way, so stop using the NetworkManager.service service with the following command and set it to boot and not start. And restart the network service
Systemctl stop NetworkManager.servicesystemctl disable NetworkManager.servicesystemctl restart network
By using the
Systemctl enable network.service
Will find that it appears.
So we need to reuse it.
/ sbin/chkconfig network on
Set the boot mode for network.service.
Finally, restart the virtual machine.
Reboot
You can see that you can already connect to the network