sakana

very short memo

Name Server

Now let’s move on to Name Server. Sometimes you would like to have your own name services to manipulate protocol like SMTP.

I hereby demonstrate procedure to set up BIND (version 9). In this example, we use fictitious domain, example.org.

We disregard redundancy and focus on primary server. That is, we omit secondary server :-).

By the way, following articles are good reference for you.

In this sample, we Ubuntu as platform. And goal is to setup instance as follows.

None

Installation

Installation is quite simple.

$ sudo apt-get install bind9 dnsutils

That’s all.

Server Configurations

Configuration files are stored under /etc/bind directory. You will modify some file and add zone files for forward/reverse lookup.

├── bind.keys
├── db.0
├── db.127
├── db.255
├── db.empty
├── db.local
├── db.root
├── named.conf
├── named.conf.default-zones
├── named.conf.local
├── named.conf.options
├── rndc.key
└── zones.rfc1918

Forward Zone

Append following lines into named.conf.local file so as to specify your domain name and its zone file.

zone "example.org" {
        type master;
    file "/etc/bind/db.example.org";
};

Create zone file, db.example.org, so as to describe host in the domain.

;
; BIND data file for example.org
;
$TTL    604800
@       IN      SOA     example.org. root.example.org. (
                       20130928         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
        IN      A       10.0.3.10
;
@       IN      NS      dns.example.org.
@       IN      A       10.0.3.10
@       IN      AAAA    ::1
dns     IN      A       10.0.3.10
;MTA
        IN      MX 10   mta.example.org.
mta     IN      A       10.0.3.20

Reverse Zone

And now configure for reverse lookup. Same as forward lookup, append following lines into named.conf.local.file.

zone "3.0.10.in-addr.arpa" {
        type master;
        file "/etc/bind/db.10";
};

And create a file named db.10 as follows.

;
; BIND reverse data file for network 10.0.3.0
;
$TTL    604800
@       IN      SOA     example.org. root.example.org. (
                       20130928         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      dns.
10      IN      PTR     dns.example.org.
20      IN      PTR     mta.example.org.

Logging

Log message has been and will be your friend for debugging problem. Append following lines to named.conf.local file.

logging {
    channel query.log {
        file "/var/log/query.log";
        severity debug 3;
    };
    category queries { query.log; };
};

And create a log file and change file owner to bind user.

$ sudo touch /var/log/query.log
$ sudo chown bind /var/log/query.log

You will see log messages like this.

client 127.0.0.1#34060 (mta.example.org): query: mta.example.org IN A +E (127.0.0.1)

start service

$ sudo service bind9 restart