首先修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息,例如:
DNS=8.8.8.8 114.114.114.114
nano /etc/systemd/resolved.conf
加入
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文件
cat /etc/resolv.conf
就可以看到新的dns信息已经写入其中了。

发表评论 取消回复