Dnsmasq

Install Dnsmasq for serving your home LAN dhcp clients and caching DNS queries.

Install Dnsmasq:

Dnsmasq config files are stored in /etc/dnsmasq.d. To get started, create a new config file there. Call it home.conf. This config file will have the basics for dns and dhcp for our home network.

Adding domain-needed blocks incomplete requests from leaving your network, such as google instead of google.com. bogus-priv prevents non-routable private addresses from being forwarded out of your network. Using these is simply good netizenship.

Set your private domain name with domain=mydomain.net, replacing mydomain with any domain name your heart desires. You don’t need to register it with a domain name registrar because it’s private and never leaves your LAN.

The expand-hosts directive adds the domain name to your hostnames, so you get fully-qualified domain names like hostname.mydomain.net. Again, these are completely arbitrary and can be whatever you want.

local=/mydomain.net/ ensures that queries for your private domain are only answered by Dnsmasq, from /etc/hosts or DHCP.

The listen-address directive tells Dnsmasq which interface or interfaces to listen on. Always use listen-address because you don’t want Dnsmasq exposed to the wrong networks, and especially not the Internet. Always include the loopback address. You could use the interface= directive instead, for example interface=eth0, but the Linux kernel doesn’t always bring up network interfaces with the same names after reboot. If you have more than one NIC the names could get changed, and then your name services will be messed up.

The bind-interfaces directive ensures that Dnsmasq will listen only to the addresses specificied with listen-address.

DNS Caching
The dns-forward-max=5000 directive tells Dnsmasq to cache up to 5000 dns entries. You defiantly want to set this because the default is 150. Also the dns-forward-max=5000 is the max number of concurrent DNS queries. Again, you want to crank that up.

Static IP Addresses
Dnsmasq reads your server’s /etc/hosts file for local DNS records. Always include the localhost in the first line:

Once you are happy with your configuration, run:

Dnsmasq logs to the /var/log/syslog so you can see the dhcp clients talking with:

Did you find this information helpful? If you did, consider donating.

One thought on “Dnsmasq

Leave a Reply

Your email address will not be published. Required fields are marked *