Every time I should be getting an error because a domain does not exist (e.g. could not resolve host), I instead get an error about connecting to a loopback address:

$ curl -4 -v https://nonexist.invalid

The problem only starts occuring about 2 seconds after establishing a wireless connection. For a short time, all works as expected.

I am using systemd-resolved and dns appears to be working:

$ readlink /etc/resolv.conf
$ dig +short A example.com
$ dig +short A nonexist.invalid
$ systemd-resolve -t A nonexist.invalid
nonexist.invalid: resolve call failed: No appropriate name servers or networks for name found

If name resolution looks okay, why would programs still appear to be resolving names to


It's DNS. The search domain setting is causing this:

$ cat /etc/resolv.conf
options edns0
search localhost

A router tricked Ubuntu into expanding names with a search domain that receives special treatment from systemd-resolved and as such breaks expected behavior:

The hostnames "localhost" and "localhost.localdomain" (as well as any hostname ending in ".localhost" or ".localhost.localdomain") are resolved to the IP addresses and ::1.

Solution A: Reconfigure the router to send a more appropriate search domain

Solution B: disable automatic DNS configuration, e.g. in NetworkManager you can disable it just for either Ipv4 or IPv6 if the issue is limited to one. The corresponding option in the text config format is ignore-auto-dns.

# /etc/NetworkManager/system-connections/WLAN
# ..
# ..

Not a solution: edit /etc/dhcp/dhclient.conf (this configuration cannot supersede IPv6 Router Advertisment DNSSL)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.