Call us Toll-Free:
1-800-218-1525
Email us

 Sponsors

How to use BIND as a simple nameserver

Michel Nadeau, 02-19-2009
From time to time, our dedicated servers hosting company's DNS servers are going down. It's never for a very long time but, even for a few minutes, it's something we really can't accept because everything stops working correctly.

To fix this situation, we decided to install and configure our own DNS servers. We're not delegating any domains to these servers - only using them as local nameservers on our servers.

This quick tutorial will tell you how to achieve this on FreeBSD (may also apply to other Linux versions with some minor BIND configuration file modifications).

1. Install BIND

In our case, BIND was already installed on all our servers. The version we're using is BIND 9.3.5-P2. To install it, simply do this:

cd /usr/ports/dns/bind9
make all install

2. Configure BIND

To use BIND as a simple nameserver, no special configuration is needed; the default configuration file is perfect. The configuration file is located here:

/var/named/etc/namedb/named.conf

If you have specific configuration needs, just do them in that file.

3. Start and test BIND

Now that BIND is installed and configured, you're ready to start and test it. To start BIND, simply do this:

named

Now to test it, just use nslookup specifying the DNS server to use like this:

nslookup google.com localhost

This will lookup google.com using localhost as the DNS server. Do many tests, including the hosts your scripts may use the most.

You can also run BIND in foreground mode instead of daemon, so you can see debug information directly on-screen. To do so, simply start it like this:

named -g

You can also control the amount of debug information with the -d (debug level) switch. Just specify a debug level (numeric) from 0 to 100. For example:

named -d 100 -g

Now using another session you can issue nslookup commands and see what's doing the BIND server on-screen.

4. Rolling BIND live

When all your tests are satisfying, you're ready to roll the BIND server live! To do so, simply edit this file:

/etc/resolv.conf

Simply add, on the FIRST line:

nameserver 127.0.0.1

NOTE: DO NOT use "localhost" or a hostname - resolv.conf only accepts IPs (on FreeBSD, at least).

resolv.conf tells your operating system what are your DNS servers, in order of priority. We HIGHLY recommend that you keep your other DNS servers as secondary servers, so if there's a problem with your BIND server, your operating system will use the secondary servers.

Conclusion

Voila! In a couple of minutes, you have your own local nameserver and you don't need your hosting company's DNS servers anymore (except in case of backup).

Dawn Rossi, 02-26-2009
Sample bind config file:

$TTL 60

alwaysupdns.com. IN SOA alwaysupdns.com. alwaysupdns.com. (
20090220 ; Serial number
60 ; Refresh
900 ; Retry
864000 ; Expire
60 ; Min TTL
)

; Host records
alwaysupdns.com. IN A 67.228.124.168
www.alwaysupdns.com. IN A 67.228.124.168

; Mail servers
alwaysupdns.com. MX 10 mx1.softwareprojects.com.
mail.alwaysupdns.com. IN A 204.200.197.196

; DNS Servers
alwaysupdns.com. IN NS dns1.alwaysupdns.com.
alwaysupdns.com. IN NS dns2.alwaysupdns.com.
dns1.alwaysupdns.com. IN A 67.228.124.168
dns2.alwaysupdns.com. IN A 67.228.191.123

; Alternate DNS Servers
alwaysupdns.com. IN NS ns2.mydyndns.org.
alwaysupdns.com. IN NS ns3.mydyndns.org.
alwaysupdns.com. IN NS ns4.mydyndns.org.
alwaysupdns.com. IN NS ns5.mydyndns.org.

Adrian Singer, 12-13-2009
To reload Bind's named.conf file, use:

named.reload
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions