主机文件不再忽略中线注释

主机文件不再忽略中线注释

我刚刚从 ubuntu 16.04 升级到 18.04

我的 /etc/hosts 文件有许多行,格式如下:

1.1.1.1 domain1.net domain2.net # domain3.net domain4.net

(换句话说,我原本希望所有4个主机名都指向1.1.1.1,但后来改变了主意,希望domain3.net和domain4.net通过DNS解析)

在升级操作系统之前,这按预期工作。升级后,我发现所有4个域都解析到指定的IP地址:

$ ping domain3.net
PING domain3.net (1.1.1.1) 56(84) bytes of data.

哪些软件可能发生了变化而导致了这种行为?有什么办法可以恢复到以前的行为吗?


其他发现:

$ nslookup
> domain1.net
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   domain1.net
Address: 1.1.1.1
> domain3.net
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   domain3.net
Address: 1.1.1.1

来自关于 dnsmasq 和 systemd 的问题

$ dnsmasq --version
Dnsmasq version 2.79  Copyright (c) 2000-2018 Simon Kelley
Compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify

$ systemd --version
systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid

$ ps aux |grep dnsmasq
lxc-dns+  3395  0.0  0.0  52876   384 ?        S    Aug29   0:00 dnsmasq -u lxc-dnsmasq --strict-order --bind-interfaces --pid-file=/run/lxc/dnsmasq.pid --listen-address 10.0.3.1 --dhcp-range 10.0.3.2,10.0.3.254 --dhcp-lease-max=253 --dhcp-no-override --except-interface=lo --interface=lxcbr0 --dhcp-leasefile=/var/lib/misc/dnsmasq.lxcbr0.leases --dhcp-authoritative
lxd       3835  0.0  0.0  52876  2092 ?        S    Aug29   0:00 dnsmasq --strict-order --bind-interfaces --pid-file=/var/lib/lxd/networks/lxdbr0/dnsmasq.pid --except-interface=lo --interface=lxdbr0 --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address=10.35.228.1 --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/lib/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/lib/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range 10.35.228.2,10.35.228.254,1h --listen-address=fda0:a426:431:225d::1 --enable-ra --dhcp-range ::,constructor:lxdbr0,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/lib/lxd/networks/lxdbr0/dnsmasq.raw -u lxd

来自关于 nsswitch 的问题:

$ grep ^hosts: /etc/nsswitch.conf
hosts:          files myhostname mdns4_minimal [NOTFOUND=return] wins dns

来自关于 avahi 的问题:

$ ps aux |grep avahi
avahi     1228  0.0  0.0  49468  5564 ?        Ss   Aug29   0:02 avahi-daemon: running [BCMSVR.local]
avahi     1410  0.0  0.0  47076   332 ?        S    Aug29   0:00 avahi-daemon: chroot helper

/etc/avahi/hosts 未修改,仅包含注释,例如

# Examples:
# 192.168.0.1 router.local
# 2001::81:1 test.local

来自有关正在侦听端口 53 的内容的问题:

$ sudo lsof -Pn 2>&1 | grep LISTEN | grep :53 
systemd-r   952           systemd-resolve   13u     IPv4              22349         0t0        TCP 127.0.0.53:53 (LISTEN)
gdomap     1775                    nobody    5u     IPv4              25908         0t0        TCP *:538 (LISTEN)
dnsmasq    3395               lxc-dnsmasq    7u     IPv4              39172         0t0        TCP 10.0.3.1:53 (LISTEN)
dnsmasq    3835                       lxd    9u     IPv4              39488         0t0        TCP 10.35.228.1:53 (LISTEN)
dnsmasq    3835                       lxd   11u     IPv6              39490         0t0        TCP [fe80::c874:a1ff:fec6:e4e]:53 (LISTEN)
dnsmasq    3835                       lxd   13u     IPv6              39492         0t0        TCP [fda0:a426:431:225d::1]:53 (LISTEN)

相关内容