Registered Users

Login

Setting up and Using Bind Part One
(1 vote, average 4.00 out of 5)
System
Written by James Birchfield   
Tuesday, 28 September 2010 08:36

It is very easy to take for granted a very valuable service, the Domain Naming System (DNS).  DNS provides us the ability to lookup and resolve internet addresses without the need to know the Internet Protocol (IP) address.  Imagine, that if you wanted to do a Google search with no DNS, you would have to know that http://google.com is really  72.14.204.147.  To make DNS requests (lookups) convenient, most people are assigned a DNS server when they receive their IP address from their Internet Service Provider (ISP) .

In this article, we will learn how to, and more importantly why we should, setup our own caching DNS server and how use it as our primary server.

Every time you point your browser to a location, a DNS lookup request is made.  Depending on the amount of network traffic, or the load on the DNS machine you were assigned, this lookup request can sometimes take as much as two to three seconds.  If you have ever noticed your browser’s status bar saying “Looking up host...” and then just sit there for what seems like a very long time, this is what it is doing.  By routing all DNS requests through a local caching DNS server, once we have made the initial request, for let’s say google.com, the caching server remembers the lookup information and will use the cached copy the nest time the same request comes though.

Our solution involves the installation and configuration of a Bind (http://www.bind9.net/) server.  Bind, which stands for Berkley Internet Name Domain), is a very popular open source implementation of the DNS protocol, and is readily available on most Linux servers as well as OS X.

 

 

First thing we need to do is to install Bind.  There are a few ways to do this.  If you are using Ubuntu or Debian, you can use apt-get:

sudo apt-get install bind9
 

If you are using RedHat, you can use Yum:

sudo yum install bind
 

Lastly, if you are running OS X 10.6+, you already have what you need.

Now that we have Bind installed, let’s look at a basic caching only configuration.

/etc/named.conf:

include "/etc/rndc.key";
 
controls {
 inet 127.0.0.1 port 54 allow {any;}
 keys { "rndc-key"; };
};
 
options {
 directory "/var/named";
 forwarders { 74.128.17.114; }; // this should be one of the DNS servers provided by the ISP
};
// 
// a caching only nameserver config
// 
zone "." IN {
 type hint;
 file "named.ca";
};
 
zone "localhost" IN {
 type master;
 file "localhost.zone";
 allow-update { none; };
};
 
zone "0.0.127.in-addr.arpa" IN {
 type master;
 file "named.local";
 allow-update { none; };
};
 
logging {
 category default {
 _default_log;
 };

In the above configuration, you will notice the ‘file’ attribute.  These files are expected to live in the ‘/var/named’ directory.  Luckily, if all we want is a caching DNS server, the default configuration files can be used right out of the box with no changes.  You would only need to modify or add configuration files if you were going to use your own zones.  We will discuss zones in part two.

All that is left now is to start the server and configure our system to use it.  To start the server onUbuntu, Debian, and Redhat you can type:

 sudo /etc/init.d/named start
 

To start the server on OS X, you can type:

 launchctl load -w /System/Library/LaunchDaemons/org.isc.named.plist

 

Now that we have the server running, we need to tell our server to use it as the primary DNS server.  For Ubuntu, Debian, and RedHat, you make your changes to the /etc/resolv.conf file.

 

/etc/resolv.conf

nameserver 127.0.0.1

 

The ‘nameserver’ entry is the only thing required for us to use our new caching server.  If you want to add other name servers, just add an additional line each one you wish to use.  You can also set your search and domain values here, which we will look at in depth in part two.

 

Even though OS X has the /etc/resolv.conf file, it *does not use it*!  In fact, the following comment block can be found at the top:

#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
#
# This file is automatically generated.
#

To use our newly started caching server, we have to use the Network Preferences GUI Panel.  First, select the connection to edit (i.e. AirPort, Ethernet, etc.) and then clickthe advanced button.  On the next screen, you will see a tab called DNS.  Click the ‘+’ button at the bottom and enter ‘127.0.0.1’.  Then, if there are other DNS servers defined, drag the ‘127.0.0.1’ entry above them all to the top position.

 

We are all set, now point your browser to http://google.com agains and notice the status bar. After the page loads, hit refresh, and you should see a noticeable difference.

 

In part two, we will learn how to create our own zone, and forward requests our ISP or OpenDNS name servers.

 

 

 

 

Last Updated on Thursday, 30 September 2010 16:48
 

Add comment


Joomla SEO by AceSEF