Page 1 of 1

How does RouterOS prioritize domain name servers?

Posted: Mon Mar 25, 2024 6:26 pm
by Zilch
Hi, all

So, say I have specified two domain name servers in my MikroTik - 8.8.8.8 first and 8.8.4.4 secondly, how would RouterOS decide which to use first?

For my application, I need RouterOS to always use the first specified server, unless it is unreachable.

If I specify those two domain name servers in my DHCP, and I have a Windows client, it will sometimes use the one, and sometimes the other. It seems to be random?

I will be running a custom domain name server, and I need RouterOS to always send queries to it, again, unless it is unreachable.

Thanks in advance.
Untitled.png

Re: How does RouterOS prioritize domain name servers?

Posted: Mon Mar 25, 2024 7:43 pm
by mkx
Your wish goes against established operation and good practice.

All configured DNS servers are supposed to return same results to any query. Hence when multiple servers are configured, then DNS client (resolver) is free to use any of them with no particular affinity. Most use one server for all queries until it fails to respond [*] after which another server is used for all subsequent queries until that one fails. Etc.

[*] Failing to respond is exactly this: server doesn't answer to query. Negative answer doesn't count as failure to respond ans thus not a reason for client to query another server.

So: if one needs two DNS servers which can return answers to queries which are not globally available (e.g. LAN hosts), then one has to host two (or more) separate DNS servers on LAN (one being master for LAN zones, the rest being slaves but still authoritative) and configure the rest of LAN to use those servers.

Re: How does RouterOS prioritize domain name servers?

Posted: Mon Mar 25, 2024 8:08 pm
by Amm0
@mkx is correct. If you give a client two DNS servers via DHCP it can use either.

Now... if you client use FQDN (e.g. hostname.example.com) for stuff, and you have a custom domain with it's own DNS. You can use the Mikrotik "FWD" record in /ip/dns/static to match on a domain name & that will send queries to that server for the specified domain. But if clients are using "bare" hostname, that method won't work. And of course, the client device has use only one DNS to the Mikrotik for the "FWD" method to work. If you use Mikrotik + Google to client via DHCP, you arrive at @mkx point of how DNS resolvers works.

Re: How does RouterOS prioritize domain name servers?

Posted: Tue Mar 26, 2024 6:53 pm
by Zilch
Ah, thanks for this. I'm relatively new to all this networking stuff.