Problem: Ubuntu 20 DNS is automatically overwritten to
the static IP address set in the interface environment of 127.0.0.53, and then the IP can be pinged, but the webpage cannot be accessed. The initial judgment is a DNS problem.
Check the content of sudo cat/etc/resolv.conf and find that it is 127.0.0.53
Temporary solution, modify the file /etc/resolv.conf to fill in Ali DNS
vim /etc/resolv.config
Add nameserver 223.5.5.5 to the file
and modify it according to the actual situation.
After the modification is completed, it is generally ok, if not, repeat the modification of the following files
sudo vi /etc/resolvconf/resolv.conf
It has been changed here and you can go online normally, but you will find that it will be automatically changed back after the computer is restarted.
The final solution:
1 in 3 steps
, stop and disable systemd-resolved.
2. Set the dns of NetworkManager to default
3. Restart NetworkManager.
………………… The actual steps are as follows……………
1 Disable and stop the systemd-resolved service:
first disable the service
sudo systemctl disable systemd-resolved.service
then stop the service
sudo systemctl stop systemd-resolved
2 Set DNS to default
vim /etc/NetworkManager/NetworkManager.conf
In the [main] section add
dns=default
Remove the symlink /etc/resolv.conf
rm /etc/resolv.conf
3 restart network-manager
sudo service network-manager restart
It can be seen that the DNS will not change even if the computer is restarted
Matters needing attention
Since ubuntu18, the network management mode has changed. Set the configuration of fixed IP in /etc/network/interfaces, even if the configuration does not take effect, it will be changed to netplan mode, and the configuration will be written in /etc/netplan/01-netcfg .yaml or a yaml file with a similar name". Refer to
https://blog.csdn.net/fansnn/article/details/105930009 for specific configuration methods.
On 18.04 Desktop, the basic management level is netplan -> NetworkManger -> systemd- The resolved
DNS cannot be saved. The essence is that
the renderer of /etc/netplan/01-network-manager-all.yamlnetplan is set to NetworkManager.
According to the command
sudo NetworkManager --print-config
You can see that NetworkManger's dns is set to
systemd-resolved
Reference link
https://www.jianshu.com/p/cf4498ad2f0c
https://ubuntuqa.com/article/6573.html
https://blog.csdn.net/fansnn/article/details/105930009