Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Install DNSMasq - DNS + DHCP - Home Network - Google DNS - All configs in same file.

I spent a whole night figuring out BIND9 (DNS) and ISC-DHCP-SERVER plus WebMin before I settled on DNSMasq, its just perfect and easy for a home network.

My absolute favorite part of DNSMasq is that I can configure static IPs and custom DNS in the same file.

In this example I will set up the DHCP network range to so that I can restrict my local SMB shares via IP Ranges. While I have the configs set up in this to group DNS and DHCP together what I really use is the first two configs are the global DNS and DHCP then I have Static IPs and Custom DNS @ the bottom for easy entry.

I will also assign my laptops Ethernet and WiFI the same static IP under the assumption both will not be used simultaneously.

My DNS will forward all requests to Googles DNS but of course resolve my configured DNS entries first.

Also my DNSMasq server is not my gateway router, so I forward that on to and I reserve my DNSMasq server's ip from the DHCP pool range. (Even though its outside, but I think its a good config)


Prep Server :


sudo nano /etc/hostname && sudo nano /etc/hosts && sudo nano /etc/network/interfaces && sudo reboot



Install DNSMasq and Configure :

sudo apt-get update
echo y | sudo apt-get install dnsmasq
sudo sh -c 'echo "nameserver\nnameserver\n" >> /etc/resolv.dnsmasq.conf'
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
sudo nano /etc/dnsmasq.conf && sudo ufw allow bootps && sudo ufw allow out 53 && sudo ufw allow 53 && sudo service dnsmasq restart

Custom Alias for Bash :

alias DNSMasq="sudo nano /etc/dnsmasq.conf && sudo service dnsmasq restart" 
#Dont use external file for custom dns
#Use this file for DNS nameservers (contains googles DNS)
# PING =,
# WildCard Resolve all to +
# See Unix.StackExchange for Address vs Host-Record
#Listen only on eth0
#DHCP Range (12hr lease time)
#Change DEFAULT GATEWAY (Default is same IP as DNSMasq Server)

#STATIC IP to 2 MAC Address that WILL NOT be used simultaneously [IE: Laptop with WiFi + LAN]
#Assign STATIC IP by MAC
  • No labels