How to use multiple dns servers on debian?

i have a debian machine.
i am trying to use the dns servers 10.13.16.1 and 10.13.74.1 as primary and secondary dns respectivley. but i cannot figure out how to do this.

my expected behavior when resolving any domain:
lookup with 10.13.16.1, and if it cannot resolve, use the dns server on 10.13.74.1 to resolver.

what actually happens:
it tries to resolve on 10.13.16.1, fails, and the connection cant be made and the program exits with failure to resolve or host unreachable.

here is the entry in /etc/network/interfaces

iface vmbr0 inet static
bridge-ports none
bridge-stp on
bridge-fd 0
bridge-vlan-aware yes
bridge-vids 2-4094
bridge_maxwait 0
address 10.13.16.174
netmask 255.255.255.0
gateway 10.13.16.1
dns-nameservers 10.13.16.1 10.13.74.1

Hi,
Debian has gone through multiple flavors over handling DNS/networking in the course of recent releases, I guess you are having Debian 12 bookworm, but best to confirm, just in case.

For the issue you are describing, I can imagine the first DNS server 10.13.16.1
did send a NX record back, which you describe as “cannot resolve”. Problem with NX records are, that it means there is actually a response, and this is what the system is taking (and caching!).

If the failure mode is of the nature of “the Debian host not being able to reach the first DNS service”, can you post results of dig or nslookup, or a tcpdump?
(you can retract or best rewrite the entries you see as sensitive)

2 Likes

Your desired behavior doesn’t really exist in DNS, your debian works as designed.

When configuring multiple DNS servers the client (your computer) will only use the second in case the first cannot connect to the DNS service.

What are you trying to accomplish?

i got my desired behavior by redoing this whole setup do just use dhcp.

2 Likes

I’ve run into the same weird behavior on Debian before, and honestly switching to DHCP for DNS made things smoother for me too. I still like keeping a dns list on hand for testing or quick overrides, and it’s been handy to compare how different resolvers behave without fighting local config quirks. Once DHCP hands out the servers you want, Debian tends to stay out of the way.

1 Like

It used to be in the olden days that the resolver looked in resolv.conf and if the first listed name server could not resolve a name it tried with the next one.

I’ve been in organizations where we put the internal hostnames in one bind server and relied on the resolver to try the public servers first and if those didn’t resolve a name like “my-server.internal” the client went on to try the internal DNS server.

Then came systemd and name resolving was never the same again.

1 Like

i see. so this is all redhat’s fault!

aifbf5

2 Likes