Ubuntu 修改永久 DNS

新版 Ubuntu 每次在 /etc/resolv.conf 修改DNS之后,重启就会失效。

永久修改需要编辑 /etc/systemd/resolved.conf 文件。

该文件默认内容如下:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

我们要做的就是取消 DNS 项的注释,并在后面填入合适的 DNS 服务器(可以多行)。

例如 DNS=119.29.29.29 ,然后保存并重启 systemd-resolved 服务。

systemctl restart systemd-resolved.service

最后可以查看下修改结果。

systemd-resolve --status

终端回显:

root@ubuntu:~# systemd-resolve --status
Global
         DNS Servers: 119.29.29.29
                      114.114.114.114
赞(3) 打赏
转载请保留出处:耗子博客 » Ubuntu 修改永久 DNS
广告

评论 抢沙发

金额随意,一百两百也不介意的啦

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏

登录

找回密码

注册

Loading...