Dnsmasq DNS server priority

I need to get both dynamically provided DNS servers and fixed servers as fallback if provider's DNS servers are not available. I see that dnsmasq uses /tmp/resolv.conf.d/resolv.cond.auto file containing dynamic servers. If I put fixed servers into the interface config file, e.g.

        list dns '8.8.8.8'
        list dns '8.8.4.4'

they appear in the resolv.conf.auto file before the dynamic ones. I suspect that dynamically provided servers are those closest and thus fastest to respond, thus would be wise to use them in priority, but, if I get it right, with google servers at the top of the list they will be used in first place.

Is there any way to have fallback fixed IP-address servers having lower priority than dynamically provided?

Thanks!

dnsmasq sends requests to multiple servers at once. Unless majority of servers are slow it works well.

interface config is wrong place, it is in dnsmasq forwarders

eg use provider's servers for resolving their addresses:
/cloudflare.com/1.1.1.1
/cloudflare.com/1.0.0.1

1 Like

Excellent, thank you so much! I see in the output of logread that dnsmasq uses the servers I have put into the /etc/dnsmasq.conf. These servers do not appear in the .auto file though.

And next, if it sends request to all the servers on the list, it will inflate the traffic - does not sound good... Is there any optimization in the querying the servers?

By default, dnsmasq “tests” all the configured servers every 50 queries or 20 seconds (whichever comes first). So unless the all-servers parameter is enabled, not every query goes to all servers.

https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=blob;f=src/config.h;hb=d7d682637d1a85947891d10b5b16b99db852aa38#l31

2 Likes

There's also a strict order option in the advanced settings of the DHCP and DNS menu.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.