每次重启后都需要重新启动 systemd-resolved

每次重启后都需要重新启动 systemd-resolved

不久前我安装了 dnscrypt-proxy,并修改了我的resolv.conf设置systemctl。然后它停止与我的互联网合作,所以我删除了它。我试图恢复旧设置,但每次我重新启动 Ubuntu 时它们都会消失。现在我每次都必须运行这 3 个命令才能使我的互联网连接再次正常工作:

 nano /etc/resolv.conf 

 //To set "nameserver 127.0.0.53"

 systemctl restart systemd-resolved.service

 sudo service network-manager restart

我该怎么做才能彻底修复它?

答案1

如果您想将名称服务器永久设置为 127.0.0.53,请尝试以下操作:

(1) sudo nano /etc/systemd/resolved.conf

and add:

[Resolve]
DNS=127.0.0.53
(2) sudo nano /etc/dhcp/dhclient.conf

and add:

supersede domain-name-servers 127.0.0.53;

(3)

(A) Click on NetworkManager icon in the system tray 
> Edit connections
> Select the connection you like to edit, e.g.: 'Wired connection 1'
> Click the "Gear" icon to edit the connection
> IPv4 settings
> Method
> Select "Automatic (DHCP) addresses only"
> in the "DNS Servers" field (enter): 127.0.0.53
> Save

或者

(B) Find out the connection name from Network Manager, e.g.: 'Wired connection 1'

sudo nano '/etc/NetworkManager/system-connections/Wired connection 1.nmconnection'

and add:

[ipv4]
dns=127.0.0.53;
dns-search=
ignore-auto-dns=true
method=auto

保存、重新启动并检查(1)/etc/resolv.conf其中的名称服务器,以及(2)ping askubuntu.com检查互联网连接。

相关内容