Virtual machine has no network in VMware NAT mode-troubleshooting highlights

  • System version:
    cat /etc/redhat-release
    Insert picture description here
    Centos 7.7
  • dhcp dynamic configuration is as follows
cat /etc/sysconfig/network-scripts/ifcfg-ensxxx #注意网卡名要与文件名后的网卡名称对应一致
DEVICE=eth0
BOOTPROTO=dhcp
IPV6INIT=no
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
GATEWAY=10.0.0.2
DNS1=8.8.8.8
DNS2=8.8.4.4
  • The static static IP configuration is as follows
cat /etc/sysconfig/network-scripts/ifcfg-ensxxx #注意网卡名要与文件名后的网卡名称对应一致
DEVICE=eth0
BOOTPROTO=static
IPV6INIT=no
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
IPADDR=10.0.0.10
NETMASK=255.255.255.0
GATEWAY=10.0.0.2
DNS1=114.114.114.114
DNS2=8.8.4.4
  • Restart the network after the change
systemctl restart network
#如果是红帽6及红帽6.5的可以使用如下命令
/etc/init.d/network restart

During the startup process, observe whether the log reports an error, you can modify the configuration according to the corresponding error report

#查看状态
systemctl status network
/etc/init.d/network status
#查看日志
journalctl -xl
  • Virtual machine
    Insert picture description here
    settings After clicking change settings, click Add Network to create a new virtual network. I have already built it here, as shown in the figure VMnet0, as shown in the
    Insert picture description here
    figure. Here I set the subnet ip segment to 10.0.0.0/16, and click the nat setting
    ![Insert picture description here](https://img-blog.csdnimg.cn/20210125151201839.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4cx0ND,size3FF,size
    as shown in the figure. The gateway setting is 10.0.0.2 The settings here are consistent with the GATEWAY parameters in the above configuration file.
    Insert picture description here
    Save, click Apply and exit
  • Turn off the network service that comes with linux
#上述IP配置文件已配置不受网络控制,这里是否关闭影响不大,操作可选
systemctl stop NetworkManager
#查看状态
systemctl status NetworkManager

Insert picture description here

  • At this time, after restarting the network, the ip display is normal, and there is no error log after restarting the network, but the external network is still not connected; the performance status is as follows:
    ① normal startup
    Insert picture description here
    ② normal status
    Insert picture description here
    ③ check ip
ip a

As shown in the figure, the ip is displayed normally, the network card in the box is also in the startup state "UP", but the arrow points to the state is DOWN,
Insert picture description here
indicating that the problem lies here.
Solution: Because there is no log error, so check whether the current virtual machine is already Use the configured nat network group
①Open the virtual machine settings Insert picture description here
②Select Hardware --> Network Adapter --> Network Connection --> Custom, select the NAT mode just set (VMware0), confirm the application exit ③Retry Insert picture description here
at this time, It is recommended to restart the network and try again, and check the ip again

ip a

Insert picture description here
Normal at this time

  • If you complete the above operations, the network is still blocked, please check the firewall and selinux
iptables -L | egrep -i "reject|drop"
iptables -t -nat -L | egrep -i "reject|drop"
#如果上述有输出,则运行以下命令
iptables -F
iptables -t -nat -F
#检查selinux
getenforce
#如果值为Enforcing,运行如下命令
setenforce 0
  • Finally, pay attention; in nat mode, the local network is normal, and the virtual machine network can be used normally

Guess you like

Origin blog.csdn.net/qq_38774492/article/details/113113019
Recommended