I like playing around with and running services on servers because I think that it’s fun, it’s the reason that this blog runs on its own server at home, that does mean that there are problems with conectivity sometimes and I am forced to fix my own problems, which has lead me to think about moving the blog to a hosted service.

I have been playing around with DNS services for a while and during reading noticed that most people believed that BIND wasn’t up to standard anymore and a more acceptable service to go for would be djbdns, the documentation on the site is great and with other sites like life with djbdns and djbdns rocks and there wasn’t with the help of the above three sites I was able to setup a suitable caching name server for my home network. The only problem that I had was because of the way dnscache and tinydns is setup it cannot run on the same network IP so as a result tinydns will normally run on 127.0.0.1 and dnscache will run on the private or public IP. This worked great for me, except for one reason or another I wasn’t able to get dns lookups for my local machine to work.

After some searching I decided that it would be best to head towards dnsmasq

As good as djbdns is for what it does it was probably a bit of overkill for the kind of network that I was running considering that it was a home network with about 5 computers connecting to the Internet at any one time.
dnsmasq was probably more suitable to what I wanted to do, but then again it probably won’t be useful in the corporate environment because I’m not sure how it would scale and it doesn’t (i think) have services that are able to publish DNS recoards to the Internet.

Because I run a Debian system the install was dead simple:

$ apt-get install dnsmasq

and from that you can control the service with these commands:

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

But before we do that I will need to configure it to suit my needs.

Go ahead and edit the hosts file as root:

$ nano -w /etc/hosts

$ /etc/init.d/dnsmasq restart

192.168.1.21 vacantmind.net
192.168.1.22 proxy.vacantmind.net proxy animal
192.168.1.11 wombat.vacantmind.net wombat

Once this has been done you have to enter the IP address of the DNS server to the clients on the network, for windows machines this can be done with editing the IP config.
CMD IPconfig

GUI IPconfig

In GNU/Linux machines this can be done with editing /etc/resolv.conf

But since dnsmasq is also able to act as a DHCP server we will also get it to do that as well.

Edit the file /etc/dnsmasq.conf

The simplees way to do this is to uncomment the line

dhcp-range=192.168.1.100,192.168.1.150,60h

The first two parts is the IP range and the last bit is the time of the lease

Also make sure that the following lines are uncommented

dhcp-leasefile=/var/lib/misc/dnsmasq.leases

# For debugging purposes, log each DNS query as it passes through
# dnsmasq.
log-queries

That way in the terminal type the following command

$ tail -f /var/log/syslog

and you should see the following: ( i went to http://www.quotationspage.com/qotd.html )


Jul 3 23:38:15 localhost dnsmasq[1712]: query[A] www.quotationspage.com from 192.168.1.10
Jul 3 23:38:15 localhost dnsmasq[1712]: forwarded www.quotationspage.com to 203.12.160.35
Jul 3 23:38:15 localhost dnsmasq[1712]: reply www.quotationspage.com is
Jul 3 23:38:15 localhost dnsmasq[1712]: reply quotationspage.com is 67.15.52.101
Jul 3 23:38:16 localhost dnsmasq[1712]: query[A] www.quotationspage.net from 192.168.1.10
Jul 3 23:38:16 localhost dnsmasq[1712]: forwarded www.quotationspage.net to 203.12.160.35
Jul 3 23:38:16 localhost dnsmasq[1712]: reply www.quotationspage.net is 66.98.180.223
Jul 3 23:38:16 localhost dnsmasq[1712]: query[A] as.casalemedia.com from 192.168.1.10
Jul 3 23:38:16 localhost dnsmasq[1712]: forwarded as.casalemedia.com to 203.12.160.35
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casalemedia.com is
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.209.194
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.34.162
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.117.114
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.117.146
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.117.178
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.117.194
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.209.18
Jul 3 23:38:17 localhost dnsmasq[1712]: reply as.casale.com.akadns.net is 70.86.209.98
Jul 3 23:38:17 localhost dnsmasq[1712]: query[A] a.tribalfusion.com from 192.168.1.10
Jul 3 23:38:17 localhost dnsmasq[1712]: forwarded a.tribalfusion.com to 203.12.160.35
Jul 3 23:38:17 localhost dnsmasq[1712]: reply a.tribalfusion.com is 204.11.109.64
Jul 3 23:38:17 localhost dnsmasq[1712]: reply a.tribalfusion.com is 204.11.109.61
Jul 3 23:38:17 localhost dnsmasq[1712]: reply a.tribalfusion.com is 204.11.109.62
Jul 3 23:38:17 localhost dnsmasq[1712]: reply a.tribalfusion.com is 204.11.109.63
Jul 3 23:38:18 localhost dnsmasq[1712]: query[A] cdn5.tribalfusion.com from 192.168.1.10
Jul 3 23:38:18 localhost dnsmasq[1712]: forwarded cdn5.tribalfusion.com to 203.12.160.35
Jul 3 23:38:18 localhost dnsmasq[1712]: reply cdn5.tribalfusion.com is
Jul 3 23:38:18 localhost dnsmasq[1712]: reply cdn1.tribalfusion.com.edgesuite.net is
Jul 3 23:38:18 localhost dnsmasq[1712]: reply a889.g.akamai.net is 59.167.192.16
Jul 3 23:38:18 localhost dnsmasq[1712]: reply a889.g.akamai.net is 59.167.192.9
Jul 3 23:38:18 localhost dnsmasq[1712]: query[A] pagead2.googlesyndication.com from 192.168.1.10
Jul 3 23:38:18 localhost dnsmasq[1712]: forwarded pagead2.googlesyndication.com to 203.12.160.35
Jul 3 23:38:18 localhost dnsmasq[1712]: reply pagead2.googlesyndication.com is
Jul 3 23:38:18 localhost dnsmasq[1712]: reply pagead2.google.com is
Jul 3 23:38:18 localhost dnsmasq[1712]: reply pagead.l.google.com is 72.14.203.99
Jul 3 23:38:18 localhost dnsmasq[1712]: reply pagead.l.google.com is 72.14.203.104
Jul 3 23:38:19 localhost dnsmasq[1712]: query[A] client.pluck.com from 192.168.1.10
Jul 3 23:38:19 localhost dnsmasq[1712]: forwarded client.pluck.com to 203.12.160.35
Jul 3 23:38:19 localhost dnsmasq[1712]: reply client.pluck.com is 66.179.81.247
Jul 3 23:38:20 localhost dnsmasq[1712]: query[A] b.casalemedia.com from 192.168.1.10
Jul 3 23:38:20 localhost dnsmasq[1712]: forwarded b.casalemedia.com to 203.12.160.35
Jul 3 23:38:20 localhost dnsmasq[1712]: reply b.casalemedia.com is
Jul 3 23:38:20 localhost dnsmasq[1712]: reply b.casalemedia.com.edgesuite.net is
Jul 3 23:38:20 localhost dnsmasq[1712]: reply a1083.g.akamai.net is 59.167.192.16
Jul 3 23:38:20 localhost dnsmasq[1712]: reply a1083.g.akamai.net is 59.167.192.9

And that should be it.

My dhcp server with dnsmasq won’t be fully implemented once I have the IP forwarding and routing properly configured on this box and I will cover that in another post.

Share →

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>