Once you've configured BIND as a DNS server, there are a number of commands you can use to keep it working. Red Hat even has its own GUI configuration tool for BIND. While I describe the Red Hat tool briefly, it's somewhat complex. Red Hat didn't even include a GUI tool for RHEL 4, so its reliability in RHEL 5 may not have been fully tested in production.
There are three commands associated with the BIND service: rndc, host, and dig. The rndc command is a better way to control the service. The rndc and host commands are successors to nslookup.
The rndc commands are straightforward. When you run rndc by itself, the output guides you through the available options. The options I use are straightforward: rndc stop and rndc start don't require explanation. The rndc reload command rereads any changes you've made to the configuration or DNS database files. The rndc status command confirms that DNS is running, along with information on the DNS database.
While you can still use commands such as service named start and service named reload, the rndc command can do more. Because the current Red Hat Exam Prep guide suggests that you need only know how to create a caching and slave nameserver, the details are not important for this book.
After you configure DNS and make it reread your configuration files with the rndc reload command, examine the results with the host -l example.com command. I've shown the results from my zone file in Figure 11-7.
Figure 11-7: Listing a working DNS zone
Now test the setup. Use the dig command to examine your work. For example, if you use dig to look up the address of www.redhat.com, you'll see something like the output shown in Figure 11-8.
Figure 11-8: DNS query using dig
The dig command asks your DNS server to look for the www.redhat.com server. Assuming IP address information for www.redhat.com isn't stored locally, it then contacts one of the name server computers listed in /etc/resolv.conf. If that doesn't work, it goes to one of the name servers listed in the named.ca file and makes its requests from there. The request may be passed on to other DNS servers. Therefore, it can take some time before you see an answer.
|On the Job|| |
The nslookup command is now deprecated, and you may not even be able to use it in a future release of Red Hat Enterprise Linux.
Red Hat has created a number of excellent GUI configuration tools. They are "front ends" that can help many administrators create the configuration files that they need. While the Red Hat Domain Name Service tool is promising, it was just introduced for RHEL 5. Red Hat did not even include a GUI configuration tool for BIND in RHEL 4.
In any case, it is best if you learn how to configure Linux services, including DNS, directly from the configuration files. As a Linux systems administrator, you may not always have access to the GUI. You may need to administer servers remotely, which makes GUI configuration difficult at best.
If you want to try the Red Hat Domain Name Service configuration tool, back up your DNS configuration files first: /etc/named.conf, as well as the files in the /var/ named directory (subdirectories, and links actual files in other directories).
Exercise 11-1: Setting Up Your Own DNS Server
Following the example files shown previously, set up your own DNS server. Set it up to serve the domain called rhce.test. As long as your domain is private, it doesn't matter that rhce.test does not match the standard domain name types such as .com or .net.
Edit the /etc/named.conf file to reflect the configuration files that you plan to use. Name the zone file rhce.test.zone and set it to be a master domain.
Edit the file /var/named/rhce.test.zone and place the proper zone information in it. Start by adding in the header with the serial number and expiration information.
Add the SOA resource record (RR) with a proper administrative e-mail address contact.
Add NS and MX RRs for the domain. Use the 192.168.0.0/24 address range. If you're configuring an actual TCP/IP network with static IP addresses, feel free to use the assigned IP addresses on your network.
Add several hosts to the zone file. Use WWW, FTP, and mail for a few.
Save the zone file and then restart named with the rndc reload command.
Use the dig command to check the rhce.test domain. If it works, you have a working DNS server.