Windows DevCenter    
 Published on Windows DevCenter (http://www.windowsdevcenter.com/)
 See this if you're having trouble printing code examples


Implementing and Understanding DHCP

by Chris Sanders
06/12/2007

The Dynamic Host Configuration Protocol (DHCP) is a member of the TCP/IP suite and a protocol that is designed to save network administrators a lot of time and effort. A successful DHCP implementation can do just that.

As you probably already know, every computer that communicates on a network does so via an IP (layer 4) address. The goal of DHCP is to provide a mechanism of automated address delivery, to give every computer its own IP address without an administrator having to type them all in manually. In small networks, this isn't too big of an issue. However, in networks with tens, hundreds, and even thousands of computers, the task of IP address management is daunting. Luckily, Windows Server 2003 provides a means for us to implement DHCP with its own DHCP server service (see Figure 1).

Figure 1
Figure 1. DHCP Servers assign computers IP addresses from a user-specified range

Planning for DHCP

The first stage to any technical implementation is planning. Here are a few key things to consider when thinking about DHCP:

Installing DHCP

The DHCP server service is built into the Windows Server 2003, and can be installed during the initial operating system installation or afterward from the Configure Your Server wizard. We will assume you are installing DHCP on a pre-existing Windows Server 2003 machine.

Begin by accessing the Configure Your Server dialog, either as it appears when you first log in or from the control panel. In this window, select "DHCP Server" from the list of server roles and click "Next." This begins the installation process by bringing up the New Scope Wizard. A scope is a range of IP addresses configured on a DHCP server. In this scenario we will configure a scope of IP addresses for our DHCP server to hand out to the sales department of our example company. As you can see in Figure 2, the first screen of this wizard is where you create a name of this scope. Coming up with a descriptive naming scheme for your DHCP scopes is crucial, especially if you are setting up several scopes on one server. After entering the name and description for your scope, click "Next."

Figure 2
Figure 2. Creating a name and description for a DHCP scope

The following screen will prompt you for the addressing information of the scope (Figure 3); that is, the range of IP addresses to be distributed and the subnet mask the network is configured for. As stated earlier, calculating subnets is a little beyond the scope of this article, but this is something you should consider and plan out well before actually setting up your DHCP server.

Figure 3
Figure 3. Configuring the IP addresses to be handed out by this DHCP scope

The next window is where you enter any exclusions to the range of IP addresses you entered in the previous step. These exclusions are IP addresses that you do not want the DHCP server to hand out in the range specified. This is where planning ahead for static IP assignments (as mentioned earlier) comes in handy. For example, if the sales department's router has an IP address of 192.168.0.1, you'll want to make sure to exclude this from the DHCP scope (Figure 4).

Figure 4
Figure 4. Adding exclusions is crucial to preventing IP conflicts in DHCP networks

The next screen you will come upon is the Lease Duration dialog. Here you configure the amount of time for a standard DHCP lease (Figure 5). If you did your planning properly, you should already have an idea of what you want this to be. If you are not running any services that have an effect on DHCP leases, and you don't have a large makeup of mobile clients, then it is usually a good idea to just accept the default value.

Figure 5
Figure 5. Setting the IP lease duration

After you have configured lease duration, you will be prompted to configure any additional network settings. If you wish, this is where you can choose to enter default gateway, DNS server, and WINS server addresses to be distributed to network clients. Once you have completed these additional steps, you will come to the end of the New Scope Wizard, where you are prompted to activate the scope. Doing this will cause the DHCP server to begin answering DHCP discovery requests.

Configuring Additional DHCP Settings

Once you have completed setup of your first DHCP scope, you can then make changes to DHCP server and scope options from the DHCP MMC snap-in, accessible through the servers' administrative tools. There are a couple of tasks that you will commonly do from this snap-in that we will cover here.

The first of these is adding exclusions. Although we did this in our initial setup, there are often occasions where new devices are installed that require a static IP address. Whenever this happens, you will want to make sure you create an exclusion for the device. To do this, find the scope the exclusion falls under in the left pane of the DHCP snap-in and expand it. Right-click "Address Pool" and select "Add Exclusion Range." From here, type in the address or address range and click "Add" (Figure 6).

Figure 6
Figure 6. Adding exclusions from the DHCP MMC snap-in

The second thing that you may find yourself doing often from the DHCP snap-in is creating IP reservations. For whatever reason, you may want a client workstation to receive its address from the DHCP server, but keep the same address regardless. DHCP allows for this by tying the devices MAC (layer 2) address to an IP address in order to create a reservation of an IP address by that device. To create a reservation, you must once again expand the scope the reservation will reside under in the left pane of the MMC snap-in. After doing this, right click "Reservations," and click "New Reservation." On this screen (Figure 7), you must enter a name for the reservation, the MAC address of the network interface card on the client, the IP address you want to reserve for it, a description for the reservation, and whether or not the reservation supports DHCP and BOOTP. It is a best practice to come up with a standardized naming scheme for your IP reservations that is simple and descriptive.

Figure 7
Figure 7. Creating an IP reservation

Conclusion

It doesn't take a genius to realize how much work it would require to manually assign and manage IP addresses for even a small-sized network. That being the case, DHCP is the best logical option for automated address deployment. The Windows Server 2003 implementation of DHCP server is just the ticket and provides a solution that is both easy to configure and to manage.

Chris Sanders is the network administrator for one of the largest public school systems in the state of Kentucky. For more about Chris, you can view his personal blog at http://www.chrissanders.org.


Return to Windows DevCenter.

Copyright © 2009 O'Reilly Media, Inc.