3

I've just upgraded from ubuntu 16.04 to 18.04

My /etc/hosts file has a number of lines in the form:

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

(In other words, I had originally wanted all 4 hostnames to point to 1.1.1.1, but then changed my mind and wanted domain3.net and domain4.net to resolve by DNS instead)

Prior to upgrading OS, this worked as intended. After the upgrade, I find that all 4 domains resolve to the specified IP address:

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

What software might have changed to lead to this behaviour? Is there any way to revert to the older behaviour?


Additional findings:

$ 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

From a question about dnsmasq and 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

From a question about nsswitch:

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

From a question about 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 is unmodified and only contains comments, such as

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

From a question about what is listening on port 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)
  • 2
    The hosts(5) manual on Ubuntu 18.04 has not changed between releases, and still says that the hosts file format supports comments just like you are used to. [Not knowing very much about Ubuntu, I would say that] This is either a software bug or a documentation bug. – Kusalananda Aug 30 '18 at 12:23
  • 1
    It would be interesting investigating whether this could be caused by a dnsmasq or systemd bug, or if it is something else; there was a good while ago a similar bug in systemd for the sysctl.conf file. – Rui F Ribeiro Aug 30 '18 at 12:33
  • 1
    What is the output of grep ^hosts: /etc/nsswitch.conf ? – Jeff Schaller Aug 30 '18 at 13:00
  • 2
    These outputs are much easier to read if they're edited into your question -- thanks! – Jeff Schaller Aug 30 '18 at 13:12
  • 2
    Please would you edit your question to include this information (ideally, as if you'd provided it in the first place). You should consider comments to be transient and not somewhere to add extra detail. At the moment your question is really hard to read, which makes it harder to answer. – roaima Aug 30 '18 at 14:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.