Ubuntu18.4设置永久DNS

1. 打开 /etc/systemd/resolved.conf,设置变量DNS:

$ sudo gedit  /etc/systemd/resolved.conf

2. 单击"save" 按钮,保存设置

3. 输入一下命令,使设置生效

$ systemctl restart systemd-resolved //重启systemd-resolved服务
$ systemctl enable systemd-resolved//使能systemd-resolved服务

$ mv /etc/resolv.conf  /etc/resolv.conf.bak//备份修改前的resolv.conf,这一步可以省略。
$ ln -s /run/systemd/resolve/resolv.conf /etc/  //这一步必须执行,否则DNS设置不能有效

注:

1. 亲测可行

2. 和ubuntu14.4的DNS方法是不一样的,如果你的是ubuntu14.4版本,可在百度上搜索,不能使用本文方法去设置。

参考:https://blog.51cto.com/yangzhiming/2439681

猜你喜欢

转载自blog.csdn.net/renlonggg/article/details/104252580