VMware can't connect to the network after installing the Linux (CentOS) virtual machine

Open the VMware virtual network editor to see the three network modes of the virtual machine, namely bridge mode, NAT mode, and host-only mode.

bridge mode

The bridge mode is to use the virtual bridge to communicate between the host network card and the virtual network card of the virtual machine. Under the function of bridging, virtual machines in the virtual network can access each other and can access physical machines and external network devices, which is equivalent to an independent host.

NAT mode

In the NAT mode, the host network card is directly connected to the virtual NAT device, and then the virtual NAT device and the virtual DHCP server are connected to the virtual switch VMnet8, thus realizing the virtual machine networking. No external network device can access the virtual machine, but the virtual machine can.

host only mode

Since the host-only mode can only communicate with the host, it is not covered in this article. 


1. Method 1: Add a virtual network card directly

1.1 Select the virtual machine and open the settings of the virtual machine

1.2 Click Add 

1.3 Select the network adapter and click Finish

1.4 Click OK 

1.5 Try to ping Baidu, successfully ping

2. Method 2: Bridge mode

2.1 Start the virtual machine, right click on the desktop and click to open the terminal

2.2 Enter the command su to log in to the ROOT account (the password will not be displayed when entering the password, but it has actually been entered)

su

2.3 Enter vi /etc/sysconfig/network-scripts/ifcfg-ens33 to switch to the configuration file

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

2.4 Change ONBOOT =no to ONBOOT=yes (press the INSERT key on the keyboard to modify)

BOOTBROTO=dhcp //一般默认是dhcp,如果不是则改成dhcp
ONBOOT=yes

2.5 Change ONBOOT=no to ONBOOT=yes and press ESC to exit editing

2.6 Enter : wq! and press Enter to save the modification

:wq!

2.7 Enter the command reboot to restart the virtual machine, or restart it directly through the VMware operation interface

reboot

2.8 Select the virtual machine and open the settings of the virtual machine

2.9 Select the network adapter, then select the bridge mode and click OK below

2.10 After restarting the virtual machine, try to ping Baidu, and the ping is successful

3. Method 3: NAT mode

3.1 Start the virtual machine, right click on the desktop and click to open the terminal

3.2 Enter the command su to log in to the ROOT account (the password will not be displayed when entering the password, but it has actually been entered)

su

3.3 Enter vi /etc/sysconfig/network-scripts/ifcfg-ens33 to switch to the configuration file

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

3.4 Change ONBOOT =no to ONBOOT=yes (press the INSERT key on the keyboard to modify)

BOOTBROTO=dhcp //一般默认是dhcp,如果不是则改成dhcp
ONBOOT=yes

3.5 Change ONBOOT=no to ONBOOT=yes and press ESC to exit editing

3.6 Enter : wq! and press Enter to save the modification

:wq!

3.7 Enter the command reboot to restart the virtual machine, or restart it directly through the VMware operation interface

reboot

3.8 Select the virtual machine and open the settings of the virtual machine

3.9 Select the network adapter, then select the bridge mode and click OK below

3.10 After restarting the virtual machine, try to ping Baidu, and the ping is successful

Guess you like

Origin blog.csdn.net/Coin_Collecter/article/details/129980327