So now that I have my web servers all setup and working I need a way to be able to define URI’s internally (such as FTP, SSH etc) I also wanted to be able to access these sites internally and my modem will not allow hairpin routing so I needed something to direct me to the correct location inside the network. So I needed to setup a DNS server with the correct entries.

First things first is install BIND.

sudo apt-get install bind9

Now that BIND9 is installed the first thing to do is to setup the forwarders. These are the addresses that  we will send any requests that are not defined. i.e. if you dont host it will forward that request onto these servers to get the correct IP. So we edit

vi /etc/bind/named.conf.options

And add or modify the following

forwarders {;;

After the forwarders are setup, we are going to create a folder for the Zone records. A zone is domain that the server will look after. (For example all of the entries related to that domain are grouped together in a zone file.

sudo mkdir /etc/bind/zones

Now we setup the Zone file for the domain in my case I am setting up so I will create a zone file called

sudo vi /etc/bind/zones/

Inside that file I will add the following.

; BIND data file for
$TTL    604800
@       IN      SOA root.localhost. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
@       IN      NS
@       IN      A
@       IN      AAAA    fe80::20c:29ff:fe50:a7a6    IN      NS    IN      A
accounts        IN      A
www     IN      CNAME
dea     IN      CNAME
ns1     IN      A

To get started you can copy the existing local zone file and then modify it do this run

sudo cp /etc/bind.db.local /etc/bind/zones/

The SOA part is quite a thing to wrap your head around. For more information about what is in the file check out After the SOA there is just a single line for each record or sub domain. (In the example above you can see the records for the domain @, accounts, www, dea and ns1)

Now that you have a zone file ready for the domain you need to add it into the named.conf.local

sudo vi /etc/bind/named.conf.local

Once you are into the file add the following to the file

zone "" in{
 type master;
 file "/etc/bind/zones/";

After that is done you can restart bind

sudo service bind9 restart

and then point a DNS client to the server and try to resolve the addresses.

dean@remote:~$ dig

; <<>> DiG 9.8.1-P1 <<>>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8185
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;                  IN      A

;; ANSWER SECTION:           604800  IN      A

;; AUTHORITY SECTION:           604800  IN      NS

;; ADDITIONAL SECTION:       604800  IN      A

;; Query time: 1 msec
;; WHEN: Sat May  3 08:21:46 2014
;; MSG SIZE  rcvd: 80

Now you can add the other domains you want to add by repeating the process and pointing other URI’s to different locations around your network.