我通过 TP Link 路由器更新了 Cloudflare DNS 1.1.1.1
,它在我的移动设备和其他系统上运行良好,但在安装了 Ubuntu 18.04 LTS(最新版本)的系统中却不能完美运行。我遵循了很多方法和解决方案,但都不起作用,但 Google DNS 运行正常
我按照这个方法来修复但没有效果
$ sudo rm -f /etc/resolv.conf
$ sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 32 Oct 28 09:54 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
答案1
我在测试 Ubuntu 18.04 LTS 时也遇到了这个问题。
Ubuntu 有一个新的配置网络的系统:Netplan
要配置 DNS,您必须编辑 /etc/netplan 目录中名为 01-netcfg.yaml 的文件
您应该在设备 ID 条目下输入以下密钥。
nameservers:
addresses: [1.1.1.1]
您可以在示例中看到提到的键的位置,并且可以在 Netplan 链接中查找更多信息
示例复制自https://netplan.io:
network:
version: 2
# if specified, can only realistically have that value, as networkd can not
# render wifi / 3G.
renderer: NetworkManager
ethernets:
# opaque ID for physical interfaces, only referred to by other stanzas
id0:
match:
macaddress: 00: 11: 22: 33: 44: 55
wakeonlan: true
dhcp4: true
addresses:
- 192.168.14.2/24
- 192.168.14.3/24
- "2001: 1 :: 1/64"
gateway4: 192.168.14.1
gateway6: "2001: 1 :: 2"
nameservers:
search: [foo.local, bar.local]
addresses: [8.8.8.8]
routes:
- to: 0.0.0.0/0
via: 11.0.0.1
table: 70
on-link: true
metric: 3
routing-policy:
- to: 10.0.0.0/8
from: 192.168.14.2/24
table: 70
priority: 100
- to: 20.0.0.0/8
from: 192.168.14.3/24
table: 70
priority: 50