Setup DNS Server in Raspbian -RasberryPi

This article will show you how to Setup and configure DNS Server on Raspbian. Its called as Bind9 on RasberryPi and is used for resolving IP address to domain name and vice-versa. Make sure that you are logged in as ROOT user and update the OS to the latest.

For reference the IP of this test RasPi is 172.16.64.9

First update Raspbian to the latest patch level.

# apt-get update

One done install bind9

# apt-get install bind9 bind9utils dnsutils

Edit the BIND9 local config file

# vi /etc/bind/named.conf.local
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "hm.local" {                       ---> Your Domain name
        type master;
        file "/etc/bind/forward.zone";  ----> Forward Zone File
        allow-update { key rndc-key; };
};
zone "66.16.172.in-addr.arpa" {          ---> Your IP address subnet
        type master;
        file "/etc/bind/reverse.zone";    ---> Reverse Zone File
        allow-update { key rndc-key; };
};

Create Forward and Reverse Zone Files

# vi /etc/bind/forward.zone
# vi /etc/bind/reverse.zone

1st Edit forward zone file

# vi /etc/bind/forward.zone
$TTL 1D
@ IN SOA raspi.hm.local. root.raspi.hm.local. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   raspi.hm.local.
ciscovpn                IN A    172.16.64.1
raspi                   IN A    172.16.64.9
viz-raspi-st            IN A    172.16.66.212

2nd Edit reverse zone file

# vi /etc/bind/reverse.zone
$TTL 1D
@ IN SOA raspi.hm.local. root.raspi.hm.local. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
         IN NS      raspi.hm.local.
1        IN PTR     ciscovpn.hm.local.
9        IN PTR     raspi.hm.local.
212      IN PTR     viz-raspi-st.hm.local.

Change group permissions to bind9 for both files

# chown :bind /etc/bind/forward.zone
# chown :bind /etc/bind/reverse.zone

You can RUN a config check on bind9

# named-checkconf /etc/bind/named.conf.local

 Configure bind9 to run at runtime and start the service

# update-rc.d bind9 enable
# service bind9 start

And lastly update the /etc/resolv.conf file on your clients to point to the new DNS server IP.

# vi /etc/resolv.conf
search hm.local
nameserver 172.16.64.9

 All done now and ready to start using this DNS server.

If you encounter any errors during the process, let us know via Contact Us and will get it resolved promptly.

Most Read Articles

Add/Detect a new disk in ...

Written By Farooq Mohammed Ahmed on Sunday, 11 January 2015 19:22
Add/Detect a new disk in ...

Cacti Install and Config ...

Written By Farooq Mohammed Ahmed on Monday, 30 November 2015 11:13
Cacti Install and Config ...

Create Kickstart Tree Aut...

Written By Farooq Mohammed Ahmed on Wednesday, 10 February 2016 22:45
Create Kickstart Tree Aut...

Using awk in Alias Comman...

Written By Farooq Mohammed Ahmed on Friday, 19 February 2016 14:22
Using awk in Alias Comman...

Integrate FreeIPA/IDM wit...

Written By Farooq Mohammed Ahmed on Tuesday, 01 March 2016 10:23
Integrate FreeIPA/IDM wit...