systemd-resolved关闭,关闭Ubuntu自带的dns解析服务

systemd-resolved关闭,关闭Ubuntu自带的dns解析服务

原来的 53 端口被 systemd-resolved 占用。想自行安装dns解析器,必须解除占用

编辑 resolved 服务文件

sudo vim /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
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes  将这行的注释拿掉,改为no保存,如下
DNSStubListener=no  
#ReadEtcHosts=yes

重新链接 resolv.conf 文件

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
#s表示软链接
#f表示存在即覆盖

原来的 /etc/resolv.conf 也是一个软链接,链接的是:

/run/systemd/resolve/stub-resolv.conf    ->   /etc/resolv.conf

重启系统即可 reboot

systemctl restart systemd-resolved.service

Copyright: 采用 知识共享署名4.0 国际许可协议进行许可

Links: https://zwc365.com/2024/01/17/systemd-resolved关闭关闭ubuntu自带的dns解析服务

Buy me a cup of coffee ☕.