如何设置 systemd-resolve DNS 服务器?

如何设置 systemd-resolve DNS 服务器?

Ubuntu 18.04 不再尊重本地配置。由于我无法再让 DHCP 服务器通告 DNS 服务器,因此我想手动设置客户端(LXD 容器)。我尝试编辑文件/etc/systemd/resolved.conf以更改行DNS=,查看文件内容:

# cat /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=192.168.1.11 192.168.1.29
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

然而,我仍然是一个不需要的 DNS 服务器fe80::5ee2:8cff:fe99:f106

# systemd-resolve --status
Global
         DNS Servers: 192.168.1.11
                      192.168.1.29
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 129 (eth0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.1.11
                      192.168.1.29
                      fe80::5ee2:8cff:fe99:f106
          DNS Domain: forumanalogue.fr

因此 DNS 查询返回错误结果,导致服务器环境无法正常工作。

# dig toot.forumanalogue.fr

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> toot.forumanalogue.fr
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62248
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;toot.forumanalogue.fr.         IN      A

;; ANSWER SECTION:
toot.forumanalogue.fr.  300     IN      A       151.127.52.79

;; Query time: 20 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Thu Jan 02 14:09:41 UTC 2020
;; MSG SIZE  rcvd: 66

dig返回公共 IP 地址。预期结果是

# dig toot.forumanalogue.fr @192.168.1.11

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> toot.forumanalogue.fr @192.168.1.11
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12877
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: a875a4c08c601052bf3b129e5e0dfb08254c48cf47944e9f (good)
;; QUESTION SECTION:
;toot.forumanalogue.fr.         IN      A

;; ANSWER SECTION:
toot.forumanalogue.fr.  604800  IN      A       192.168.1.39

;; AUTHORITY SECTION:
forumanalogue.fr.       604800  IN      NS      ns2.forumanalogue.fr.
forumanalogue.fr.       604800  IN      NS      ns.forumanalogue.fr.

;; ADDITIONAL SECTION:
ns.forumanalogue.fr.    604800  IN      A       192.168.1.11
ns2.forumanalogue.fr.   604800  IN      A       192.168.1.29

;; Query time: 0 msec
;; SERVER: 192.168.1.11#53(192.168.1.11)
;; WHEN: Thu Jan 02 14:15:36 UTC 2020
;; MSG SIZE  rcvd: 161

相关内容