Domain Name System
DNS is the method Internet computers use to map IP addresses to domain names. Computers use IP addresses to locate one another, but they are not easy for people to commit to memory. Domain names, such as www.apple.com or train.apple.com, are much easier to remember, but they need to be translated into the IP addresses that computers use. DNS performs this translation.
DNS Basics
Here's a simple example for understanding DNS. Imagine a user who wants to access a website such as Apple's training site. That user is connected to the appropriate server for Apple's training department by entering http://train.apple.com in a browser. Behind the scenes, the graphic on the following page depicts what is actually happening on the Internet to make this connection occur.
- A user enters http://train.apple.com.
- The user's computer checks with a DNS server to find the IP address associated with the domain name train.apple.com. The computer uses the DNS server configured in Network preferences to look up this information. This is referred to as a forward lookup or just lookup.
- The DNS server determines the IP address that corresponds to the domain name requested in the lookup. It returns this information to the user's computer.
- The user's computer then uses the IP address to request the training webpage by sending this IP address to its default Internet router.
This DNS scenario oversimplifies the true capabilities of DNS. The real power of DNS is that any valid Internet IP address in the world can be found quickly and easily, yet easily maintained. This is due to the global design of DNS.
DNS combines a global search space with a local, relatively easy way to maintain this search space. It does this through a hierarchical structure in which each organization is responsible for maintaining its own DNS information.
Reviewing the previous request for a webpage, imagine that the request was coming from a computer at a company in Japan. The Japanese company may maintain its own DNS server but have no idea of how DNS is assigned for companies in the United States. In this case, the local DNS server would contact a parent DNS server, looking for the information on train.apple.com. If the parent DNS server does not have this information, it sends a request to a top-level “root” DNS server that can then contact appropriate servers to find the correct lookup information.
All valid DNS servers on the Internet can eventually find DNS information on any address by following the appropriate lookup through this top-level approach. In this case, the Japanese computer finds the appropriate DNS mapping by following the lookup process and eventually finding a DNS server in the United States that is responsible for mapping the address train.apple.com to the IP address 17.254.2.78.
This process highlights the other key aspect of DNS—locally maintained DNS servers. For example, Apple maintains a list of computers for various web services. Apple can reassign IP addresses internally to meet its server needs, as long as Apple maintains a correct set of DNS files on its local DNS servers and has these DNS servers configured appropriately to be available to higher-level DNS servers that contact them.
The key to these DNS servers is correctly configured files containing the DNS information. These files are typically referred to as DNS configuration and zone files.
DNS Setup
Mac OS X Server includes DNS server functionality based on the standard UNIX-based implementation BIND (Berkeley Internet Name Domain). BIND is the most common implementation of DNS in use on the Internet today, and Mac OS X and Mac OS X Server currently include BIND version 9.2.2.
Most companies that use Mac OS X Server for services such as file, print, and web serving have already established appropriate DNS service. This service could be provided by dedicated DNS departments in their organizations or by an ISP. Companies running their own mail services would also want to ensure DNS service to correctly map IP addresses to their mail domains. If a company has not established DNS service yet, the following steps are required to configure DNS for Mac OS X Server:
- Register your domain name via any valid registrar, such as VeriSign.
- Configure BIND on Mac OS X Server by modifying the DNS configuration and zone files.
- Set up mail exchange (MX) records (optional).
- Start DNS service.
With Mac OS X Server, you can configure DNS zone files with Server Admin.
DNS Zones
Zones are the basic organizational unit of the DNS. Zones contain records, and are defined by how they acquire those records and how they respond to DNS requests. There are three kinds of zones:
- A master zone has the master copy of the zone's records and provides authoritative answers to lookup requests.
- A slave zone is a copy of a master zone stored on a slave or secondary name server. Each slave zone keeps a list of masters that it contacts
to receive updates to records in the master zone. Slaves must be configured to request the copy of the master zone's data.
Slave zones use zone transfers to get copies of the master zone data. Slave name servers can take lookup requests like master
servers. By using several slave zones linked to one master, you can distribute DNS query loads across several computers and ensure that lookup requests are answered when the master name server is down.
Slave zones also have a refresh interval that determines how often slave zones check for changes from the master zone. You can change this interval by using the BIND configuration file. See the BIND documentation for more information.
- A forward zone directs all lookup requests for that zone to other DNS servers. Forward zones don't do zone transfers. Often, forward zone servers are used to provide DNS services to a private network behind a firewall. In this case, the DNS server must have access to the Internet and a DNS server outside the firewall. Finally, forward zones cache responses to the queries that they pass on. This can improve the performance of lookups by clients that use the forward zone.
To add a new DNS zone, go to the Settings pane and click the Zones button. In the Zones list, you see two zones that are created by default. To add more zones, use the Add Zone (+) button. You can delete, edit, or duplicate zones. For each zone, you can add, edit, delete, and duplicate records. When you add a record, you are prompted for the type of record you want to add. After you add a record, it is displayed in the Records list for the zone.
DNS Zone Records
Each zone contains a number of records. These records are requested when a client computer needs to translate a domain name (like www.pretendco.com) to an IP number. Web browsers, email clients, and other network applications rely on zone records to contact the appropriate server. You create records by adding machines to a zone in Server Admin.
Your master zone's records will be queried by others across the Internet so they can connect to your network services. There are several kinds of DNS records. Following are the records that are available for configuration by Server Admin's user interface:
-
Address (A): Stores the IP address associated with a domain name. An A record is created for each machine entry added to a zone.
-
Canonical Name (CNAME): Stores the “real name” of a server when given a nickname or alias. For example, mail.pretendco.com might have a canonical name of mailsrvr1.pretendco.com. A CNAME record is created for each entry in the Alias field when adding a machine to a zone.
-
Mail exchange (MX): Stores the domain name of the computer that is used for email in a zone. An MX record is created when you specify that a machine is a mail server.
-
Pointer (PTR): Stores the domain name of a given IP address (reverse lookup). A PTR record maps an IP address to a computer's DNS name. The pointer record contains the four octets of the IP address in reverse order followed by in-addr.arpa. (For example, 10.1.0.1 becomes 1.0.1.10.in-addr.arpa.)
Mac OS X Server simplifies the creation of these records by focusing on the computer being added to the zone rather than the records themselves. As you add a computer record to a zone, Mac OS X Server creates the appropriate zone records that resolve to a certain computer address.
Add Records to a DNS Server
DNS is a complicated topic that covers a wide range of configuration options and settings. This lesson does not cover in-depth DNS configuration. You will add information to your DNS configuration that will enable you to associate a friendly name with your computer and see the effects of that change.
- On your server computer, open the Terminal application located on the Dock.
If you are familiar with the Secure Shell (SSH) protocol, you can ssh into your server from your Mac OS X computer.
- In the Terminal window, enter cd /var/named to navigate to /var/named.
- List the contents of the ls -la folder.
These are the default DNS configuration files.
- Leave the Terminal window open.
- Open Server Admin if it is not already open and connect to your server.
- Click the DNS service, click the Settings button, and click the Zones tab.
- In the Settings pane, click the Add Zone (+) button to create a zone.
Enter the following settings:
-
Zone Name: pretendco.com. (Make sure to enter the period at the end of the zone name.)
-
Server Name: server17<SHADE></SHADE>
-
Administrator email: admin@pretendco.com. (Make sure to enter the period at the end of the address.)
-
- Click Save, and then click Start Service in the toolbar to start the DNS service.
- Type ls –la in the Terminal window again, and note changes in the named folder.
In this book, you will use Server Admin to make several changes that create and configure files on your disk. It's useful to be familiar with those file locations when troubleshooting. Review the contents of /var/named after you create the new zone.
Note that the list now includes multiple settings files for the default zone you created.
- Now we will use the move comand to examine the content of the pretendco.com.zone file.
In the Terminal window, type more pretendco.com.zone and press Return.
This command displays the contents of your zone file. Entries with A to the left of the IP address are A records. You will see an A record for your server computer, created by default.
Enter the DNS Search Information
You now must enter DNS search information inside the Network preferences pane of both your Mac OS X Server and Mac OS X computers.
- On your server, open System Preferences, navigate to the Network preferences pane, and click Configure to continue.
- Enter the following values:
-
DNS Servers: 10.1.17.1
-
Search Domains: pretendco.com
-
- Click the Apply Now button and close System Preferences.
- Repeat this process on the Mac OS X computer.
Create a DNS Alias for Your Client Computer
In a DNS hierarchy, there are explicit hostnames that resolve to IP addresses. However, a DNS server can maintain a number of different names for computers, which are called aliases. Aliases by themselves are simply friendly names that point to an IP address, and are often used to reduce typing or perform server redirection.
- Return to Server Admin.
You will add a machine alias to your DNS entry and observe the result.
- Select DNS and click the Stop Service button in the toolbar.
- Click the Stop Now button in the dialog that appears to stop the DNS service.
- Select the Settings tab of DNS and click the Machines button.
You will see a list with your server computer, entered by default.
- Click the Add Machine (+) button to add a new entry, and enter the following information:
-
IP Address: 10.1.17.2
-
Name: user17
-
- Click the Add Alias (+) button to add a new alias.
- Type client17 in the Aliases field and click OK.
- Click the Save button and start the DNS service again.
- Note changes in pretendco.com.zone by typing more pretendco.com.zone again in the Terminal.
This command will refresh the display of your zone file. You will see a new entry, with your student name associated with the IP address and an alias that points to your A Record.
- Check your pretendco.com.zone file to ensure that it reflects the changes you just made.
It is useful to understand how your zone files change over time.
Test the New Alias From Your Client Computer
The real test of any DNS change is when your DNS clients are able to use the new entry. Because of the limited number of services available, you will use ping from your client computer to see if its alias was configured properly.
- On your client computer, open Network Utility and click the Ping button.
- In the address field, type client17 and click Ping.
The ping command should execute properly and resolve to 10.1.17.2.
Monitoring DNS Activity
Within Server Admin, you can monitor DNS activity on Mac OS X Server using the Overview, Activity, and Log panes for DNS.
- The Overview pane displays information such as DNS server status (Running/Stopped), DNS version (BIND 9.2.2), number of zones allocated, and query logging status (Off/On).
- The Activity pane displays information on Source of Authority (SOA) queries and zone transfers.
- The Log pane displays current information about start time and DNS queries (lookups).
DNS is an essential function in any running version of Mac OS X. Many services look for DNS information to find critical information. Examples of these services are the login window, server administration tools, directory services, Internet communications, and any direct web access. Incorrectly configured DNS could result in a long delay in these services completing their associated tasks.
DNS is a complicated and subtle protocol. Its distributed nature often makes it difficult to discern where a problem lies: Is it the client, the local DNS server, or some remote DNS server on the Internet? Advanced DNS issues will likely require an experienced system administrator. However, there are few quick checks you can make easily.
Perform DNS Lookups
The best graphical tool for troubleshooting DNS issues is Network Utility's Lookup pane, where you can perform DNS lookups. Perform the following checks when you troubleshoot DNS problems:
- Check hardware and network issues.
- Verify that network settings are correct in the Network pane of System Preferences.
- Use Network Utility's Lookup pane to test your DNS server.
- Use Network Utility's Ping pane to test direct IP connectivity, bypassing DNS.
- Ping another computer on your subnet to test for basic IP connectivity, but also be sure to test the IP address that is listed as the DNS server in Network preferences.
- Check with a network administrator to ensure that DNS servers are configured properly.
Isolate and Resolve DNS Issues
DNS issues can take many forms. You may have problems that are related to end users who misunderstand your DNS hierarchy, or typographic problems within your DNS aliases. A system administrator must be able to determine authoritatively where a DNS entry is being resolved.
You have already tested your alias with a successful ping. You will now look up DNS information.
- On your Mac OS X computer, in Network Utility, click Lookup.
Lookup enables you to identify the server where DNS resolves for a particular value. You know that user17 and client17 were working, but now you should make sure you see how they resolve.
- In the address field, type client17.pretendco.com and press Return.
Lookup requires an FQDN, which is why you must add “pretendco.com”.
- Scroll the response so that you can see the Authority Section information.
Your authority should be your server computer, server17.pretendco.com. This result shows that server17.pretendco.com. is resolved on your server computer, and the DNS service is working at that level.