DNS Server in Ubuntu / Debian

December 4, 2015 in Services

zone “allaboutlinux.local” {
type master;
file “/etc/bind/db.allaboutlinux.local”;

Lets create the db that will have the information for our zone. as we defined that in the previous step that will be /etc/bind/db.allaboutlinux.local

sudo gedit /etc/bind/db.allaboutlinux.local

Add the following lines but configure the ips and names to fit your needs.

; BIND data file for allaboutlinux.local
; Filename: /etc/bind/db.allaboutlinux.local
$TTL    604800
@       IN      SOA     ns.allaboutlinux.local   root.allaboutlinux.local. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
@       IN      NS      ns.allaboutlinux.local.
ns      IN      A

;also list other computers
DNS     IN      A
sql     IN      A
Apache  IN      A
filesrv IN      A
router  IN      A

save, exit and restart bind9:

sudo service bind9 restart

That was it. The DNS is up and running for you local network and you can add the ip of your dns in all computers in your network. There is one last thing that we need to do since your dns is able to convert names into ips in your network but not outside of that. So if you want to visit allaboutlinux.eu most likely you will get an error that the name cannot be resolved. To fix that we need to setup some forwarders so our dns server will check his own database and if he cannot resolve the provided name it will forward this request to another dns. open the following file:

sudo gedit /etc/bind/named.conf.options

Add the following lines at the end of the document save and close:

forwarders {;;;

In this example I’m using the public dns of google and as 3rd the ip of my router that points to the dns of my ISP. On very change that you are doing in the config files of your dns dont forget to restart the service.

Now lets test our dns server. open a terminal and type:

nslookup apache.allaboutlinux.local

Actually i’m asking here the ip of apache.allaboutlinux.local by using the dns and that should reply something like:

nslookup apache.allaboutlinux.local

Name:   apache.allaboutlinux.local



Pages: 1 2