recently I had to add another nic to one of my VMs and noticed a few hickups. Turns out that NIC2 overwrote the DNS settings obtained by the dhcp server on NIC1. I could obviously make that static, but would really like to avoid that. Is there any way to prioritize one NIC over the other? How does Debian decide which dhcp server to get it's dns settings from?

Thanks in advance

1 Answer 1


If your DHCP clients are configured to directly overwrite the /etc/resolv.conf file, the last set of DNS addresses written in wins, and when any interface goes down, the settings that were in effect before that particular interface was configured will be restored, which may lead to unexpected results if the interface shutdown order is not exactly the reverse of the interface start-up order.

(I guess DHCP was originally intended for "simple" clients that have just one NIC to configure, and nobody thought much about how to deal with multiple DHCP-configured interfaces on the same host. Classically, when you had a multi-homed host = a host with multiple NICs in separate networks, that was usually reason enough to assign static IP addresses for it.)

If you are using the resolvconf package to centrally manage your DNS settings, it will remember which interface provided which DNS settings, merge them all, and when an interface is disabled, it will re-do the merge without the settings that were provided by the disabled interface, which might be the right thing to do in most cases.

But if you use systemd-resolved, your resolv.conf will just say nameserver and the real DNS server settings can be viewed and managed using the resolvectl command. systemd-resolved will understand global and per-link DNS settings, and can be more versatile than traditional DNS settings.

If you use a network configuration management system, such as NetworkManager, it will add another layer on top of all this.

If you are using classic resolv.conf-based DNS configuration (either with or without the resolvconf package), remember that the DNS resolver library assumes that all the nameservers listed in /etc/resolv.conf are interchangeable and all have the same information available through them. So if the resolver gets a "this name does not exist" response from the first configured DNS server, it will not ask the other configured servers for a second opinion. In DNS, "no such name/information exists" is a valid possible response to a query, not an error condition.

If you need a configuration that directs queries for names belonging to particular domains to one set of DNS servers, and other queries to another set of servers, then you should be aware that this is not something a classic resolv.conf-based DNS configuration can do. systemd-resolved can do it using its "routing domains" configuration, or if you want classic resolv.conf, then you need dnsmasq or some other local DNS proxy that can be configured with the appropriate forwarding rules.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .