Skip to content

Home Lab

Notes from my learning sessions

Menu
Menu

dnsmasq : For my local network

Posted on December 22, 2019 by sandeep

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.

Recent Posts

  • Ceph + KVM: 4. Orchestrating Ceph RBD backed VMs on KVM Hosts
  • Rabbit MQ Cluster + HAProxy + Keepalived
  • Install and configure MariaDB / Galera cluster
  • Ceph + KVM : 3. Installing KVM, cutsomized monitoring scripts
  • Ceph + KVM : 5. Service checks and CLI commands
  • Ceph + KVM : 2. Installation – Ceph Storage
  • Ceph + KVM : 1. Planning and preparing for Ceph Storage
  • Openstack Xena on Ubuntu 20.04 – Cinder
  • Preparing custom Debian 11 MATE image
  • Setup Ubuntu 20.04 repository mirror server

Archives

  • April 2025
  • March 2025
  • October 2024
  • September 2024
  • April 2022
  • March 2022
  • February 2022
  • December 2021
  • October 2021
  • September 2021
  • October 2020
  • February 2020
  • January 2020
  • December 2019
© 2025 Home Lab | Powered by Minimalist Blog WordPress Theme