Need was to have a DNS service serving my local network name resolutions. After surfing on multiple how tos, found dnsmasq would suffice my needs.
Install dnsmasq
#apt install -y dnsmasq
Edit the configuration file and updated the following entries (uncomment if commented)
# Never forward plain names (without a dot or domain part) domain-needed # Never forward addresses in the non-routed address spaces. bogus-priv # Add local-only domains here, queries in these domains are answered # from /etc/hosts or DHCP only. local=/localnet/ # Add domains which you want to force to an IP address here. # The example below send any host in sandeeprao.net to a local # web-server 10.1.1.4 address=/sandeeprao.net/10.1.1.4 # Need to listen for dns requests from multiple networks associated # with multiple interfaces - so added the following listen-address=127.0.0.1 listen-address=10.1.1.3 listen-address=10.1.2.3 listen-address=10.1.3.3
The contents of /etc/resolv.conf in this system is as follows, Only local network dns queries are answered from /etc/hosts remaining get forwarded to the dns servers configured in the system.
nameserver 10.1.1.1 nameserver 8.8.4.4
Now update your /etc/hosts with your local network dns requirements, some sample entries
10.1.1.2 dcserver dcserver.xxx.net 10.1.1.3 dcdns dcdns.xxx.net 10.1.1.4 blog sandeeprao.net 10.1.2.5 db1 db1.xxx.net 10.1.2.6 db2 db2.xxx.net 10.1.2.7 db3 db3.xxx.net 10.1.2.10 haproxy1 haproxy.xxx.net 10.1.2.11 haproxy2 haproxy.xxx.net 10.1.2.12 dbvip dbvip.xxx.net
Restart dnsmasq service
service dnsmasq restart
Configure 10.1.1.3 (ip where dnsmasq was configured) as name server in your client systems and you will find dns resolutions work for local network and also get resolved for external networks.