Setting up bind DNS server for local domain and forwarder

This post will cover the setup of a bind server within the local network. It will resolve my.homezone locally on the bind server and forward all other requests to the google dns servers.

network = 192.168.1.0/24
bind server ip = 192.168.1.4
webserver ip = 192.168.1.5
local domain : my.homezone

Bind Installation

$ sudo apt-get update [ENTER]
$ sudo apt-get install bind9 bind9utils bind9-doc [ENTER]

named.conf.options

$ sudo vi /etc/bind/named.conf.options [ENTER]

Now we will define the clients allowed to query the bind server, to do so add the following (1st line).

acl trusted{
localhost;
192.168.1.0/24;
}

Now we have to define the forwarders within the options configuration.

forwarders{
192.168.1.4;
8.8.8.8;
8.8.4.4;
}
recursion yes;
allow-query {trusted;};
allow-recursion {trusted;};
listen-on {192.168.1.4;};
allow-transfer {none;};

save the file
now we check the config

$ named-checkconf [ENTER]

In case there’s no errors we can proceed.

Our zonefile¬† “my.homezone”

$ sudo vi /etc/bind/named.conf.local [ENTER]

add the zone as followed

zone "my.homezone" {

type "master";
file "/etc/bind/zones/my.homezone";

}

Now we have to create the zonefile :

$ cd /etc/bind/zones [ENTER]
$ sudo cp ../db.local ./my.homezone [ENTER]
$ sudo vi my.homezone [ENTER]

Your file shall look similiar to this one :

@   IN      SOA     ns1.my.homezone. hostmaster.my.homezone. (
                              5         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;

; Name servers
my.homezone.    IN      NS      ns1.my.homezone.
ns1.my.homezone.             IN      A       192.168.1.4

; Other A records
; Web Server
www.my.homezone.             IN      A      192.168.1.5

Does the webserver resolve

$ host www.my.homezone [ENTER]

should return

www.my.homezone has adress 192.168.1.5

resolv.conf

Finally we have to make sure it also works on reboot. Ubuntu tends to overwrite /etc/resolv.conf. We need to install resolvconf to prevent the system from overwriting the configuration on boot.

$ sudo apt-get install resolvconf
$ sudo vi /etc/resolvconf/resolv.conf.d/head

add the following entries to the file

nameserver 192.168.1.4
search my.homezone

Check our settings

$ named-checkconf [ENTER]
$ named-checkzone my.homezone /etc/bind/zones/my.homezone

Now reboot and check if server resolves internal zone after boot.

In case there’s no errors you have successfully setup a bind server with your own domain. Congratulations.

Leave a Reply

Your email address will not be published. Required fields are marked *