Dynamic Host Configuration Protocol (DHCP)
In this lesson, we'll discuss how IP addresses are assigned to devices on the network.
We'll cover the following
Introduction
In the early days of the Internet, IP addresses were manually configured on both hosts and routers and almost never changed. However, this manual configuration can be complex and often causes errors that can be difficult to debug.
To ease the attachment of hosts to subnets, most networks now support the Dynamic Host Configuration Protocol (DHCP) RFC 2131. DHCP allows a host to automatically retrieve its assigned IPv4 address. A DHCP client actually can retrieve other network parameters too, including subnet mask, default gateway and DNS server addresses from the DHCP server.
How It Works
-
A DHCP server is associated with the subnet to which it is connected. Routers do not forward DHCP traffic from one subnet to another.
-
Each DHCP server manages a pool of IPv4 addresses assigned to the subnet.
-
When a host is first attached to the subnet, it sends a DHCP request message in a UDP segment to the DHCP server (the DHCP server listens on port 67).
-
As the host knows neither its own IPv4 address nor the IPv4 address of the DHCP server, this UDP segment is sent inside an IPv4 packet whose source and destination addresses are and respectively.
-
The DHCP request may contain options such as the data link layer address of the host.
-
-
The server captures the DHCP request and selects an unassigned address in its address pool.
-
It then sends the assigned IPv4 address in a DHCP reply message which contains:
- The data link layer address of the host and additional information such as
- The subnet mask of the IPv4 address
- The address of the default router or the address of the DNS resolver.
- The DHCP reply also specifies the lifetime of the address allocation. This forces the host to renew its address allocation once it expires.
- The data link layer address of the host and additional information such as
-
This DHCP reply message is sent in an IPv4 packet whose source and destination addresses are respectively the IPv4 address of the DHCP server and the broadcast address.
-
Thanks to the limited lease time, IP addresses are automatically returned to the pool of addresses when hosts are powered off. This reduces the waste of IPv4 addresses. Furthermore, the IP has to be renewed with the server every so often.
Have a look at the following slides to see how an IP address is retrieved from a DHCP server. Note however, that the DHCP request response is an abstraction that we have created here. The DHCP protocol specifies several messages and their formats to do its job. For example, a DHCP server makes an offer for address assignment to a client, which the client may or may not accept. So, there are “Offers," “Acks” and “Nacks” etc.
Get hands-on with 1400+ tech skills courses.