ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software

Creating DNS Server with Ubuntu Linux - Primary DNS Server with Bind9

Updated on November 17, 2009
DNS Server with BIND9
DNS Server with BIND9

Creating Primary DNS Server with Bind9

This little tutorial will go through the steps of creating a DNS (domain name system) server on your ubuntu server machine. I recently setup a dns server to host some of my internal and public domains and found many tutorials confusing or caused problems.

For this example I will go through the steps for setting up a private domain name for a private network, the instructions will apply if you have decided to host a dns server for your domain name.

The bind9 dns server was tested on ubuntu server 8.04,8.10 and 9.04

Bind9 - Configuring Zone Files

A primary master server using Bind9 is setup to serve DNS records (groups of records referred to as zones) for a fictitious domain name which is restricted to a private network.

The first step is to boot up your ubuntu server system and ensure you have root privledges

sudo su

Once in root mode you can enter the main directory for bind9 /etc/bind

The first file you will need to modify is "named.conf.local" , this file is where we will be referencing our forward and reverse zone files for your domain names.

The below code shows the basic format for your named.conf.local file inside the /etc/bind directory. it specifies the domain which in this case is, classified it as a master server and specified the location of the file which will store all information relating to that zone.

The reverse zone file is your ip address backwards e.g ( becomes 68.170.192)


zone "" {
             type master;
             file "/etc/bind/";

Reverse Zone File

zone "" {
        type master;
        notify no;
        file "/etc/bind/db.192";

Creating the (SOA) Start of Authority Record domain zone files contains all the regular DNS information for a (SOA) or Start of Authority Record which defines global parameters for the zone (domain).

The zone file contains many different values and its important to know what each does for future reference.

name - The 'root name' of the zone. Most commonly written as @ or Origin Value.

ttl - Standard TTL values apply (range 0 to 2147483647 clarified by RFC 2181). The slave (Secondary) DNS does not use the the TTL value but various parameters defined within the SOA. set by an authoritative nameserver for a particular resource record.

name-server - Any name server that will respond authoritatively for the domain.

refresh - Signed 32 bit time value in seconds. Indicates the time when the slave will try to refresh the zone from the master

retry - Signed 32 bit value in seconds. Defines the time between retries if the slave (secondary) fails to contact the master when refresh (above) has expired. Typical values would be 180 (3 minutes) to 900 (15 minutes) or higher

expiry - Signed 32 bit value in seconds. Indicates when the zone data is no longer authoritative. Used by Slave or (Secondary) servers only.

Serial - The serial value is in the format YYYYMMDDSS for example 2009101101 , year 2009 10th month 11th day serial 01, remember the serial needs to be incremented by 1 every time a change is made in order for secondary dns server/slave to registry it.

$TTL    604800
@       IN      SOA (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
@       IN      NS
@       IN      A
box     IN      A

Apply changes in Bind9

Remember to restart the naming service whenever you make any changes to your zones using

/etc/init.d/bind9 restart

remember to be in root mode

The reverse zone file is also created with similar format to



; BIND reverse data file for local loopback interface
$TTL    604800
@       IN      SOA (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
@       IN      NS      ns.
10      IN      PTR

Testing and Troubleshooting

Once you have modified the files , named.conf.local, and db.192

and restarted the naming service /etc/init.d/bind9 restart

You can test your domain name but before you do that you should set your linux systems DNS resolvers to point to the dns server you just created on

open up the file /etc/resolv.conf using vim /etc/resolv.conf

and enter your domain name information




once the DNS resolvers have been setup inside /etc/resolv.conf

you can test your dns server using

ping , dig or named-checkzone /etc/bind/


For any trouble shooting problems first consult the system logs using ,

to check for errors otherwise feel free to ask questions or let me know if i've made any mistakes.


    0 of 8192 characters used
    Post Comment

    • profile image

      dd_vv 5 years ago

      I followed your suggestion and it failed when I first tried it; looked up logs in /var/log/syslog and got an error message that of an unknown expression "Reverse" while attempting to load the named.conf.local file.

      I therefore went back to the named.conf.local file and commented out the line stating Reverse:

      // Reverse Zone File

      Restarted bind9 and it worked like a charm. Thank you so much. I have been having issues trying to set up a dns server for a very long time using multiple resources and never came out of it with a working server. I can't thank you enough!!!

    • profile image

      cosscat 7 years ago

      Hello expectus. i have read and applied your tutorial. overall good info. anyway, I have some trouble seeing my site online. Here is what I get after dig

      ; DiG 9.7.1-P2

      ;; global options: +cmd

      ;; Got answer:

      ;; ->>HEADER

    • expectus profile image

      expectus 7 years ago from Land Downunder

      if the dns server fails to start it usually means the zone files are formatted incorrectly, double check formatting or post in comments so i can take a look

    • profile image

      sukieboy 7 years ago

      Hey man it was a nice topic though am new to Ubuntu/Linux. Was trying to follow your steps but when I restarted my DNS server, it failed.

      Actually I am trying to settup up a private domain to connect my mail service (postfix)earlier installed and maybe connect MS office outlook to it.

      So can you please help show the way?

    • profile image

      drprometheus 7 years ago

      You are the Man! Thank you for such a lucid and simple explantion. Exceptional...

    • expectus profile image

      expectus 8 years ago from Land Downunder

      thanks for the comment, yea those DNS problems can be very frustrating and hard to pin point the cause of the problems.

    • profile image 8 years ago

      Love this kind of hub. I recently had an issue with the SOA for a Domain name - the issue prevented the domain showing up so very interesting to read this. Thanks expectus!