Installing DNS on SLES 9
TEST OBJECTIVE COVERED:
- Configure a DNS server using BIND.
To implement a DNS service on your SLES 9 server, you can choose from several packages. However, the most widely implemented DNS package is Berkeley Internet Name Domain (BIND) package. For your CLE 9 certification, this is the package you need to know how to deploy.
Let's briefly discuss the BIND package itself.
BIND was originally developed in the early 1980s at the University of California at Berkeley. Its initial development was funded by a grant from the United States Department of Defense.
Subsequent versions, up to version 4.9, were sponsored by DEC. Versions since have been maintained by the Internet Systems Consortium (ISC). The latest versions of BIND can be downloaded from http://www.isc.org. However, you don't need to do that because the BIND 9 package is included on your SUSE Linux Enterprise Server 9 CD 3; as shown in Figure 3.9:
Figure 3.9 BIND package on SLES 9 CD 3.
Let's now review how to install the BIND package on your SLES 9 server.
You install BIND on a SLES 9 server the same as you would any other software package. You can use either YaST or the rpm command-line utility. Let's look at how to do this with YaST. Complete the following:
- From your SLES 9 desktop, select YaST.
- When prompted, provide your root password.
- In the left frame, select Software.
- In the right frame, select Install and Remove Software. The screen in Figure 3.10 appears:
Figure 3.10 YaST software management screen.
- In the Search field, enter bind ; then select Search.
- In the right frame, mark the bind and the bind-utils packages; as shown in Figure 3.11.
Figure 3.11 Installing BIND packages.
- Select Accept.
- When prompted, insert the appropriate CDs.
- Wait while the packages are installed and SuSEconfig is run; as shown in Figure 3.12.
Figure 3.12 Running SuSEconfig after installing BIND.
- Close YaST by selecting Close.
If you want to use the rpm utility to install the package from a shell prompt, do the following:
- Insert your SLES 9 CD 3 into your server's CD-ROM drive.
- Open a terminal session and enter rpm -i /media/cdrecorder/suse/i586/bind-9.2.3-76.9.i586.rpm .
If you followed the steps in the lab exercises in the previous chapter, your SLES 9 system should already have the BIND package installed.
To verify that it's there, open YaST and select Software, Install and Remove Software. In the search field, enter bind , and then select Search. You should see the bind and bind-utils packages marked with blue check marks, as shown in Figure 3.13:
Figure 3.13 BIND is already installed.
If, for some reason, the BIND packages aren't installed on your SLES 9 system, follow the preceding steps to install them.
After the BIND packages are installed, the service is started and stopped using the named (pronounced "name dee") init script in /etc/init.d, as shown in Figure 3.14:
Figure 3.14 The BIND startup script.
The actual binary that provides this service is the named executable located in /usr/sbin shown in Figure 3.15.
Figure 3.15 BIND binary.
Like other daemons, you use the /etc/init.d/named script to start, stop, or restart named. This is done by simply calling the script and supplying the appropriate parameter. Some examples of commands you can use include the following:
- /etc/init.d/named start— Starts the named daemon.
- /etc/init.d/named stop— Stops the named daemon.
- /etc/init.d/named restart— Restarts the named daemon.
If you don't want to use the full path, you can also enter rcnamed from the shell prompt along with the start, stop, or restart parameters to manage the named daemon.
After BIND is installed on your system, you're ready to configure and start the service on your server. However, before doing so, you need to have a solid understanding of the BIND configuration files.
BIND Configuration Files
In this chapter, we're going to use YaST to set up the named service on your SLES 9 server. However, as discussed in Chapter 2, "Introduction to SUSE LINUX Enterprise Server 9," I believe that it's critical that you thoroughly understand what's happening "under the hood" of YaST's graphical interface.
With that in mind, let's look at the files that are used to configure the named service running on your server.
CONFIGURING named USING named.conf
The first file you need to be familiar with is named.conf. This file resides in /etc, as shown in Figure 3.16:
Figure 3.16 The named.conf file in /etc.
The named.conf file is the main configuration file for the named service. named.conf is composed of directives along with blocks of information associated with those directives.
The directives within the named.conf file include the following:
- options— This directive defines general configuration options for the named service.
- logging— This directive configures logging channels for the named service. These channels could include sending logging information to the syslog service or to a specific file.
- zone— These directives define zones serviced by named.
The named.conf file has many configuration parameters. At this point, we're going to focus on two of them. We'll look at several of the others later on in the chapter.
The first parameter you need to be aware of is the directory parameter within the options directive, shown in Figure 3.17:
Figure 3.17 Setting the working directory for named.
This option specifies the directory where the zone database files used by the named service will reside. By default, these reside in /var/lib/named, as shown in Figure 3.18:
Figure 3.18 Files for named in /var/lib/named.
Anytime a filename is specified in any directive that follows the directory parameter in the named.conf file, it is assumed to reside in the specified directory.
The second set of parameters you need to be familiar with are the zone directives. These are found farther down in the file after the options directive, as shown in Figure 3.19.
Figure 3.19 Zone directives in /etc/named.conf.
The zone directives in named.conf define the zones that will be serviced by named. Notice in Figure 3.19 that a zone directive is composed of several parts:
- Zone Name— The zone name comes right after the zone directive. The zone name is enclosed in quotes. In Figure 3.19, three zones have been defined: ., localhost, and 0.0.127-in-addr.arpa:
- Name Space— The name space declaration comes after the zone name. In Figure 3.19, each of the three zones has been configured to use the Internet name space, denoted by in.
- Type— The type declaration identifies whether the server will be a master DNS server or a slave DNS server.
- File— The file declaration identifies the file where the zone data is stored. The file name is enclosed in quotes. The file is assumed to be in the directory specified in the options directive.
In Figure 3.19, you can see that three zones are defined by default in named.conf. The first zone is called . and is configured as a hint file. The records in this zone point to the root-level name servers on the Internet. This zone is used by named when it receives a request to resolve a hostname residing in a zone for which it isn't authoritative. The IP address for these root-level name servers is contained in the root.hint file, shown in Figure 3.20:
Figure 3.20 Root-level DNS server IP addresses in root.hint.
The root.hint file is automatically copied to /var/lib/named when the BIND package is installed.
The next default zone defined in named.conf is localhost. This zone contains only a single record that simply maps localhost to the IP address 127.0.0.1.
The last default zone is called 0.0.127.in-addr.arpa. That name may sound a little confusing, but it actually isn't. This zone is a reverse zone. It maps the IP address 127.0.0.1 to the localhost hostname. We'll look at reverse-lookup zones a little later.
As you may have noticed, these three default zones don't define any real DNS zones. Can the named service installed on the server do any meaningful work in this configuration? Your first impression might be that it can't. What can it resolve if it has records only for the localhost hostname? However, it can actually function very nicely. In this default configuration, the named service operates as a caching-only name server.
Recall, as discussed earlier in this chapter, that a DNS server will query root-level name servers when it's asked to resolve a hostname that it isn't authoritative for. The DNS server will use the information supplied by the root-level DNS server to locate an authoritative DNS server for the requested hostname.
When the hostname is finally resolved, the DNS server stores that information in its cache. The next time it receives a request to resolve the same hostname, it simply pulls the information out of its cache.
This type of configuration is appropriate for situations where you don't have your own domain and you want to provide users with the capability to browse the web.
However, it's more likely that you will need to provide resolution services for a domain using the name daemon. To do this, you will need to create your own zone files and configure named to use them.
Let's talk about how to do that next.
CREATING ZONE FILES
Suppose you are the system administrator for an organization named CLE9 (what a coincidence!). You've secured the cle9.com domain name for your organization. Previously, you configured your SLES 9 server to be a caching-only name server. However, now you need to configure named to provide authoritative resolution services for the cle9.com zone. What do you need to do?
First, you need to edit your /etc/named.conf file and add a new zone directive. This is shown in Figure 3.21:
Figure 3.21 Adding a New Zone to named.conf.
In this example, we've added the cle9.com zone. The DNS server will be a master, authoritative server for the zone. The next thing we need to do is to create a file for the zone. Notice that we've specified the file to be master/cle9.com. Because we've specified that our directory is /var/lib/named, the zone file will, therefore, be /var/lib/named/master/cle9.com.
After saving the file, the next thing we need to do is open the zone file and add the appropriate information. This is where things get a little more complicated. I'm going to show you a basic zone file I've created for the cle9.com zone. This is shown in Figure 3.22:
Figure 3.22 The cle9.com zone.
In this zone, there are three hosts: fs1, fs2, and gateway. Let's explore each element of the zone file in a little more depth:
- $TTL— This stands for Time To Live. This value specifies the default time to live for each record. If a record has an explicit time to live value, it takes precedence over the TTL value specified here. If no unit is specified, the value is assumed to reference seconds. Figure 3.22 shows 2 seconds, which is probably too small a value. You can also specify units in days by placing a D after the value; for example, 2D.
- IN— Specifies that the file uses the Internet namespace.
SOA stands for Start Of Authority. The SOA is actually a record, just like the records you see in Figure 3.22 for fs1 and fs2. However, the SOA record has a special purpose. It must be placed immediately after the $TTL parameter. The role of the SOA record is to identify the following:
- Which DNS server is the authoritative server for the zone? In Figure 3.22, fs1.cle9.com. is identified as the authoritative DNS server for the cle9.com zone.
- The email address of the system administrator who maintains the zone. In this example, this is firstname.lastname@example.org.
- The zone's serial number. This number is used by slave DNS servers for this zone to determine whether they should update their databases. You can use any initial value you want in this field. However, the general practice is to use the date the zone file was created concatenated with a zero. In Figure 3.22, the zone file was created on April 8, 2005. If you use YaST to update your zone, this number will be auto- matically incremented (that's why we start with a zero at the end). If you update the zone file with a text editor, you should manually increment the last digit of the serial number. This tells slave DNS servers that the zone file has changed and that they need to update their database from the master server.
- The periodic interval, specified by the refresh parameter at which slave DNS server should update their databases from the master server. Notice in Figure 3.22, the refresh interval is set to 3 hours.
- How many attempts slave servers should make before giving up when updating their database from the master server. This is specified by the retry parameter.
- How long before zone data on slave servers expire. This is specified by the expiry parameter. If zone data expires, slave servers will not be allowed to respond to name resolution requests until it downloads updated zone data from the master server.
- How long failed name resolution requests should be stored in the cache of slave servers. This is specified by the minimum parameter.
After the SOA record come a series of records for network hosts. The general syntax is:
host_name name_space record_type IP address or host_name.Let's review each of these parameters:
- Hostname— This the hostname assigned to the particular system.
- Name space— This specifies the name space used for the record. More than likely, you will always used the Internet (IN) namespace.
- Record type— This parameter specifies what type of DNS record this is.
- IP address or hostname— This parameter specifies the IP address or hostname you are mapping a the hostname to. Remember, if you use a hostname, you have two options. First, you can just specify the hostname being mapped to. If you do this, it will be assumed to be in the zone specified in the SOA. Second, you can use a FQDN. If you do, you must use a trailing period.
When creating DNS records, you can create several types. These include the following:
- NS— An NS record is used to specify the hostname of the DNS server that hosts the specified zone. Instead of mapping to an IP address, an NS record maps to the hostname of the DNS server. The DNS server referenced by the NS record must, itself, be represented by an A record in the zone.
- A— An A record maps a hostname to an IP address. The host is usually just the hostname, as shown in Figure 3.22. In this case, the host is assumed to be in the zone specified in the SOA record. However, you can also specify a FQDN (with a trailing period).
- CNAME— A CNAME record is an alias. Instead of mapping to an IP address, it maps a hostname to another hostname in the zone. For example, in Figure 3.22, you could create a CNAME record that maps the hostname of MyServer to fs1. If you do this, you must create an A record for the hostname being mapped to. In preceding example, you would have to have an A record for fs1.
- MX— An MX record represents a mail server. Like a CNAME record, an MX record maps a hostname to another hostname instead of an IP address. For example, suppose fs2 in Figure 3.22 is running a mail service. You could create an MX record in your zone for the hostname mail that points to fs2. Like a CNAME record, you must have an A record in the DNS zone that maps the second hostname to an IP address.
At this point, we need to discuss an interesting fact about the way named handles records in a zone file. The question frequently arises as to how to handle hosts with multiple IP addresses. This situation arises for two reasons.
First, to provide a degree of fault tolerance and to balance the network load between the NICs, many network administrators will install multiple NICs in their servers. In this situation, a server may have two or more IP addresses.
Second, many network administrators will provide a given service on multiple hosts. For example, to accommodate network load, an organization may divide its HTTP service among several servers in a server farm. For example, if you use dig or nslookup to resolve www.yahoo.com, you will see that there are multiple A records for this single hostname, as shown in Figure 3.23:
Figure 3.23 Multiple address for www.yahoo.com.
If you are in either situation, you need to configure your zone file so that named will resolve multiple IP addresses to a single hostname. Additionally, you probably want to make sure that named doesn't give out the same address for the multiaddress hostname over and over. One of your major goals behind implementing a multi-NIC server or a multiserver service is to balance the load. This goal would be undermined if your DNS server resolves only one of the addresses assigned to the hostname.
So what do you do? The good news is that named is designed with this scenario in mind. If you have a hostname that has multiple IP addresses, all you have to do is create multiple A records for the same hostname in your zone; each resolving to a different IP address. The named daemon will then automatically rotate which address is resolved to the hostname, thereby distributing the network load on your server or service for you. Pretty powerful stuff!
At this point, we need to switch gears. Everything we've been talking about in this topic has been based on forward-lookup zones. Before continuing, we need to also review how to create reverse zones.
CONFIGURING REVERSE-LOOKUP ZONES
As discussed earlier in this chapter, a reverse-lookup zone operates in the opposite manner of a standard forward-lookup zone. Instead of resolving hostnames into IP addresses, a reverse zone resolves IP addresses into hostnames.
Before your named daemon can perform this type of lookup, you need to configure a companion reverse zone for your forward zone. An example of a reverse zone for the cle9.com zone is shown in Figure 3.24:
Figure 3.24 The reverse-lookup zone for cle9.com.
You'll notice that the $TTL parameter and the SOA record are pretty much the same as the forward-lookup zone. However, similarities end there.
Locate the NS record in Figure 3.24. Notice the odd zone name used. Instead of cle9.com, the zone's name is 1.168.192.in-addr.arpa.. Reverse zone names are constructed in the following way:
For example, in Figure 3.24, the network address for the hosts in the zone is 192.168.1.0. Therefore, the zone name is 1.168.192.in-addr.arpa..
Accordingly, the hosts in the zone are referenced in the following way:
For example, the reverse hostname for fs1.cle9.com is 188.8.131.52.in-addr.arpa..
With the reverse zone running, you can send reverse resolution requests, as shown in Figure 3.25:
Figure 3.25 Performing a reverse-lookup.
In this example, the DNS server has resolved the IP address of 192.168.1.47 to fs1.cle9.com.
Now that you know about forward and reverse zone as well as the files that compose them, you are ready to configure BIND on your server. Let's do that next.
Configuring BIND on SLES 9
To configure BIND on SLES 9, you basically have two options: You can manually create and edit the necessary files or you can use YaST. For your CLE 9 certification, you need to know how to do this with YaST. Let's dig right in and do it. To configure BIND on SLES 9, complete the following:
- From the desktop of your SLES 9 server, start YaST.
- Select Network Services, DNS Server, as shown in Figure 3.26:
Figure 3.26 Configuring DNS in YaST.
- Configure the named files directory by completing the following:
- To configure named logging, complete the following:
- In the left frame, select Logging. The screen in Figure 3.28 is displayed.
Figure 3.28 Configuring named Logging options.
- If you want named to use the system log, mark Log to System Log. (This is the default behavior.)
- If you want named to write log information to a separate log file, mark Log to File; then enter a filename, maximum log size (in MB), and a maximum number of log versions to be saved.
- If you want to log the requests for name resolution that the named daemon receives from clients, mark Log Named Queries under Additional Logging.
- If you want to log modifications made to the zone, mark Log Zone Updates.
- If you want to log zone transfers, mark Log Zone Transfers.
- In the left frame, select Logging. The screen in Figure 3.28 is displayed.
- Configure your zones by completing the following:
- In the left frame, select DNS
Zones. The screen shown in Figure 3.29 is displayed.
Figure 3.29 Configuring DNS Zones in YaST.
- To create a new zone, enter the name of the zone in the Zone Name field.
- Select Add.
- Under Configured DNS Zones, select the zone you just created, and then select Edit Zone.
- Select the NS Records tab. The screen in Figure 3.30 appears.
Figure 3.30 Configuring NS Records in YaST.
- In the Name Server to Add field, enter the FQDN of the server that is running named.
- Select Add.
- Select the SOA tab. The screen shown in Figure 3.31 is displayed:
Figure 3.31 Configuring the SOA Record in YaST.
- Configure your SOA directives as desired.
- Select the Records tab. The screen in Figure 3.32 is displayed.
Figure 3.32 Configuring Zone Records in YaST.
- In the Record field, enter the hostname or the FQDN for a host you want to add to the zone.
- In the Type drop-down list, select the type of record you are adding.
- In the value field, enter the IP address (for A records) or FQDN (for CNAME records) assigned to the host.
- Select Add.
- Repeat these steps for all the hosts you want to add to the zone.
- When you're done, select OK.
- In the left frame, select DNS Zones. The screen shown in Figure 3.29 is displayed.
- Configure startup options for the named daemon by completing the following:
- Apply the changes by selecting Finish.
That's all there is to it. You're probably ready to get your own DNS server up and running; let's do that in Lab Exercise 3.1.