CentOS in the virtual machine cannot access the Internet (connect: network is unreachable)

In the past, I remembered that after installing CentOS in VirtualBox, it could be used directly. Today, after installing it, I found that I could not access the Internet, and it was shown that connect network is unreachable when using ping. Through ifconfig, it is found that the network card has not been assigned an IP address. Considering that it is a DHCP problem, I sudo dhclient and find that I can access the Internet. However, after restarting, there is no IP anymore, so I have to modify the configuration file of the network card in the etc directory (/etc/sysconfig/network-scripts/ifcfg-[network device name]), and found that the ONBOOT option in the last line turned out to be no , change it to yes, and then it's normal.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326065202&siteId=291194637