DNS and DHCP on the RPi

Having upgraded the weather station, I didn't need the Raspberry Pi to look after that, but one of the things I'd been meaning to do for a while was use a different DNS server than the (not as robust as I'd like) one my ISP provides. The bad news is that the router+modem I have doesn't let me set that up, so I'd need to set up my own DHCP server too. Enter the Raspberry Pi! I actually had the old SD card barf again, so I recently did the setup from scratch in a few hours.

First off, I installed 2015-05-05 Wheezy because I already had it around, and logged on and did the network setup. I had it working on the network at this point by just giving it the password to my Wi-Fi in /etc/network/interfaces - I also set it up with a static IP of 192.168.0.55.

Next I updated everything: sudo apt-get update

and installed dnsmasq: sudo apt-get install dnsmasq

I stopped it: service dnsmasq stop

and edited the /etc/dnsmasq.conf file:

server=8.8.8.8

server=8.8.4.4

(These are Google's servers, and they're pretty fast, but very robust).

address=/ted/192.168.0.51

address=/printer/192.168.0.54

address=/pi/192.168.0.55

(Addresses to return for these names)

dhcp-range=192.168.0.100,192.168.0.120,12h

(Where my DHCP clients will show up, and the TTL)

dhcp-host=00:25:2f:21:1f:ea,ted,192.168.0.51

dhcp-host=00:00:85:e8:57:74,printer,192.168.0.54

dhcp-host=80:1f:02:68:79:56,pi,192.168.0.55

(Static IPs on my network)

dhcp-option=3,192.168.0.1

(Gateway - the default is this machine)

Restarted the Pi, and fixed typos etc until my PC started getting a 192.168.0.1xx address.

Now, the important thing is that this is a caching DNS server, so things get faster, quickly :o)

eg:

dig @75.75.75.75 womeninwaders.com|grep "Query time"

(This is my ISP's default DNS server)

;; Query time: 232 msec

dig womeninwaders.com|grep "Query time"

(Using my DNS server, which has to go out to the Google's server)

;; Query time: 185 msec

dig womeninwaders.com|grep "Query time"

(Using my DNS server, which now pulls that domain from the cache)

;; Query time: 2 msec

Magic, I tells you :o)