Common errors in VMWare network configuration and their solutions
Article directory
Network Configuration |
1. First check the IP address of our computer.
Use "Windows+R", enter "cmd", and enter the following command in the dialog box to view the IP of the local computer.
ipconfig
2. Edit network editor
Then select "Edit" → \rightarrow in the VMware interface→ "Virtual Network Editor", select Change settings in the virtual network editor. Select WVMnet8, modify the subnet IP and subnet mask, and then modify the NAT settings. Pay special attention here thatthe network segment in the subnet IP must be consistent with the network segment of the local computer.
The local computer IP address here is 192.168.31.169, and the network segment is 192.168, so the subnet IP on the virtual machine is set to 192.168.0.1 (it will become 192.168.0.0 after saving), and the subnet mask of the local virtual machine is The code is 255.255.255.0, then the subnet mask of the virtual machine is set to 255.255.255.240.
Then click NAT Settings and modify the gateway IP. Pay special attention here that the network segment in the gateway IP must be consistent with the network segment of the default gateway of the local computer . The default gateway of the local computer here is 192.168.31.1, and the gateway IP of the virtual machine is set to 192.168.0.2.
PS: The last two digits of the virtual machine gateway cannot be the same as the local computer, nor can they be the same as the virtual machine subnet IP address. After modification, click "Apply" and "OK".
3. Modify the VMnet8 IP of the local computer
You can directly search for "Network Status" in the taskbar search box of the machine, select "Ethernet" in the pop-up settings window, and then select "Change Adapter Options".
Select "Change Adapter Options" in "Related Settings", a network connection window will pop up, right-click "VMware Network Adapter VMnet8" and select Properties.
In the pop-up dialog box, select "Internet Protocol Version 4 (TCP/IPv4)", modify the IP address inside, and click OK. The network segment settings of the local computer also need to be consistent .
Set the content as follows:
The network segments of the IP address and default gateway are both 192.168. The last two digits of the IP address cannot be the same as those of the virtual machine, so they are set to 192.168.0.7; and the default gateway needs to be consistent, so it is set to 192.168.0.2.
Then set the DNS server address and set the "Preferred DNS Server" to 8.8.8.8. Note that it cannot be empty or 0.0.0.0, otherwise the network setup of the virtual machine may fail.
4. Change virtual machine network card settings
Open the virtual machine interface, right-click on the virtual machine and open the terminal. Enter the following command to enter this directory. You can see the ifcfg-ens33 file and enter the modified file.
cd /etc/sysconfig/network-scripts
ls
vim ifcfg-ens33
Then press i to enter file insertion mode and modify the file content as follows:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=50df2512-62eb-4a34-a203-af1456c80fe6
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
GATEWAY=192.168.0.2
DNS1=8.8.8.8
The content modified here is 3 parts:
(1) Set the IP to static;
(2) Set the computer to automatically turn on after startup;
(3) Modify the IP address, subnet source code, gateway and DNS address of this virtual machine.
PS: The IP address here must be consistent with the modification content of the virtual network editor.
After modification, click "Esc" data ":wq" to save the file and exit.
After setting up, we restart the virtual machine, enter the command to reconfigure the network settings, and then enter the command Unicom URL to check whether the connection to the network is successful. Enter "Ctrl" + "C" on the keyboard to interrupt the connection.
service network restart # 配置网络设置
ping www.baidu.com # 联通网络
ping 192.168.31.169 # 联通本地电脑的IP
The successful results of China Unicom Network are as follows:
You can also open a browser to see if it is successful.
It is shown here that the virtual machine has successfully pinged the network and the local machine, and can also access the Internet successfully; the local machine has also successfully pinged the virtual machine network, indicating that the network setting is successful.
Common network settings errors and solutions |
Although there are only 4 steps to configure the network of a virtual machine, each step is crucial, otherwise various errors may occur during the configuration process.
Report error ①
In the above step 2, the following error message often appears
There are two reasons for this error:
-
The IP network segment of the local computer is inconsistent with the IP network segment settings of the virtual machine. For example, if the local computer IP is 192.168 and the virtual machine network IP is set to 10.4, an error will be reported;
-
The virtual machine subnet mask is the same as the subnet mask set on the local machine. Usually the last digit of the local subnet is 0. If the last digit of the virtual machine's subnet mask is also set to 0, an error message will appear.
Solution:
The IP address and gateway IP network segment must be consistent, and the last digit of the subnet mask is set to 240 .
Report error②
If the WiFi connected to this machine is an intranet, it may also cause the network connection to be unsuccessful.
For example: when connecting to the school's WiFi, the wireless LAN adapter WLAN will have a specific DNS suffix, which will cause obstacles in the connection establishment between the local network and the virtual machine network, resulting in failure of the establishment.
Solution:
Use your mobile phone to turn on a hotspot to build a network, or connect to other WiFi.
Report error ③
If the local computer has firewall protection turned on, it may also cause the network connection to fail. Just turn off the firewall on your local computer.
Report error ④
When modifying the "ifcfg-ens33" file, the file is in read-only mode and the modifications cannot be saved.
Solution:
Replace the ":wq" command to save the modified content with the following command line to successfully solve the problem.
:w!sudo tee%
If you still cannot save the modified file, you can choose to restart the virtual machine and modify the file again.
Report error ⑤
If all network settings are configured, but the virtual machine still cannot connect to the network, an error will appear when pinging the network.
Solution:
First check whether the network card configuration file in the virtual machine is consistent with that in the ifcfg-ens33 file, and check whether the IP address, gateway, DNS and other aspects in the ifcfg-ens33 file are set properly. If everything is correct, restart the network card. .
ip add #查看虚拟机网卡
cat /etc/sysconfig/network-scripts/ifcfg-ens33 #检查文件
systemctl restart network #重启网卡
Then test the mutual ping situation between the local machine and the virtual machine. If the local machine can ping the virtual machine, but the virtual machine cannot ping the physical machine, it means that the virtual machine still cannot access the external network, and you need to proceed to the next step.
vim /etc/resolv.conf #打开并修改/etc/resolv.conf文件
nameserver 192.168.0.1 #添加nameserver + 虚拟机的网关
Then "Esc" + ":wq" save and exit.
Modify the file content as follows:
Save and then restart the network.
systemctl restart network.service
Test the connection to www.baidu.com and the physical machine. If the test is successful, the issue will be resolved smoothly.
The above are the errors encountered in network configuration and their solutions. If it is helpful to you, please add a follow~