Configuring Primary Nameserver On Linux via BIND


ISC’s BIND, the Berkely Internet Name Domain system, can be set up to act as: a primary nameserver, secondary nameserver, and a caching-only nameserver (or combinations of these). While configuring a DNS system per se is a beast of a task, setting it up to act as a nameserver for a local LAN network is pretty easy.

Before setting up BIND, knowledge of how the DNS system works is absolutely necessary. There are countless tutorials spread across the Internet which not only describe the ins and outs of the DNS system at length, but also clearly explain how to configure BIND in its various configurations.

BIND reads data and configuration information from several files. Under Slackware, these are: /etc/named.conf, /var/named/localhost.zone, /var/named/named.ca, /var/named/named.local, /var/named/forward.domain.tld.zone, /var/named/reverse.domain.tld.zone. The first four files come, by default, with BIND, while the last two files need to be created by users according to their needs.

For demonstration, I am going to set up a domain “uaaa.rk” for a local network. Files required, in this setting, by BIND are: /etc/named.conf, /var/named/ayaz/localhost.zone, /var/named/ayaz/named.ca, /var/named/named.local, /var/named/ayaz/forward.uaaa.rk.zone, /var/named/ayaz/reverse.uaaa.rk.zone

The contents of these file, as favours the scenario in question, are as follows:

/etc/named.conf
options {
directory "/var/named/ayaz";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
//query-source address * port 53;
};

//
// a caching only nameserver config
//
zone "." {
type hint;
file "named.ca";
};

zone "localhost" {
type master;
file "localhost.zone";
allow-update { none; };
};

zone "0.0.127.in-addr.arpa" {
type master;
file "named.local";
allow-update { none; };
};

zone "uaaa.rk" {
type master;
file "forward.uaaa.rk.zone";
};

zone "50.168.192.in-addr.arpa" {
type master;
file "reverse.uaaa.rk.zone";
};

/var/named/ayaz/localhost.zone
$TTL 86400
$ORIGIN localhost.
@ 1D IN SOA @ root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

1D IN NS @
1D IN A 127.0.0.1

/var/named/ayaz/named.local
$TTL 86400
@ IN SOA localhost. root.localhost. (
2006022707 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.

1 IN PTR localhost.

/var/named/ayaz/forward.uaaa.rk.zone
$TTL 86400
@ IN SOA ns.uaaa.rk. root.localhost. (
2
1h
15m
30d
1h )

@ IN NS ns.uaaa.rk.
@ IN MX 0 mail.uaaa.rk.

localhost IN A 127.0.0.1

ns IN A 192.168.50.1
www IN A 192.168.50.1
ftp IN A 192.168.50.1
ssh IN A 192.168.50.1
mail IN A 192.168.50.1

/var/named/ayaz/reverse.uaaa.rk.zone
$TTL 86400
@ IN SOA ns.uaaa.rk. root.localhost (
2 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttl
)

@ IN NS ns.uaaa.rk.

; The first row are digits appended to 192.168.50., it seems.
1 IN PTR http://www.uaaa.rk.
1 IN PTR ssh.uaaa.rk.
1 IN PTR ftp.uaaa.rk.
1 IN PTR mail.uaaa.rk.

That is it! Start BIND, on Slackware, through /etc/rc.d/rc.bind, and voila! BIND is running.

Note: The files localhost.zone, named.ca, and named.local require no changes.

Tip: If BIND is bailing out mysteriously, execute it in debug mode by calling /usr/sbin/named -g. Doing so will, no doubt, save lots of your time.

Advertisements

3 thoughts on “Configuring Primary Nameserver On Linux via BIND

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s