linux vm Virtual machine network connection failure , Restart network card failure causes and solutions
NAT Pattern Bridging mode Host only mode
( 1 ) NAT Pattern ： Network address translation NAT Mode with virtual NAT Devices and virtual DHCP The server , Make virtual machines Networked , This is a VMware One of the most commonly used networking modes in , This connection uses VMnet8 Virtual switch . In the same place NAT The system in network mode passes through VMnet8 The switch communicates .NAT In the network mode IP Address 、 Subnet mask 、 Gateway and DNS Servers are all through DHCP The distribution of . The system in this mode uses virtual when communicating with the outside world NAT The server , therefore , Virtual machines don't have to have their own... In an external network IP Address . From the perspective of external network , Virtual machine and host are sharing one IP Address , By default , The external network terminal can not access the virtual machine .
(2 ) Bridging mode ： It is to hand over the virtual network adapter of the virtual machine with the physical network adapter of the host , The virtual network adapter in the virtual machine can directly access the external network through the physical network adapter in the host , This pattern is also easy to understand , A system that chooses to use a bridging network is like a separate host in a local area network , It's as like as two peas , And it's also connected to this real network . So if you want this system to be networked , This system needs to be set up in the same way as the external real host , If you want to treat virtual machine as a completely independent computer , And allow it to communicate with other terminals in the same way , So bridging mode is usually the easiest way for virtual machines to access the network .
( 3 ） Host only mode ： This pattern and NAT The pattern is similar , But it's more than NAT Mode more closed network connection mode , Even if the hosts in this networking mode are connected to each other , But the default is not connected to the external network , This is a network experiment （ Especially worms ） You don't have to worry about spreading to the outside .
Image theory ：
NAT Virtual machines in mode , It's just a black household without a registered permanent residence , Router " Civil Affairs Bureau " I didn't know there was such a person , Nature will not actively communicate with it . Even if the virtual machine occasionally sends out point letters , All have to be forwarded to the host in the name of the host , The host also hired a special person called NAT Our boss is responsible for sending letters to these virtual machines 、 The receipt of the letter .
Virtual machines in bridge mode , It's like a router " Civil Affairs Bureau " Where? " I have been registered " Adults of , Have your own residential address , Although I live in the same yard as the host , But somehow it's people with registered permanent residence , You can communicate directly with the outside world .
Host only virtual machines , It's a total black slave , Not only is there no account 、 Router " Civil Affairs Bureau " I don't know such a person , It's also locked in a small black room by the main engine , Even letters are not allowed to be sent out .
vmnet1: This is a Host Used with Host-Only Virtual network for communication -（ Only host network card .
vmnet8: This is a Host Used with NAT Virtual network card for communication .-（Nat） Host and virtual machine IP The address is not in the same segment ,IP The address is virtual , Through the virtual network card to achieve broadcast
If you look at it and find vm The host of the virtual machine does not have vmnet1 vmnet8 （ Pictured above ） Network card configuration , But the basic configuration of the network card is correct , And the query start command is correct It's very likely that network And NetworkManager A conflict ( The most common reason )
resolvent ： Ban NetworkManager
1 Temporarily disabled stop (centos6) service NetworkManager stop (centos6) systemctl stop NetworkManager (centos7) permanent chkconfig NetworkManager off (centos6) systemctl disable NetworkManager (centos7)
2 Restart NIC service network restart（ With centos 7 For example ）
（1） Edit network card profile ：
vi /etc/sysconfig/network-scripts/ifcfg-eth33(160) [ Take bridge mode for example ]
1. As shown in the figure above ： Open the network card configuration file , You can see the cursor flashing 2. Press the up and down keys of the keyboard , You can move the cursor . 3. Move the cursor to the last line （ Keep pressing the key ） Of no After the word , Press the letter a key 4. Press the back button （backspace key ）, Delete no, Change it to yes. 5. Then press esc key , Exit insertion mode . 6. In English input mode , Enter a colon （shift+ The colon ）wq And then go back 7. Exit file editing
（2） Restart NIC
service network restart（ With centos 7 For example ）
// The next issue is vm Under the virtual machine centos7 Three kinds of network configuration detailed steps （ The bridge NAT Host only ）