一台AI4Green的服务器,重启后发现DNS配置丢失,虽然服务还是能照常提供,但是存在隐患,需要解决该问题。
通过百度搜索,发现问题原因是:重启后/etc/resolv.conf文件被重写成127.0.0.53
解决方法是:重新配置好resolv.conf文件,并关闭systemd-resolved
执行:
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
但是提示:
Unit /etc/systemd/system/systemd-resolved.service is masked, ignoring.
于是将其unmask
sudo systemctl unmask systemd-resolved
然后再disable:sudo systemctl disable systemd-resolved,成功!
然后修改/etc/resolv.conf文件:
$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 114.114.114.114
nameserver 8.8.8.8
重启后
问题照旧
编辑文件
sudo vi /etc/NetworkManager/NetworkManager.conf
在main部分加上一句dns=default:
变成这样
[main]
plugins=ifupdown,keyfile
dns=default
再重启,问题搞定!