Tutorial: Dynamic IP Addresses and DHCP

IP addresses may be static or dynamic.

Static means that the address assigned to a machine generally does not change. Dynamic means that an IP address is assigned to a computer on demand, for a fixed lease period. The computer may be assigned a different address each time it demands one.

Dynamic addresses are acceptable for a machine running client software, since the way things are organized is that the client initiates communications with a server, and includes its "return address" (the source IP address) in every packet sent to the server.

To communicate to a server, it is necessary to find out the numeric IP address of the server before the client can communicate to it. That is often accomplished through the Domain Name System (DNS), essentially tables where the IP address of a server can be looked up. To avoid having to frequently update those tables, servers are generally assigned static addresses.

dhcp discover
DHCP Discover Message

Addresses are assigned to a computer using the Dynamic Host Configuration Protocol (DHCP). The system administrator provisions a DHCP server, configured to assign IP addresses within a defined range to clients. Computers are loaded with DHCP client software.

Communications between the DHCP client and server are effectively application-layer messages, coded into ASCII and carried in UDP protocol data units, which are carried in IP packets, which are carried in MAC frames.

The desired recipient of the messages is indicated as being the DHCP on a machine by populating in the UDP header destination port = 67 for messages to the server and destination port = 68 for messages to the client.

The messages are "broadcast", which means that the destination IP address is all 1s and destination MAC address is all 1s. The actual addresses are used for source MAC and IP addresses, except that the client uses "0" as its IP address, since of course the whole point of the exercise is to get an IP address.

Each computer will run a DHCP client when it starts, generating a DHCP Discover message as illustrated above.

Any DHCP server that receives it, and there may be more than one, will respond with a DHCP Offer message, with an offered IP address and a lease time:

dhcp offer
DHCP Offer Message

The client will answer with a DHCP Request message to confirm its selection of an offered address:

dhcp request
DHCP Request Message

Then the server will complete the cycle with a DHCP ACK that usually includes other configuration information such as the IP address of the default gateway (CE router), the IP address of one or more DNS servers and the subnet mask, which indicates what bits in the address are the host or machine ID:

dhcp ack
DHCP ACK Message

There are several variations on the basic process, all of which are enumerated in the relevant standards document, RFC 2131.

On expiry of the lease time, the DHCP client must begin the discover process anew. If a DHCP client runs while still holding a valid lease, it will request to be assigned the same IP address. If there are many clients constantly running DHCP (an ISP's customers, for example), then it is likely that a different IP address will be offered by the server each time a computer runs its DHCP client.

The lease time may be configured by the system administrator to any value. This function might be useful to help manage situations where there are more clients than addresses. If the DHCP server reaches the end of its configured range of addresses, it attempts to re-assign previously-assigned addresses to new requestors, beginning with those previously-assigned addresses for which the lease has expired. Before re-assigning the address to a different machine, the server might optionally ping the address to determine if it is still in use.

Even though it is the "dynamic" host configuration protocol, DHCP is also used to assign static addresses to machines.

This is accomplished with a table in the server, configured by the system administrator, which relates MAC addresses to IP addresses.

Whenever a computer with a MAC address contained in the table asks for an IP address, it will always be assigned the IP address specified in the table.

This allows the assignment of static addresses to computers from a centralized management system (the DHCP server), conveyance of other information like default gateway and netmask, and eliminates the need for any human involvement (and its associated errors) in configuring computers.

In Windows, you can see the IP address currently assigned to a computer, as well as its LAN card MAC address by opening the Network Connections folder and viewing the "status" of the LAN card.

If under "properties" of the TCP/IP protocol the choice "obtain a network address automatically" is selected, the DHCP client is run at startup and when "repair this connection" is clicked.

Join thousands of satisfied customers including the FBI Training Academy, US Marine Corps Communications School, US Army, Navy, Air Force and Coast Guard, CISA, DISA, DoJ NSD, NSA and CIA, IRS, FAA, DND, CRA, CRTC, RCMP, banks, power companies, police forces, manufacturers, government, local and regional telcos, broadband carriers, individuals, telecom planners and administrators, finance, tax and accounting personnel and many more from hundreds of companies.

Benefit from decades of knowledge, insight and experience distilled into clear lessons designed for non‑engineers, logically organized to build one concept on another... in plain English. Teracom's GSA Contract supplying this training to the US government reflects approved quality and value that you can depend on.

we provide training to at&t             we provide training to verizon             we provide training to Bell Canada             microsoft             we provide training to intel             we provide training to cisco             GSA contract holder - pre-approved pricing and quality - supplier to the US Government             cox cable