How to solve the problem of Ubuntu not being able to access the Internet

Problems and phenomena

The Ubuntu virtual machine (18.04) always fails to access the Internet for no apparent reason.
Use ifconfig -a the command to check. ensxx(xx is the ID number assigned to the virtual machine). The corresponding network card has a mac address, but no IP address is assigned.
There is no Wired option in Network.

Temporary solution

After using it  sudo dhclient ensxx, you can get the IP again and you can surf the Internet normally, but it will not work after restarting.

permanent solution

Finally a permanent solution was found.

sudo service network-manager stop 
sudo rm /var/lib/NetworkManager/NetworkManager.state 
sudo service network-manager start

Guess you like

Origin blog.csdn.net/m0_55333789/article/details/132877430