How to resolve dns in multiple name servers

dnsmasqdomain-name-systeminternal-dnslinux-networkingnetworking

resolv.conf

domain example.com

nameserver 192.168.122.54

nameserver 192.168.124.44

Take this as the sample resolv.conf. The scenario is that the DNS tries to resolve in the first name server as mentioned, if it is not able to resolve it should try to resolve using the second name server but it is not happening this way but an exception Unknown host is thrown during HTTPS call in Java code.

Could someone advice on how to resolve this?

Best Answer

"if its not able to resolve it should try to resolve using the second name server "

Yeah, except that is not how DNS works.

If server 1 says "can not resolve" THAT IS IT. They are supposed to be redundant, so an answer is an answer.

It will only ask nameserver 2, if nameserver 1 does not respond (i.e. is down).