| Setting up and Using Bind Part One |
| 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:
If you are using RedHat, you can use Yum:
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:
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:
To start the server on OS X, you can type:
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
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: 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 |
Welcome to codefui. Your once a day stop for coding fullfilment.
We've all seen it, we've all been there. You start on a new project, you begin to review the code, and then you see it. The most hideous or most awesome line of code you have ever read in your life. I mean this is bad-ass code. Code so bad, or so good, you want to punch your cube-mate because he is within arm's reach. We also present a lot of useful, and reusable code snippets you can freely use.
Have a good code snippet you want to share? Send it to us and we might post it! codefui@codefui.com!
Bored? Create an account. Lord knows you don't have enough already. What's one more?