Friday, October 14, 2011

DNS Server setup using Bind DNS on Ubuntu Server

To Setup Bind server we need to install Bind Package using
sudo apt-get install bind9

Configure the main Bind files. Usually, if you install Bind from the source code, you will have to edit the file named.conf. However, Ubuntu provides you with a pre-configured Bind, so we will edit another file:
sudo vi /etc/bind/named.conf.local

Add  this code there
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
};

Now, let's add the zone definition files (replace example.com with your domain name so create a zone definition file as
sudo vi /etc/bind/example.com.db

Add this code there
;
; BIND data file for local loopback interface
;
$TTL    3600
@    IN    SOA    example.com. admin.example.com. (
11
604800
86400
2419200
604800 )
;
@       IN      NS      ns1.example.com.
@       IN      A       192.168.0.1
ns1     IN      A       192.168.0.1
ns2     IN      A       192.168.0.1
www     IN      A       192.168.0.1

Save it and Restart bind Server :
sudo /etc/init.d/bind9 restart

Now Our name server is ready as
ns1.example.com
ns2.example.com

if it asks for IP address just provide the IP address of your server in oue case 192.168.0.1

Now its Done.