Dynamic Host Configuration Protocol
DHCP is a protocol for dynamically configuring a host machine. While most people associate DHCP with receiving an IP address, the configuration information provided to a machine can be much more than an IP address. Typically DHCP provides IP address assignment along with a valid subnet mask, router, DNS server, and domain name. DHCP can provide other host configuration information, such as the default information for connecting to a NetInfo directory. Mac OS X Server also provides a convenient way to configure the Lightweight Directory Access Protocol (LDAP) information to be sent to a requesting computer.
The process of the server granting an address to the client is well documented. In the illustration below, the interaction occurs in the following order:
- A host iBook on the network is set to obtain network configuration information via DHCP. It sends a request to the network to see if a valid DHCP server is available.
- A DHCP server receives the request from the iBook and responds with the appropriate information. In this case, the DHCP server responds with an IP address of 10.1.55.2, a subnet mask and router, a DNS server address of 10.1.0.1, and an LDAP server of ldap.example.com. The iBook then formally requests what the DHCP server offers. At this time, the iBook has a valid IP address and can start using the network.
- As other devices come on the network and request configuration information via DHCP, they receive the appropriate information. In this case, the PowerBook receives the next available IP address of 10.1.55.3 as well as the same DNS and LDAP information.
- As the eMac joins the network, it also receives appropriate DHCP information.
A key benefit that the DHCP server provides in this example is the assignment of configuration information to each host on the network. You do not have to manually enter this information from each machine under the “Manual” setting option. Use of the DHCP server also guarantees that users do not have network problems caused by incorrectly typed information, such as duplicate IP addresses, subnet, or DNS settings. If an organization has set up its network appropriately, a new user can take a new Macintosh computer out of the box, plug it into the network, and automatically be set up with appropriate IP, DNS, NetInfo, and LDAP information. This user can then authenticate against the company LDAP or NetInfo directory and access appropriate network services without doing any configuration. This capability provides an organization with an extremely simple way to set up and administer computers.
Before you configure DHCP, you should know about the options available to you.
Server Admin is the tool that is used to configure DHCP on Mac OS X Server. You can configure multiple DHCP ranges, or subnets as they are called in Server Admin, as long as you don't allow the IP ranges to overlap. Use the Add Subnet button to set up DHCP ranges and enter all appropriate information.
To configure DHCP:
- In Server Admin, select DHCP and click Settings to configure Mac OS X Server's DHCP service.
The list of currently configured DHCP subnets appears.
- Click the Add Subnet (+) button to set up a new subnet configuration. Either double-click a subnet or select it and click the Edit (pen) button to edit an existing subnet.
DHCP Subnet Information
You can configure multiple subnet ranges on Mac OS X Server in the Subnets pane. You could add an additional subnet range for a second range on an existing port, as shown below, or for a range on a different port. You might need to configure subnet ranges on multiple ports when using an Apple Xserve server with dual Ethernet ports or when using a computer that contains a four-port Ethernet card.
DHCP General Information
In the General pane, you can configure the IP settings that the DHCP server provides for a specific subnet. (You must be editing a subnet to see the General pane.) Enter an appropriate name for the subnet and select the network interface to be used for the range of addresses. Then enter the appropriate IP addresses to define the IP range in the Starting IP Address and Ending IP Address fields. This IP range must be unique and must not overlap with another DHCP subnet range being served. Next enter the appropriate subnet mask and router settings.
DHCP servers also use a range of IP addresses to lease an IP address to computers for a temporary period, known as the lease time. Leasing enables an organization to support a larger number of computers than there are available IP addresses by reusing IP addresses over time. For example, members of a sales force using portable computers may not all need IP addresses in the local sales office if many sales reps are not in the office each day. DCHP would be an ideal way to administer such an office: A host receives the IP address for the assigned lease time and relinquishes it when the network interface is no longer in use, such as when the machine shuts down. If a machine is still using the IP address, it can request an extended lease time.
Set the length of the lease time depending upon the needs of your organization.
DHCP DNS Information
In addition to providing an IP address, DHCP can also provide additional network configuration information, such as the addresses for DNS servers. In the DNS pane, you set the DNS information that the DHCP server provides. DNS is discussed later in this lesson.
DHCP LDAP Information
LDAP is a network-based directory service designed to provide information to the client. The LDAP pane is where the administrator enters the LDAP configuration information that will be sent to clients. Clients that receive this information can connect to the LDAP server and be configured automatically to use that server's directory services. Mac OS X makes deploying LDAP easy by sending the configuration information to clients with the DHCP response over Option 95, which is the standard defined by the Internet Assigned Numbers Authority (IANA).
DHCP Static Mapping
You can assign specific addresses to the computers on your network, if desired. This enables you to keep the ease of configuration of using DHCP while having some static servers or services. To assign an IP address to a computer, you will need the computer's Ethernet address (sometimes called its MAC address or hardware address). Each network interface has its own Ethernet address. If you have a computer that moves from being wired to the network to a wireless network, it uses two different Ethernet addresses—one for the wired connection and one for the wireless connection—so be sure to enter it twice if necessary.
To assign static IP addresses:
- Open the Static Maps pane for DHCP service and click the Add Static Map (+) button.
- Enter the Ethernet address of the computer, which will receive a static address and the IP address you want to assign to it. If desired, you can write a description or note related to this mapping. Click OK.
Within the Settings pane of Server Admin for DHCP, you can set the level of detail for logs. Click the Logging button to access the Log Level pop-up menu, then set the level of detail that will be provided to the DHCP logs. The Medium setting lists general DHCP warnings and errors; the Low setting lists only more serious entries, such as a notice that the DHCP server did not start up as expected.
The DHCP log entries are contained in the main system log file. You can view the system log using other utilities such as Console or System Profiler, but if you use the Log pane for the DHCP service in Server Admin, only the DHCP entries will be displayed.
You can also look for specific DHCP events by entering them in the Filter field. Note the specific DHCP entries and the general flow of events for DHCP:
DHCP DISCOVER: A DHCP client sends a discover message to look for DHCP servers.
OFFER: A DHCP server responds to a client DHCP DISCOVER message.
DHCP REQUEST: A DHCP client requests DHCP configuration information from the DHCP server.
ACK: A DHCP server responds with DHCP configuration information for the DHCP client.
You can remember this chain of events with the acronym DORA: Discover, Offer, Request, Acknowledge.
Addresses that are assigned can of course be reused. The client sends a DHCP RELEASE message to the server when it is being shut down. This message notifies the server that the address can be reassigned to another client.
You can use Server Admin to view detailed information about the DHCP clients associated with a DHCP server. To view the DHCP client information, click the Clients button at the bottom of the screen.
The DHCP Clients pane provides the following information:
- Computer name
- Hardware address (the MAC address associated with a specific DHCP client)
- DHCP client ID
- IP address assigned
- Lease time remaining
A DHCP client can have a client ID, which may provide an administrator more information about which host is assigned a specific IP address. Some service providers may require a valid client ID before providing an IP address from their DHCP server. Use the Network pane of System Preferences in Mac OS X to configure the client ID. In the DHCP server for Mac OS X Server, the client ID is simply a convenient way for the administrator to track specific clients. You can't actually change the behavior of the DHCP server based on the client ID.
Create a DHCP Subnet
Follow these steps to create a DHCP subnet:
- On your server, click the Server Admin icon in the Dock or from your Mac OS X computer, launch Server Admin (/Applications/Server).
- If you have used Server Admin previously and added your information to your Keychain, your server will appear in the Computers
& Services list on the left.
If this is the first time you are using Server Admin, enter the server's IP address, local hostname, or DNS name (if the network is set up for DNS), or click Browse to select from a list of servers on your local network. You should be using Server17.local for this book. You can also choose your server from the Connect Recent list under the Server menu.
- Choose DHCP in the Computers & Services list, then click Settings at the bottom of the screen. You will use the Settings window to configure DHCP subnets (ranges) and determine how DHCP service messages will be logged.
- Click the Add Subnet (+) button at the bottom of the pane to create a subnet for the en0 interface.
- Enter the following values:
Subnet Name: Sales Network
Starting IP Address: 10.1.17.5
Ending IP Address: 10.1.17.5
Subnet Mask: 255.255.0.0
- Click the Lease Time pop-up menu to view the available options for lease time increments.
- Leave the Lease Time value set to 1 and the Lease Time menu set to Hours, reflecting a lease time of 1 hour.
- Click the DNS button adjacent to the General and LDAP buttons within the DHCP window. The Save Changes dialog appears. Click to save changes.
- Enter the following DNS information in the appropriate fields:
Default Domain: pretendco.com
Name Servers: 10.1.17.1
This pane provides the DHCP client computer with the correct DNS information via DHCP, even though you have yet to configure DNS on your server.
- Click the LDAP button in the DHCP service pane.
The LDAP pane contains fields for LDAP information that will be delivered to DHCP clients.
- Enter the following values:
Server Name: mainserver.pretendco.com
Search Base: dc=pretendco,dc=com
The LDAP server has not been configured yet, but sending the information in the DHCP packet causes no harm at this point. The client will simply ignore it.
- Click the Back button (the left arrow) to return to the Subnets pane.
- Select the Enable checkbox for the subnet you just edited.
- Click the Save button to save the new settings for this DHCP subnet name.
Note that you can drag the Preferences icon (located above the Save button) to the desktop to create a backup of these settings.
- Click Start Service in the toolbar to start the DHCP service.
- Click the Log button.
You can filter for specific entries in the log using the Filter field at the bottom right. For example, if you wanted to see whether your DHCP service was enabled, you could type enabled into the Filter field and see only the log entries that include that value.
- Verify that the DHCP service is running.
If the indicator next to DHCP under Computers & Services is green, then the service is running.
Request a DHCP Address and Set a Client ID
Although DHCP is running, you'll want to check your Mac OS X computer to make sure it received the proper address.
- On your Mac OS X computer, unplug the Ethernet cable, wait about 2 seconds, and plug it back in.
This enables your machine to do a Discover and look for the DHCP server.
- Click the Refresh button in the Server Admin toolbar.
You should see in the log file that your Mac OS X computer now has the IP address of 10.1.17.5.
- On your Mac OS X computer, open System Preferences and choose the Network preferences pane. Select Built-in Ethernet from the Show drop-down menu.
- Enter your name in the DHCP Client ID field and click the Apply Now button.
- Click the Refresh button in the Server Admin toolbar and then click the Clients tab at the bottom of the window.
You should see in the window that your Mac OS X computer now has a client ID associated with it.
The pane shows a list of all computers currently receiving a DHCP address from this server computer. Because you limited the DHCP range to provide only one IP address, there should be only one computer listed.
The DHCP Clients pane lists information about DHCP address recipients. This information includes the computer name, hardware address (Ethernet ID), DHCP client ID (if used), IP address, and lease remaining.
Note the Hardware Address column, which helps system administrators identify computers using the active network interface's Ethernet ID.
It is important to keep the DHCP service healthy, as computers cannot interact with each other over the Internet without IP addresses (although Bonjour allows Mac OS X 10.2 through 10.4 computers to communicate without a DHCP server on a local network).
When you are troubleshooting DHCP issues for Mac OS X, check the following:
- Is the machine configured correctly on the network? Check physical network issues, such as cabling, broken routers or hubs, and limitations of the physical subnet.
- Can you establish any network connection? Can you ping another host? Can you see another host over AppleTalk?
- Is the configuration set up properly? Are you using addresses assigned via DHCP or manually? If the problem is with DHCP, does a static address work?
- Is an IP address assigned via DHCP or is the address self-assigned (169.254.x.x range)? Can you ping another host via both IP address and hostname? Can you perform a DNS lookup?
From the client, you can see the DHCP packet information sent to it by using the Terminal application and typing ipconfig getpacket en0 and pressing Return.
When you are troubleshooting DHCP issues for Mac OS X Server, check the following:
- Is the DHCP server configured correctly on the local network? Is the server reachable on the network via ping? Is a static address properly assigned to the server?
- Is the DHCP service configured properly? Are the DHCP server subnet enabled and the DHCP service turned on?
- Does Server Admin show the expected DHCP client activity?
- Do the DHCP log entries match the expected activity for your server?
Turning Off DHCP Service
Now that you have tested DHCP, you must turn off DHCP service on your server and reconfigure your client computer to use a static IP address. You have already created a location for DHCP, so now you'll create a location for a static IP address.
- Use Server Admin to stop the DHCP services by clicking the Stop Service button in the toolbar.
- Click the Stop Now button on the confirmation dialog.
- On your Mac OS X computer, open System Preferences and choose the Network preferences pane.
You will now configure the client machine to have a static IP address, since DHCP is now turned off on the server. Your current location is called XSE Book, so you will need to create a new location.
- Choose Edit Locations from the Location pop-up menu, select XSE Book, and click Duplicate.
- Rename the duplicated location XSE Book Static and click Done.
- Choose XSE Book Static from the Location pop-up menu. Press Apply.
You may have already received a self-assigned address. These start with “169.254.” and are created by Mac OS X, not given out by Mac OS X Server.
- Choose Manually from the Configure IPv4 pop-up menu.
- Enter the following IP configuration:
IP Address: 10.1.17.2
Subnet Mask: 255.255.0.0
DNS Servers: 10.1.17.1
You will be configuring DNS services in the next section.
- Click Apply Now and close System Preferences.