Solve the problem that ping cannot be connected to external network after Centos7 is installed in VMware
- 2021-07-06 12:03:27
- OfStack
When configuring the cluster, the problem occurred. Originally, all three virtual machines can communicate with the external network by ping, but suddenly only one can communicate with the external network by ping. Between the three virtual machines, it can communicate with ping. After looking at many methods, I compared and looked at the three virtual machines
/etc/sysconfig/network-scripts/ifcfg-ens33
There is still no problem in the related network configuration, and later I found the answer on foreign websites
Answer link 1: https://geekflare.com/no-internet-connection-from-vmware-with-centos-7/
Answer link 2: https://stackoverflow.com/questions/22010904/cannot-connect-centos-vm-to-internet-nat-connection
The second answer link comes from stackoverflow.
Simply put, it is to use commands
dhclient -v
That is, to retrieve the IP address again.
The first answer first describes a problem: using ifconfig command can not get IP address (I personally installed mini version, did not install this command, and I can install 1 situation, of course, if you and I can not connect to the external network, then hehe hehe)
The authors give possible causes of the problem: the network adapter is not enabled, or the DHCP IP address cannot be obtained.
Answer 1 also gives the method of automatic startup:
Open
/etc/init.d
Create a file
net-autostart
(This can be named by itself.)
#!/bin/bash
# Solution for "No Internet Connection from VMware"
#
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
dhclient -v
After saving, change the permission by 1
chmod 755 net-autostart
Set up automatic startup
chkconfig --add net-autostart
Then restart
Summarize