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.