Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

Install DNSMasq - DNS + DHCP - Home Network 192.168.1.1 - 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 192.168.1.2-127 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 192.168.1.1 and I reserve my DNSMasq server's ip from the DHCP pool range. (Even though its outside, but I think its a good config)

The FUN STUFF!

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 8.8.8.8\nnameserver 8.8.4.4\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" 
##DNS##
##DNS_Config
#Dont use external file for custom dns
no-hosts
#Use this file for DNS nameservers (contains googles DNS)
resolv-file=/etc/resolv.dnsmasq.conf 
##CUSTOM_DNS
# PING home.com = 192.168.1.210
host-record=home.com,192.168.1.210
# WildCard Resolve all xyz.domain.com to 192.168.1.210 + domain.com
# See Unix.StackExchange for Address vs Host-Record
# http://unix.stackexchange.com/questions/295772/dnsmasq-points-nonexistent-subdomains-point-to-local-ip
address=/domain.com/192.168.1.219 
##DHCP##
##DHCP_Config
#Listen only on eth0
interface=eth0
#DHCP Range 192.168.1.2-127 (12hr lease time)
dhcp-range=192.168.1.2,192.168.1.127,12h
#RESERVE DNSMasq SERVER IP
dhcp-host=00:0c:29:c2:56:bf,192.168.1.149
#Change DEFAULT GATEWAY (Default is same IP as DNSMasq Server)
dhcp-option=option:router,192.168.1.1


##STATIC_DHCP
#STATIC IP to 2 MAC Address that WILL NOT be used simultaneously [IE: Laptop with WiFi + LAN]
dhcp-host=00:00:00:00:00:00,00:00:00:00:00:00,192.168.1.210
#Assign STATIC IP by MAC
dhcp-host=00:00:00:00:00:00,192.168.1.211 
  • No labels