DHCP and Assigning IP Addresses

Eliminate the pain of installing an IP stack

Mark Minasi

July 31, 1996

6 Min Read
ITPro Today logo in a gray background | ITPro Today

If you have an IP-based network (if you don't yet, you will soon), you'veprobably discovered the painful part of putting an IP stack on everyone's PC.You have to type in arcane numbers like 206.83.41.13, provide the WindowsInternet Name Service (WINS) and Domain Name System (DNS) server locations,identify the domain name, and perform other tedious tasks for each PC. WindowsNT's Dynamic Host Configuration Protocol (DHCP) tool eliminates a lot of thisrunaround. (For details on DHCP, see John Enck, "Take A Number," WindowsNT Magazine, October 1995.)

To use DHCP, you set up an NT server as a DHCP server and give it a range ofIP addresses to assign. A PC with DHCP client software can then request an IPaddress from the DHCP server. The DHCP server hands out the next available IPaddress and can supply a subnet mask, WINS server, WINS node type (don't worryabout what it is, just set it to "8"), domain name, DNS server, anddefault gateway.

Suppose you set up a subnet with 100 PCs. You have addresses 200.123.100.15through 200.123.100.114 to give those PCs. You could go around andhardwire one IP address into each machine, but that's a lot of work. Instead,set up a DHCP server to distribute addresses and tell a machine that its subnetmask is 255.255.255.0, its WINS server is at 200.12.4.88, its WINS node type is8, its domain name is acme.com, its DNS server is at 184.33.82.14, and itsdefault gateway is 200.123.100.1.

Sound great? It is, in general. But be aware of a few wrinkles.

Setting up DHCP


To set up DHCP on an NT server, install the DHCP server in the usualplace--Control Panel, Network, Add Software. You have to reboot the NT server tomake it act as a DHCP server.

In the group Network Administration, you'll see a new program, DHCPManager. It's the central DHCP control tool. Once you set up the DHCP server,you need to create a scope--a pool of IP addresses. In my example, thescope is 200.123.100.15 to 200.123.100.114.

To create a new scope, go to the DHCP Manager menu and select Scope andthen Create. You can fill in the range of addresses, name the scope, and evenexclude particular addresses. For example, in my network, which is 199.34.57.0,I can safely use DHCP to give out all IP addresses because most of my PCs runclient software that supports DHCP. But I have a few fixed IP addresses: anIntegrated Services Digital Network (ISDN) Mac-layer bridge takes addressesending in .5 and .6, and some important servers take addresses ending in .50through .53. These fixed addresses aren't a problem. I could, for example, putall addresses from 199.34.57.2 through 199.34.57.254 into a scope and exclude.5, .6, and .50 through .53.

Understanding Your Lease


When you create a new scope, you need to specify a lease time--howlong an IP address is active. If you understand how a lease works, you'llunderstand some fundamentals about DHCP.

First, DHCP is a pull protocol--client-driven--rather than a pushprotocol--server-driven. The first time a DHCP client workstation comes up on anetwork, the client issues a broadcast seeking a DHCP server; this message is a"DHCP Discover." DHCP servers hear the workstation and respond byoffering IP addresses; this message is a "DHCP Offer." The workstationlooks through its offers and selects one (I'm not clear about how itselects. I've seen workstations turn down more-attractive leases in favor ofless-attractive leases). The workstation broadcasts back to the DHCP server thatit wants an offer; this message is the "DHCP Request."

Why is this third part of the DHCP sequence a broadcast rather than adirected communication to the DHCP server that offers the requested lease? Theworkstation sends a broadcast so all DHCP servers, including the requested DHCPserver, hear the message; by broadcasting its message to the DHCP server, theworkstation is saying to other DHCP servers, "Thanks for the offers, butI'm going with Server X."

Finally, the chosen DHCP server sends the lease information (the IPaddress, potentially a subnet mask, DNS server, WINS server, WINS node type,domain name, and default gateway) to the workstation in a message called theDHCP ACK (data communications jargon for acknowledge). You can remember the fourparts of a DHCP message by the mnemonic DORA--Discover, Offer, Request, and ACK.

Now we have a workstation with an IP address and a lease period. Forexample, let's say the PC has address 200.123.100.77 for three days.

Set a Lease Duration


Because DHCP is a client-driven protocol, once the DHCP server gives an IPaddress and other information to a client, the server can't take it back untilthe lease expires. Suppose you change the domain name from acme.com toapex.com. The workstations don't receive this new information until theyrenew their leases. This limitation illustrates why I call this protocol a pullprotocol rather than a push protocol--the DHCP server has no way to sayto itself, "Well, I have this new domain name; let me contact200.123.100.77 and make it change its domain name."

I encountered this problem when I set up my first DHCP server years ago.Thinking to make my life easier, I set the lease durations to "infinite."But, later, I needed to change my domain structure. I added some DNS servers anda default gateway address and divided my C network into four subnets. I had noproblem rearranging DHCP to accommodate these changes. I changed the DHCPManager and went to the Control Panel to stop the DHCP server and restart it.(Don't forget this step when you make changes to your DHCP servers.)

Soon I realized that none of my changes were in effect. The problem wasthat my workstations obtained IP addresses from DHCP with infinite leases, whichtold them, "You have this lease forever; you never have to check with meagain." This situation seemed strange. I assumed that when a DHCP clientboots, it checks with the DHCP server. After all, how else does the workstationknow its IP address, subnet mask, and the like?

What I was missing was this: If your PC is a DHCP client, it keeps itslease information on its local hard disk. When the PC boots, it looks atthe lease information. If that information says, "Use IP addresssuch-and-such and subnet mask such-and-such, and you can use this until summer2031," the workstation doesn't have to check with the DHCP server.And it doesn't.

I emailed my users, telling them to open up a command prompt window andtype two commands: ipconfig /release and ipconfig/renew. Ipconfig/renew shouldbe sufficient, but it isn't. I often see DHCP not working properly--it getsstuck on something and stops working. The two ipconfig commands usuallystraighten it out. For Windows 95, don't use ipconfig; rather, use winipcfg,which is a GUI version of ipconfig.

If the ipconfig or winipcfg commands don't work, go to each workstation,and erase the local DHCP information. On a DOS or Windows for Workgroupsmachine, the file is dhcp.bin. On a Win95 machine, the DHCP information is inthe Registry inhkey_local_machinesystemcurrentcontrolsetservicesvxddhcpdhcpinfoxx,where xx is two digits. You can have multiple leases, and the two digitsaccommodate that capability. In NT, seehkey_local_machinesystemcurrentcontrolsetservicesetcardnameparameterstcpip.(Netcard name will be something like E159x.)

Back Issues


I get email from people who want me to send them my old columns. Thanks forthe interest. You can contact Windows NT Magazine customer service at800-793-5712 or 970-663-4700 for back issues. Read past columns on WindowsNT Magazine's Web site at http://www.winntmag.com.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like