Advertisment

How to: Deploy a Local Split DNS

author-image
Dhaval Gupta
New Update

While running a Cloud infrastructure locally and hosting a bunch of servers on the cloud, we realized that we needed a mechanism to access the services/servers locally over the LAN and publicly over the Internet. But for the sake of convenience, we needed something that could let us use the same DNS name for the services, but resolve it to a local IP when accessed from within the LAN and if accessed from remotely, it should resolve to the public IP.
The trick is in hosting a local SPLIT DNS server and letting the DHCP server broadcast this DNS as the primary DNS in the network. And this SPLIT DNS will make sure that whenever you access a local resource using the global FQDN, it resolves to its local IP instead of the public IP.
To deploy this, we created a VM in our Cloud and installed Ubuntu (you can install whatever Linux flavor you're comfortable using). Now, Login to the VM and escalate yourself as root
$sudo su -

Advertisment

Next, install dnsmasq like this
# aptitude install dnsmasq

Once done open /etc./dnsmasq.conf like this
# nano /etc./dnsmasq.conf

And add the following lines to the end of the file
server=8.8.8.8
server=4.4.4.4
domain=l
listen-address=

Advertisment

Now save the file and open hosts file
#nano /etc./hosts

And add

Now start dnsmasq and set it for starting at every reboot like this
# /etc./init.d/dnsmasq start
#chkconfig dnsmasq on

Advertisment

Once this is done, make sure your LAN DHCP lease setting has the IP address of this VM as its primary DNS IP. For the secondary IP, you can use any public DNS server.
And you are done!

Advertisment

Stay connected with us through our social media channels for the latest updates and news!

Follow us: