Trillex installing dns

From Teknologisk videncenter
Revision as of 11:45, 17 February 2009 by Trillex (talk | contribs)
Jump to: navigation, search

Installing and Configuring a Linux DNS server with zone file

Please note that this is done on a Ubuntu server. It can and probably will differ depending on the distro used.

PLEASE NOTICE THAT, IF NOT LOGGED IN A SUPERUSER, YOU WILL NEED TO USE SUDO FOR ALL OF THESE COMMANDS!

Installing the DNS Daemon (Bind9)

Bind9 (Or generally bind) is the standard DNS server daemon for Linux. Install it by typing:

sudo apt-get install bind9

This will install the program. Wait for it.

Configuring the DNS Daemon (Bind9)

There are several things that needs to be setup, like domain name, dns forwarders, creating several files etc.

Domain Name

Domain name can can be changed in the file /etc/bind/named.conf.local Right now the file is either blank or filled out with a lot of commented lines. Just delete them all and insert this:

# 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";
};

Replace example.com with your own domain name (I chose trillex.dk). Also change the "reverse DNS" with your IP. Remember to do it backwards, as explained in the comments. What it essentially does is point towards the zone files it will use.

DNS Forwarder

Since, on this school, we are stuck behind a "master" server, we will need to add that DNS as a forwarder so we can actually get responses back. To find your DNS, you can type:

cat /etc/resolv.conf

The nameserver will be the DNS server here.

Now edit the file /etc/bind/named.conf.options.

Uncomment the forwarder so it looks like this:

forwarders {
       172.16.4.77;
};

Obviously replace the IP with your DNS server.

Creating Files Needed

You linked to a file when choosing domain name, that does not exist. Create them by writing this:

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

Replace example.com with your domain name.

Editing the Zone Definition File

Stay inside the example.com.db file and write in:

// 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.1
mta              IN      A       192.168.0.2
ns1              IN      A       192.168.0.3

Change example.com to your domain name. Ignore or replace the ns1 and mta unless you got these set up on different servers. Remember to put in the IP of your own server.