4

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?

uberrebu
  • 503
  • 6
  • 17
  • 36
  • answer is below..thanks – uberrebu Jan 28 '21 at 19:36
  • we try to shy away from duplicate questions and duplicate answers. – Jacob Evans Jan 29 '21 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 '21 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 '21 at 03:14

1 Answers1

4

this is what worked for me

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

conf-dir=/etc/dnsmasq.d/,*.conf

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
no-resolv
#use following default nameservers
server=1.1.1.1
server=8.8.8.8
strict-order
#serve all *.private.example.com queries using a specific nameserver
server=/private.example.com/140.82.113.1
server=/private.example.com/140.82.113.2

where the following are the nameservers 140.82.113.1 and 140.82.113.2 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!!!

uberrebu
  • 503
  • 6
  • 17
  • 36