Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I need a complete step-by-step guide on how to produce such a server configuration.

Can anyone help-me?

share|improve this question
add comment

1 Answer 1

Complete DNS server in ubuntu server 12.

First of all change the ip address of your server form DHCP to STATIC for this use the following command

sudo nano /etc/network/interfaces

and add:

auto eth0
iface eth0 inet static
# dns-nameservers

*I am leaving dns-nameserver empty and is commented we will come to it later.

Restart networking daemons

sudo /etc/init.d/networking restart

Before configuring a DNS server in linux Ubuntu you have to make domain name first and then you will proceed. First you will check your hostname command for this is

sudo nano /etc/hostname


(This is my Ubuntu server hostname yours might be different .You can change this according to your need)

Now after hostname, you have to make domain name for your server. Say servername.domain.com it is better practice that whenever you are configuring server for home use or so, do not use .com but .hom or .net or whatever you like. Give the below command

  sudo nano /etc/hosts

add if it does not have it:   localhost     nefitari.autun.hom    nefitari

In my file is for localhost and I have changed the second IP address with my server IP that is now I enter my domain name having my hostname nefitari first then my domain name autun.hom and then alias nefitari. You can select of your own, hostname.abc.net or hostname.home.lan etc. but remember changing to this file need to restart your server and then login. Restart is must

Now install BIND9

 sudo apt-get install bind9

After installation just configure the below files step by step

  • Named.conf.options
  • Named.conf.local
  • Named.conf.resolv.conf

Now configure file named.conf.options This file is use for DNS IPs It mean that your server must connect to some DNS outside. When you buy domain name from ISP’s they normally gives you their own DNS IPs. You can use open DNS IPs of google or so. In my case I am using my own ISP DNS IPs.

 sudo nano /etc/bind/named.conf.options
 forwarders {
 # Give here your ISP DNS IP’s;    # gateway or router;;;

***Save the file and exit***using control x press y and overwrite the file

Now edit the file named.conf.local This is the file in which we define forward zones and reverse zones. It means that when we enter domain name it will translate it into IP address and when we enter IP address it will simply convert it into name.

sudo nano /etc/bind/named.conf.local

will show:

# Our forward zone
zone "autun.hom" {
 type master;
 file "/etc/bind/zones/db.autun.hom";

# Our reverse Zone 
# Server IP 
zone "1.168.192.in-addr.arpa" {
  type master;
  file "/etc/bind/zones/db.192";

***Save the file and exit***using control x press y and overwrite the file

Now we will make these two database files db.autun.hom and db.192 in zones folder

First make the directory zones in /etc/bind/

  sudo mkdir /etc/bind/zones

Before making files let me clear you that I have different devices

Devices IPs

  • Server itself
  • Gateway
  • Win7pc

Now in zones directory we will create two files first db.autun.hom. I am just copying the db.local already present in /etc/bind folder to zones folder by changing its name to db.autun.hom. I will put these IP’s in my db.autun.hom file. Let’s start

sudo cp /etc/bind/db.local  /etc/bind/zones/db.autun.hom

Now use the command below to edit the file

sudo nano /etc/bind/zones/db.autun.hom

 ; BIND data file for local loopback interface
 $TTL    604800
 @       IN      SOA     nefitari.autun.hom. webuser.autun.hom. (
                          2         ; Serial
                     604800         ; Refresh
                      86400         ; Retry
                    2419200         ; Expire
                     604800 )       ; Negative Cache TTL
   autun.hom.       IN  NS  nefitari.autun.hom.
   autun.hom.       IN  A
   ;@               IN  A
   ;@               IN  AAAA    ::1
  nefitari          IN  A
  gateway           IN  A
  win7pc            IN  A
  www       IN  CNAME   autun.hom.

Save it and exit

  • Webuser.autun.hom. is the email who will access name server. You can write any name instead webuser like admin, root or host master etc.
  • Autun.hom. is my NS means name server
  • Autun.hom.changing to IP
  • @ IN A and AAAA ::1 can be comment out you should not need it because db.local is already present in /etc/bind it is just a copy of that file. So no need you can delete it
  • Changing Nefitari to IP
  • Gateway to IP
  • Win7pc you can name your windows PCs or Linux Clients to any name but remember IP of that client must correctly be inserted into file. In my case I gave IP of windows PC
  • Last, I am using CNAME means canonical name it is just an alias to nefitari. Means that you can access your server by entering www.autun.hom instead nefitari.autun.hom . You can omit this or comment it. It is just up to you.

Now create reverse lookup zone file

sudo cp /etc/bind/db.127    /etc/bind/zones/db.192

Now use the command below to edit the file

sudo nano /etc/bind/zones/db.192

   ; BIND reverse data file for local loopback interface
   $TTL    604800
   @       IN      SOA     nefitari.autun.hom. webuser.autun.hom. (
                          2         ; Serial
                     604800         ; Refresh
                      86400         ; Retry
                    2419200         ; Expire
                     604800 )       ; Negative Cache TTL
        IN  NS  nefitari.
   1    IN  PTR gateway.autun.hom.
   5    IN  PTR nefitari.autun.hom.
   50   IN  PTR win7pc.autun.hom.

Save it and exit

Now when you are done with your zone file you have to check it whether it is working correctly or not by entering the command below for forward zone file

named-checkzone autun.hom /etc/bind/zones/db.autun.hom
zone autun.hom /IN: loaded serial   2

Now check the reverse zone file

named-checkzone autun.hom /etc/bind/zones/db.192
zone autun.hom /IN: loaded serial   2

If the output of your named-checkzone is same as above then it is working fine otherwise you made some mistake in file.

Now edit the file resolv.conf

sudo nano /etc/resolv.conf

domain      autun.hom
search      autun.hom

Enter the following lines into to your resolv.conf file and save it

Restart the bind

sudo /etc/init.d/bind9 restart

After bind start check your setting in log file

tail -f /var/log/syslog

it must not have any error in the log

Checking forward zones

host –l autun.hom

Output should like this

 autun.hom name server nefitari.autun.hom.
 autun.hom has address
 gateway.autun.hom has address
 nefitari.autun.hom has address
 win7pc.autun.hom has address


nslookup autun.hom



Name: autun.hom


 dig gateway.autun.hom

 ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35612
 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

 ;gateway.autun.hom         IN  A

 gateway.autun.hom      604800  IN  A

 Autun.hom.     604800  IN      NS  nefitari.autun.hom. 

 Nefitari.autun.hom.    604800  IN      A

 ;; Query time: 12 msec
 ;; WHEN: Thu Aug 8 01:56:25 2013
 ;; MSG SIZE  rcvd: 90

Output should similar to the above, check status: NOERROR means it is resolving check ANSWER SECTION: gateway.autun.hom is resolved into

Checking reverse zone


Output domain name pointer gateway.autun.hom

If it gives you an error like below

 host not found: 3(NXDOMAIN)

This means that you made some mistake in /etc/bind/named.conf.local file in reverse zone If your server IP is then your reverse zone looks like this

zone "**1.168.192**.in-addr.arpa" {
 correct ip reversing

Sometime people made mistake in reversing the ip like (just an example)

zone "**0.168.192**.in-addr.arpa" {
incorrect ip reversing



Address:    name=gateway.autun.hom

If you get NXDOMAIN or SERVFAIL like errors it means that one of your zone file is not working correctly

Now you can ping ubuntu.com or dig ubuntu.com for the first time it will take several miliseconds to resolve the name ubuntu.com but when you run it second time it will take 1, 2 or 3 seconds normally form 1 to 10 mili seconds are normal and it means that your DNS is working properly

Configuring clients

windows side

  • open network connections
  • select change adapter settings
  • select properties
  • select internet protocol version IPv4

and here give the IP address (in my case it is have you remember win7pc)

  • IP address
  • Subnet Mask
  • Default Gateway
  • primary DNS (my new BIND DNS server ip)
  • in the same window select Advance
  • select DNS tab
  • Type in the text box below here In DNS Suffix for this connection:autun.hom
  • click ok
  • click on validate setting upon exit
  • click ok

and you are done with it open CMD

ping gateway

it must gives you some replies


ping or 5

it must gives you some replies


share|improve this answer
It is a shame that this page has 3726 uniq views and the answer has only one upvote. If it was helpful to you, upvote it! –  fotanus Nov 5 '13 at 14:48
This answer is correct except for the part about editing /etc/resolv.conf. Since Ubuntu 12.04 you don't edit that file by hand but configure resolvconf to do so. Set RESOLVCONF=yes in /etc/default/bind9 to cause BIND 9 named to register its local listen address with resolvconf when it starts. Make sure that /etc/resolv.conf is a symbolic link to ../run/resolvconf/resolv.conf. –  jdthood Jan 29 at 15:48
syslog errors - (network unreachable) resolving './NS/IN': 2001:500:3::42#53 Are from bind trying to resolve queries recursively using ipv6. Editing /etc/default/bind9 and using OPTIONS="-u bind -4" fixes it. More info: serverfault.com/questions/77325/unreachable-resolving-domain –  RichardWigley Apr 22 at 14:16
add comment

protected by Community Feb 21 at 22:19

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.