ubuntu 20.04 修改dns

首先修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息,例如:

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信息已经写入其中了。

发表评论

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