ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

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


      6 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


      8 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 imageAUTHOR


      8 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


      8 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


      8 years ago

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

    • expectus profile imageAUTHOR


      9 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 

      9 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!


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at:

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)