TOPIC 9

Date: 4/2/2009
Doman Name Server (DNS)
Linux for Engineering and IT applications


Practical Exercises


Objective: configure your node computer as a DNS server and your desktop as a client to the server. Try configurations of master, slave and caching servers.

Gethostbyname function

Download perl script gethostbyname.pl. Make it executable and run it to resolve the IP addresses for following hosts: localhost, desktop02, and eden.rutgers.edu.

BIND installation on Ubuntu

apt-get install bind9
apt-get install bind9-host
apt-get install dnsutils

Generate files rndc.conf and rndc.key:
cd /etc/bind
rndc-confgen -r /dev/urandom > rndc.conf
rndc-confgen -r /dev/urandom -a
Copy the secret hash from rndc.key to that in rndc.conf. Change "default-port 953" for "default-port 955" so it wouldn't try binding to the TCP port used by rpc.statd. Besides commented out lines, your rndc.conf and rndc.key should look something like below:
# Start of rndc.conf
key "rndc-key" {
        algorithm hmac-md5;
        secret "ylnZwDNmLo7xwJDNzIW0zg==";
};

options {
        default-key "rndc-key";
        default-server 127.0.0.1;
        default-port 955;
};
# End of rndc.conf

# Start of rndc.key
key "rndc-key" {
        algorithm hmac-md5;
        secret "ylnZwDNmLo7xwJDNzIW0zg==";
};
# End of rndc.key
If named was running, reload named:
pkill -HUP named

Caching only DNS

Download local zone files localhost.zone, 0.0.127.in-addr.arpa.zone into /etc/bind. Download named.conf for the case of caching DNS only: named.conf-caching and copy it to /etc/bind/named.conf then start bind:
cp named.conf-caching  /etc/bind/named.conf
/etc/init.d/bind9  start
Check the status of the server:
rndc status

If it gives you error rndc: connect failed: connection refused, kill the named
pkill -9 named
and verify that both rndc.conf and rndc.key contain the same secret hash; start bind9.

Quiry the server for MX record of host engsoft.rutgers.edu
dig MX @127.0.0.1 engsoft.rutgers.edu.
If the DNS is working properly, it should give you an output with the answer section as follows:
;; ANSWER SECTION:
engsoft.rutgers.edu.    86400   IN      MX      0 soemail.rutgers.edu.

On your desktop and the node machine, edit file /etc/dhcp3/dhclient.conf and remove domain-name and domain-name-server from the list of acquired DHCP parameters.
In /etc/resolv.conf on the node make the only entry:
nameserver 127.0.0.1
On the desktop, instead 127.0.0.1, use the IP address of the node, accordingly.
Try to query your DNS server from the desktop
dig engsoft.rutgers.edu.
Make sure it shows your SERVER: on the bottom of the output.

Slave DNS

Download named.conf for the case of slave Rutgers DNS, named.conf-slave, and copy it into /etc/bind/named.conf
Update the list or root name servers:
dig . ns > /etc/bind/db.root

Issue command
rndc reload
Check for appearing of new zone files in /var/cache/bind
Query the DNS:
dig engsoft.rutgers.edu.

Master DNS

Download named.conf for the case of master DNS, named.conf-master, and copy it to /etc/bind/named.conf. Download the master zone files, linux.class, 192.168.5, create directory /var/cache/bind/pdm and copy them into the directory:
mkdir /var/cache/bind/pdm
cp linux.class /var/cache/bind/pdm
cp  192.168.5  /var/cache/bind/pdm
chown -R bind:bind  /var/cache/bind/pdm
Reload the server:
rndc reload

Query thye server
dig desktop18.linux.class.

Modify the zone files in /var/cache/bind/pdm by including your host entries there and change the serial number. Reload the server after modifications are done:
rndc reload



Take me to the Course Website