In a DNS bind? Get Out With dnsmasq

If the intricacies of bind are too much to navigate and all you really need is lightweight DNS services for your LAN, dnsmasq might fit the bill: Configure it with /etc/hosts, use it for easy DHCP services, and put the kibosh on the likes of Sitefinder's DNS-breaking marketing scheme.

By Carla Schroder | Posted Jul 6, 2004
Page 1 of 2
Print ArticleEmail Article
  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

There you are on your small home LAN, or small business, feeling ignored by the Linux world. You want to take advantage of nice labor-saving tools like DHCP (dynamic host configuration protocol) and DNS (domain name system), but it feels like only uber-geeks need apply.

Feel ignored no more, for there is an excellent DNS/DHCP utility for real people: Dnsmasq. Dnsmasq is especially suited for small networks that share a single Internet connection, behind a NAT firewall. Creative admins will find all sorts of ways to put Dnsmasq to work; this article will focus on simple local DNS and DHCP.

What's the Big Deal, Anyway

DNS is simply matching names to numbers. DHCP is simply automatically assigning an IP address, and optionally other information, from a pool of addresses. Dnsmasq leans the entire process down to a few essential bits. You probably wouldn't want to use it to power an ISP, but then this article isn't aimed at gigantic mondo users with complex needs anyway: Think branch office.

Starting and Stopping Dnsmasq

The Dnsmasq .debs and .rpms come with init scripts. Start, restart, and stop in the usual manner:

# /etc/init.d/dnsmasq start
# /etc/init.d/dnsmasq restart
# /etc/init.d/dnsmasq stop

Local Caching Nameserver

Setting up a local caching nameserver is a common chore. By caching DNS requests locally, your users will see faster network response times. Any PC on your LAN can be the local nameserver cache. Install Dnsmasq on this PC.

In small LANs that share a single Internet connection, typically all the hosts use the ISP's (internet service provider) nameservers. This is configured in /etc/resolv.conf:

nameserver 12.345.678.8
nameserver 12.345.678.9

Leave this configuration on your local nameserver. On all the other PCs in your LAN, make this the only entry in /etc/resolv.conf:

nameserver 192.168.1.10

Windows PCs are configured in "Network and Dial-up Connections." Any time your primary nameservers change, the only change you need to make is on your local nameserver. Yes, that's easy, like it should be.

Easy Local DNS Server

Maintaining /etc/hosts files on more than three or four PCs gets to be a pain. Running BIND is a far bigger pain. djbdns is a lovely DNS server, and is my personal favorite. But nothing beats Dnsmasq for simple administration and setup. With Dnsmasq, you only need to maintain the /etc/hosts file on the Dnsmasq server:

127.0.0.1                localhost
192.168.1.5            mail1
192.168.1.100        workstation1
192.168.1.101        workstation2
192.168.1.102        workstation3
192.168.1.103        workstation4

What, you say, why no domain names? Everyone knows that domain names have to go in /etc/hosts. Stay tuned, my little Grasshoppers, and all will be revealed.

Comment and Contribute
(Maximum characters: 1200). You have
characters left.
Get the Latest Scoop with Enterprise Networking Planet Newsletter