Creating you own internal DNS server

Recently we have been having problems with DNS not resolving with our companies broadband provider. I looked at some open source DNS services, the best one being OpenDNS, but despite them having a couple of boxes in Amsterdam the lookups are still somewhat slow.

So the solution? Create our own DNS server :-)

This is how to set up your DNS quickly and using Unbound on Ubuntu.

Firstly install unbound:

sudo apt-get update
sudo apt-get install unbound

Now configure unbound, the config file if installing from the apt package manager is located at

/etc/unbound/unbound.conf

Please note this is not secure, this is just default open to all inbound connections so if you are hosting a DNS beyond your firewall you will want to redefine the config to only accept incoming connections from your domain.

server:
  # verbosity number, 0 is least verbose. 1 is default.
  verbosity: 1

  # specify the interfaces to answer queries from by ip-address.
  # The default is to listen to localhost (127.0.0.1 and ::1).
  # specify 0.0.0.0 and ::0 to bind to all available interfaces.
  # specify every interface on a new 'interface:' labelled line.
  # The listen interfaces are not changed on reload, only on restart.
  interface: 0.0.0.0

  # port to answer queries from
  port: 53

  # Enable IPv4, "yes" or "no".
  do-ip4: yes
  # Enable IPv6, "yes" or "no".
  do-ip6: yes
  # Enable UDP, "yes" or "no".
  do-udp: yes
  # Enable TCP, "yes" or "no".
  do-tcp: yes

  # Detach from the terminal, run in background, "yes" or "no".
  do-daemonize: yes
  # control which clients are allowed to make (recursive) queries
  # to this server. Specify classless netblocks with /size and action.
  # By default everything is refused, except for localhost.
  # Choose deny (drop message), refuse (polite error reply),
  access-control: 0.0.0.0/0 allow

Now start the server:

sudo /etc/init.d/unbound restart

Client side configuration:
To configure this for a client (browser) you need to set your DNS in your wireless or wired settings to the IP address of your DNS host machine. Here’s an example using Mac OSX.

Client side configuration of DNS

And that’s it! Your local personal DNS server is ready to cache!

No Comments

RSS feed for comments on this post. TrackBack URL

No comments yet.

Leave a comment

Preview: