RSS



How to set up a DNS Server using Bind

Mon, Jan 1, 2007

Linux, Ubuntu, linkydinks

Talk about it in our Forums

ubuntu server stuff

The Ubuntu Document Storage Facility has a good article on setting up a DNS server using Bind.

You can read the original here or check it out below the jump.


After looking on Ubuntu forum for an easy step-by-step howto for instaling a DNS server, I decided the best idea would probably be to write this howto myself…. So, here it is!

Step 1: Install Ubuntu dapper, or use your WORKING installation.
Step2: Install bind 9:

file.pngCode:

sudo apt-get install bind9

Step 3: 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:

file.pngCode:

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

This is where we will insert our zones. By the way, a zone is a domain name that is referenced in the DNS server

Insert this in the named.conf.local file:

file.png File:named.conf.local

# This is the zone definition. replace example.com with your domain name
zone "example.com" {
type master;
file "/etc/bind/zones/example.com.db";
};
# This is the zone definition for reverse DNS. replace 0.168.192 with your network address in reverse notation - e.g my network address is 192.168.0
zone "0.168.192.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.0.168.192.in-addr.arpa";
};

Ok, now, let’s edit the options file:

file.pngCode:

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

We need to modify the forwarder. This is the DNS server to which your own DNS will forward the requests he cannot process.

file.png File:named.conf.options

forwarders {
# Replace the address below with the address of your provider's DNS server
123.123.123.123;
};

Now, let’s add the zone definition files (replace example.com with your domain name:

file.pngCode:

sudo mkdir /etc/bind/zones

sudo vi /etc/bind/zones/example.com.db

The zone definition file is where we will put all the addresses / machine names that our DNS server will know. You can take the following example:

file.png File:example.com.db

// replace example.com with your domain name. do not forget the . after the domain name!
// Also, replace ns1 with the name of your DNS server

example.com. IN SOA ns1.example.com. admin.example.com. (

// Do not modify the following lines!
2006081401
28800
3600
604800
38400
)
// Replace the following line as necessary:
// ns1 = DNS Server name
// mta = mail server name
// example.com = domain name
example.com. IN NS ns1.example.com.
example.com. IN MX 10 mta.example.com.

// Replace the IP address with the right IP addresses.
www IN A 192.168.0.2
mta IN A 192.168.0.3
ns1 IN A 192.168.0.1

Now, let’s create the reverse DNS zone file:

file.pngCode:

sudo vi /etc/bind/zones/rev.0.168.192.in-addr.arpa

Copy and paste the following text, modify as needed:

file.png File:rev.0.168.192.in-addr.arpa

//replace example.com with your domain name, ns1 with your DNS server name.
// The number before IN PTR example.com is the machine address of the DNS server. in my case, it's 1, as my IP address is 192.168.0.1.
@ IN SOA ns1.example.com. admin.example.com. (
2006081401;
28800;
604800;
604800;
86400
)
IN NS ns1.example.com.
1  IN PTR example.com

Ok, now you just need to restart bind:

file.pngCode:

sudo /etc/init.d/bind9 restart

We can now test the new DNS server…
Step 4: Modify the file resolv.conf with the following settings:

file.pngCode:

sudo vi /etc/resolv.conf

enter the following:

file.png File:resolv.conf

// replace example.com with your domain name, and 192.168.0.1 with the address of your new DNS server.
search example.com
nameserver 192.168.0.1

Now, test your DNS:

file.pngCode:

dig example.com

Click the icon, share the link:
  • Digg
  • del.icio.us
  • MisterWong
  • Furl
  • Reddit
  • Technorati
  • BlinkList
  • feedmelinks
  • PopCurrent
  • Blogosphere News
  • Facebook
  • Fark
  • Mixx
  • Slashdot

This post was written by:

arsgeek - who has written 1980 posts on ArsGeek.


Contact the author

3 Comments For This Post

  1. Petar Says:

    Why would anyone want to use the notoriously insecure Bind?

  2. markez linda Says:

    I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

  3. Domain Flipping Says:

    A fantastic read….very literate and informative. Many thanks….where is your RSS button ?

1 Trackbacks For This Post

  1. How to set up a DNS Server using Bind : Tech Tips Says:

    [...] How to set up a DNS Server using Bind [...]

Leave a Reply