lets say i have this private hostname dev.private.example.com that is only accessible in a private network over VPN connection and i have prod.example.com that is accessible to the internet. I have DNS servers to resolve the private hostname and then i can use the public DNS servers(google, cloudflare etc) for the public hostnames.

i will like setup dnsmasq(let me know if there is another tool) so that it will query DNS server for the private hostnames and if it is another hostname then it will resolve via the public DNS servers

How do i go about doing this?

  • answer is below..thanks – uberrebu Jan 28 at 19:36
  • we try to shy away from duplicate questions and duplicate answers. – Jacob Evans Jan 29 at 19:04
  • 1
    This is a better question and a better answer than the steaming pile that is linked as being the original Q&A. Even the question title on the other linked question is wrong. – Justin Feb 16 at 21:08
  • thank you @Justin some of the admins on this site got attitudes and i just dont worry myself much..i told them this question is not same but the guy couldn't take no for an answer and still went ahead to mark as duplicate...thanks for cosigning on this – uberrebu Feb 17 at 3:14

this is what worked for me

edit /etc/dnsmasq.conf and have this in the file


and then create a file in the conf directory /etc/dnsmasq.d/private.example.com.conf

and add the following in the content of the file

#dont use hosts nameservers
#use following default nameservers
#serve all *.private.example.com queries using a specific nameserver

where the following are the nameservers and resolving the private hostname

then restart dnsmasq

service restart dnsmasq

now any private hostnames *.private.example.com will use those nameservers to resolve!!!

and boom!!!

Not the answer you're looking for? Browse other questions tagged or ask your own question.