Setup local domains for intranet


Recently there was a requirement to configure local domains like simpsoft.local, jenkins.simpsoft.local etc.. for the development team. While this could be achieved simply by declaring IP-domain mapping at host machine (/etc/hosts), is not a good solution for a large web development team. dnsmasq is a little gem in Linux perfectly fits in this situation.

dnsmasq a local DNS server with forwarding to upstream DNS 

dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. dnsmasq is DHCP + local DNS with forwarding of all query types to upstream DNS + DNS caching + TFTP server. Being easy to configure it also has reputation for its light weight foot print. As a DHCP is already running in my envioronment, I only need its DNS capabilities. On a debian box install the server as root

apt-get install dnsmasq

Server’s static I.P. is       

Configure IP-domain mapping and DNS forwarding to upstream DNS

Given, simpsoft.local, jenkins.simpsoft.local should point to server having static I.P. ; dbadmin.simpsoft.local, gitweb.simpsoft.local should point to and salescommission.simpsoft.local, insurancecompany.simpsoft.local must point

Hence as root we need to edit /etc/dnsmasq.conf with following


We need to use dnsmasq as primary nameserver to get the local domains. That’s why we also need to instruct dnsmasq to pass queries can’t be resolved locally to upstram DNS.
Given google DNS as upstream for this setup, we need to add following at /etc/dnsmasq.conf

#DNS forwarding to upstream google DNS

Let’s activate our local DNS

service dnsmasq start

What to do at host/client system ?

Nothing if DHCP server uses dnsmasq as primary DNS. Otherwise Linux boxes should place the I.P. of dnsmasq as only / very first nameserver at  /etc/resolv.conf

#IP of dnsmasq server as only/first nameserver

Window boxes also need the same, i.e. I.P. of dnsmasq must be the first DNS

Check the setup

Let’s use nslookup and dig to see how our local DNS resolving local domain and DNS forwarding. We have to execute these tests from a Linux box which is configured to use dnsmasq server as primary DNS

Local domain


DNS forwarding



One response »

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s