0

I'm trying to configure the nameservers in my Ubuntu 18.04 with netplan. I got a DNS server which is running on my localhost (127.0.0.1). My configuration looks like this:

network:
  ethernets:
    ens160:
      addresses: [172.16.0.1/16]
      dhcp4: 'no'
      dhcp6: 'no'
      gateway4: 172.16.100.1
      nameservers:
        addresses: [10.0.0.8, 8.8.8.8, 10.15.0.18, 127.0.0.1]
  version: 2

And when I'm doing an nslookup on some DNS name in my env it fails. The dig command is failing too with the NXDOMAIN error.

But, when I change the order of the addresses in the nameservers section to [127.0.0.1, 10.0.0.8, 8.8.8.8, 10.15.0.18], after applying the configuration with netplan apply the nslookup query works and the dig outputs correctly with NOERROR.

My question is: why there is any significance to the order of the DNS servers? How can I force the netplan conf to look always in the 127.0.0.1 regarding all\specific domain?

BTW all netplan apply are successful without any errors.

0

Figured it out- the DNS works with failover only if the DNS server is unreachable or there is a specific configuration in the DNS service to fallback to the next DNS server...

So yes- there is a significance to the order in the netplan nameservers configuration.

  • 1
    However, systemd-resolved is also sticky when it fails over to a later DNS server in the list. So if you list 127.0.0.1 first, and 127.0.0.1 goes down, and resolved falls back to 10.0.0.8, it will continue using 10.0.0.8 until restart or another DNS server failure. So you shouldn't use multiple DNS server addresses in an interface's nameserver section which don't all have the same view of names. Instead you probably want to use per-domain DNS servers as described in resolved.conf(5). – slangasek May 13 at 2:58

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.