Setting up bind DNS server for local domain and forwarder

September 26, 2018


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 =
bind server ip =
webserver ip =
local domain : my.homezone

Bind Installation

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


$ 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{

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

recursion yes;
allow-query {trusted;};
allow-recursion {trusted;};
listen-on {;};
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

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

Does the webserver resolve

$ host www.my.homezone [ENTER]

should return

www.my.homezone has adress


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

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 comment