Tonight I added dnsmasq to my Fedora 12 server, and had to do some looking to figure out how to get other client computers on my internal LAN to see the new dns.

There is an EXCELLENT setup tutorial here that gave me *almost* all I needed to get things working. I did not use the DHCP feature of dnsmasq, so I ignored all those parts. Getting things working was really a breeze, really just a matter of running yum install dnsmasq, editing /etc/dnsmasq.conf and /etc/resolv.conf per the recommendations of the reference above. Here are my versions of those files:

/etc/dnsmasq.conf All of these are optional, and well documented in the link above, but for the record they are the only things I changed:

# Configuration file for dnsmasq.
domain-needed
bogus-priv
strict-order
interface=eth0

/etc/resolv.conf Taken largely from the link above, but modified for my ISP:

#Allow applications on the machine hosting dnsmasq to also use it too
nameserver 127.0.0.1

#Google DNS
nameserver 8.8.8.8

#OpenDNS
nameserver 208.67.222.222
nameserver 208.67.220.220

#Time Warner Cable Business Class
nameserver 24.25.5.60
nameserver 24.25.5.61
nameserver dns4.rr.com

As is, dnsmasq works great on the server itself, and domain name lookups were substantially faster after they got cached locally (generally from 100ms down to 1ms or less). There were now 2 problems.

Problem 1: Everytime the network interface resets, Network Manager changes /etc/resolv.conf back to whatever the router tells it to be. To prevent this, you have to add a line (PEERDNS=no) to the ifcfg file for the nework interface. In this case, my server is wired to the router and configured by eth0 in /etc/sysconfig/network-scripts/ifcfg-eth0. This is a static local ip address (192.168.0.10), and my gateway (router) is 192.168.0.1, so the relevant parts of this file:

DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.0.10
GATEWAY=192.168.0.1
PEERDNS=no
NAME=”eth0″

The important line here is PEERDNS=no. Problem 1 solved.

Problem 2: The bigger problem was how to get my clients to use this. I have a mix of windows clients, legacy equipment, and linux workstations already configured to connect to my network. I actually have 2 wireless routers, one over 802.11n (I’ll call that one Router 1) and another over 802.11b (Router 2) for my legacy equipment. The problem is that how do my routers tell the clients to use my dnsmasq server?

The answer is that it depends on the router and it depends on the client as to how exactly to do this. In my case, Router 1 is a D-Link DIR-655. The setting for this router I needed to change was to uncheck the “Enable DNS Relay” under the “Setup” –> “Network Settings” –> “Router Settings”. Leaving this enabled makes DNS a pass-through to my ISP’s DNS, the very thing I was trying to avoid. I also set my Primary DNS Server setting to the IP of my dnsmasq server (192.168.0.10). As a backup, I set my Secondary DNS Server to point to OpenDNS (208.67.222.222).

For Router 2, a Linksys WRT54GS, there is no similar setting, but instead I changed the Primary DNS to the IP address of Router 1 (192.168.0.1).

I need to experiment a little more on the client side, but on my wife’s Windows laptop it looks like I have to tell Windows to use a specific DNS server, which I manually configured to point to my dnsmasq server (192.168.0.10). My fedora laptop had no problems gathering that information from the router during the DHCP process.

Hopefully this helps someone!