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

终端回显:

[email protected]:~# systemd-resolve --status
Global
         DNS Servers: 119.29.29.29
                      114.114.114.114
赞(1) 打赏
转载请保留出处:耗子博客 » Ubuntu 修改永久 DNS
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

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

支付宝扫一扫打赏

微信扫一扫打赏

Loading