使用的 dns resolver

sudo systemctl start systemd-resolved.service

cat resolv.conf 
# Generated by NetworkManager
nameserver 127.0.0.53

ubuntu17.0之後特有,使用此dns解析機制,systemd-resolvd服務會一直覆蓋

不想使用,可改

ubuntu17.0之後,systemd-resolvd服務會一直覆蓋

解決辦法
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
sudo apt install unbound
sudo rm -rf /etc/resolv.conf
sudo vim  /etc/NetworkManager/NetworkManager.conf

在[main]
下面添加
dns=unbound
將dns服務替換為unbound
reboot
重啟電腦即可,開機查看resolve.conf發現nameserver自動配置

可以安裝一個軟件包resolvconf,它將修改/etc/resolv.conf在系統啟動時的方式。
sudo apt install resolvconf
sudo systemctl enable resolvconf.service
然後,你可以修改文件/etc/resolvconf/resolv.conf.d/tail。
文件放入一行nameserver 8.8.8.8,則在開機時將這裡行添加到/run/resolvconf/resolv.conf的末尾。
/etc/resolv.conf現在是這個文件的符號鏈接
resolv.conf -> ../run/resolvconf/resolv.conf

sudo vi /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile
dns=none

[ifupdown]
managed=true

[device]
wifi.scan-rand-mac-address=no

Last updated