GD Star Rating
loading...
One of the tasks on which I've noticed a few wanna be RHCE struggles is the BIND configuration, while I love the DNS service I know that if you're not used to work with under Linux can be a little tricky to configure, so here we go I'll show you how to configure a CentOS (but the concept still apply to other Linux Distributions)as a master DNS server for name resolution. I'll assume you've already installed all the required packages for the configuration, I'll use a chroot environment but this will easily apply even to non chrooted environment.
Just as recap here's the packages installed in the environment used for this post :
bind-chroot-9.3.6-4.P1.el5_4.2<br />
bind-libs-9.3.6-4.P1.el5_4.2<br />
bind-utils-9.3.6-4.P1.el5_4.2<br />
bind-9.3.6-4.P1.el5_4.2
The complete path for the chrooted environment is /var/named/chroot/etc and /var/named/chroot/var/ ok with this said we will be configuring our DNS for the zone ccielogs.com, of course change to whatever you like. Ok when installing BIND packages you'll find example files and documentation under /usr/share/doc/bind-version/sample let's start from this copying the file named.rfc1912.zones named.conf under the /var/chroot/named/etc/ and renaming it to named.conf with the following command :
cp /usr/share/doc/bind-9.3.6/sample/etc/named.rfc1912.zones ./named.conf
Now open this file with your favorite editor and you should find a text similar to the following :

This is exactly what we need, a good starting point to get our DNS server up and running quickly, remember the key in RHCE exam is not the style but the ability to complete required tasks quickly and this is a good way to do that. As you probably have guessed in this file we find the definition of our DNS zones, so we need to add the required options/stanzas to make our server actually work as a DNS Server so edit the file as in the following image :

I've put some comments on the file to help you out understand what I've modified and because this is a very good habit to develop, I've learned this the hard way in my days as a programmer. Now all that is left to do is to define our zones so delete the "default" zones defined in the sample file and input what you need in our example will create a fake zone for the ccielogs.com domain and a reverse zone for the 192.168.1.X network, in the picture the definition for these zones :

As you can see here I've defined the domain for which my server will be authoritative and the file where the zone will be hosted, basically where we are going to register the clients/server for the specific domain together with a reverse lookup zone for our network, the next step is creating the actual zone files in the /var/ path (remember we are in a chroot environment) so just change to the /var/named/chroot/var/ path and input :
touch ccielogs.zone ccielogs.rr && chown named.named ccielogs*
This will create the two needed files and will assign the ownership of both to the user and group named which is the security context under which our BIND server runs. Now open the file with your favorite text editor and compile it to resemble the one below changing the IP addresses and names as needed :


Of course I could accomplish the above result easily using ALIAS records, but for the sake of this post I preferred to do this way, of course the second image shows our reverse lookup zone for our network.
Last step before we can actually start resolving names for our network is to verify that we did not commit any error in the configuration files, to do this simply issue :
service named configtest

If everything was correct you'll get an output similar to the above, otherwise the service command will tell you what's wrong wit your files and will ask you to correct the problem, now simply start the service with :
service named start
Ok let's see if everything is working testing the names of the machines we just defined in our test zones :

Congratulations! Your DNS server is working and able to resolve names in the domain!
Keep in mind this is a very basic configuration, BIND can be a very complex matter, enough to say that there is a really good book about it and the more advanced configurations, but this should suffice for getting you started with a working configuration of a BIND Master Name Server.
In the post and in our configuration there is though a "small" error that I introduced on purpose, can you tell what's wrong with this configuration?
A small hint, try to ping www.google.com and check the results. What's wrong with this configuration?
A cookie to the first 10 people who can spot the error, just leave a comment.
In the following days I'll post a solution about this, meanwhile this should be a good exercise for anyone struggling to learn BIND and for all RHCE aspirant.
Lethe.
GD Star Rating
loading...
GD Star Rating
loading...