Ubuntu20.04 系统中设置dns并生效

修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息

DNS=2001:4860:4860::8888 2001:4860:4860::8844
DNS=8.8.8.8 114.114.114.114

 

然后退出保存。

然后以root身份在ubuntu终端中依次执行如下命令:

systemctl restart systemd-resolved
systemctl enable systemd-resolved
mv /etc/resolv.conf /etc/resolv.conf.bak
ln -s /run/systemd/resolve/resolv.conf /etc/
再查看/etc/resolv.conf文件就可以看到新的dns信息已经写入其中了。
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注