DHCP (Dynamic Host Configuration Protocol)

1. Introduction to DHCP

Imagine having to manually assign an IP address, subnet mask, gateway, and DNS settings every time you connect to a network. That would be slow and error-prone!

Instead, DHCP is a protocol that automatically provides your device with all necessary network settings so you can connect instantly without worrying about configuration.

DHCP Client and DHCP Server Jobs in the network 1

What does DHCP provide?

When your device connects to a network, DHCP assigns:

  • An IP address (so your device can communicate)
  • A subnet mask (to define the network range)
  • A default gateway (so you can reach other networks, including the internet)
  • DNS servers (to resolve domain names like google.com into IP addresses)

This way, your device is fully configured without any manual input.

Devices such as computers, smartphones, and printers rely on DHCP to obtain their network settings effortlessly. Without it, managing network devices would be tedious and prone to misconfiguration.

Understanding DHCP in Action

The DHCP client (your device) sends a request to the DHCP server (typically your router or a dedicated DHCP server in larger networks).

DHCP Client request IP Address

The server assigns an IP address and other necessary network settings for a specific duration, known as a lease.

DHCP SERVER GIVE IP ADDRESS TP DHCP CLIENT

This process is automatic, but how can you verify that DHCP is working on your device? Let’s check.

Checking DHCP Settings on Your Device

Let’s follow these steps to verify that DHCP is enabled on my PC:

You can do the same task at home using your own device!

  1. First we need to Access the Control Panel in the windows search and then Navigate to the Network and Sharing Center.
Network and Internet DHCP Configuration Panel
  1. One there you can see the current connection. In my case, it’s labeled Ethernet 3 because I’m connected via an Ethernet cable.
  2. Click on Ethernet 3 Status and then on Properties.
Wi Fi Interface Port DHCP

4. In the list of properties, find Internet Protocol Version 4 (TCP/IPv4) and click on it.

Interface Ethernet IPv4 Proprieties

5. In the TCP/IPv4 properties window, you’ll see that both the IP address and DNS server settings are set to be obtained automatically—this is done by DHCP as you can see in the red circle.

DHCP Enabled Internet Protocol Version 4 TCP IP Properties

Our DHCP configuration can be view also by using command prompt !

Using the Command Prompt to Verify DHCP Settings

You can also verify DHCP settings using the command prompt with : ipconfig /all

C:\Users\PingMyNetwork>ipconfig /all

/Output Omitted/

Ethernet adapter Ethernet 3:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Realtek USB GbE Family Controller #2
   Physical Address. . . . . . . . . : 38-7C-76-11-B0-70
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.1.19(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, January 27, 2025 10:47:39 PM
   Lease Expires . . . . . . . . . . : Tuesday, January 28, 2025 10:47:39 AM
   Default Gateway . . . . . . . . . : 192.168.1.254
   DHCP Server . . . . . . . . . . . : 192.168.1.254
   DNS Servers . . . . . . . . . . . : 192.168.1.254
   NetBIOS over Tcpip. . . . . . . . : Enabled
   
/Output Omitted/

You need to search for your interface, in my case, it’s Ethernet adapter Ethernet 3 but it can be an Wi-Fi interface if your are using an Wi-Fi connection.

The first thing I want to highlight is the line that says DHCP enabled: Yes.

This indicates that when my computer connect to the network, it automatically requested its network configuration to an DHCP server.

Below this, you can see the network configuration details that were assigned by an DHCP server:

C:\Users\PingMyNetwork>ipconfig /all

/Output Omitted/

Ethernet adapter Ethernet 3:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Realtek USB GbE Family Controller #2
Physical Address. . . . . . . . . : 38-7C-76-11-B0-70
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.1.19(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Monday, January 27, 2025 10:47:39 PM
Lease Expires . . . . . . . . . . : Tuesday, January 28, 2025 10:47:39 AM
Default Gateway . . . . . . . . . : 192.168.1.254
DHCP Server . . . . . . . . . . . : 192.168.1.254
DNS Servers . . . . . . . . . . . : 8.8.8.8
NetBIOS over Tcpip. . . . . . . . : Enabled

/Output Omitted/

As you can see, we have the IPv4 address of my device which is 192.168.1.19.

The subnet mask is 255.255.255.0.

The default gateway is 192.168.1.254 and the DHCP server is also 192.168.1.254, which is my box that serves as both the default gateway and the DHCP server in one device.

I am using 8.8.8.8 as the DNS server.

C:\Users\PingMyNetwork>ipconfig /all

/Output Omitted/

Ethernet adapter Ethernet 3:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Realtek USB GbE Family Controller #2
   Physical Address. . . . . . . . . : 38-7C-76-11-B0-70
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 192.168.1.19(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Monday, January 27, 2025 10:47:39 PM
   Lease Expires . . . . . . . . . . : Tuesday, January 28, 2025 10:47:39 AM
   Default Gateway . . . . . . . . . : 192.168.1.254
   DHCP Server . . . . . . . . . . . : 192.168.1.254
   DNS Servers . . . . . . . . . . . : 8.8.8.8
   NetBIOS over Tcpip. . . . . . . . : Enabled
   
/Output Omitted/

The last important detail we need to highlight is the Lease Obtained and Lease Expires lines.

These indicate the duration for which the DHCP server assigns an IP address to a client.

Let’s break it down:

  • Lease Obtained: This is the date and time when the DHCP server assigned the IP address to the client.
    Example: Monday, January 27, 2025.
  • Lease Expires: This is the date and time when the assigned IP address is no longer valid for the client.
    Example: Tuesday, January 28, 2025.

When the lease expires:

  1. The IP address assigned to the client will return to the pool of available addresses on the DHCP server.
  2. The client must send a request to the DHCP server to renew or obtain a new IP address.

Why does this happen?

The lease time ensures that IP addresses are not assigned indefinitely. If a client stops using an address (it disconnects from the network or is offline for an extended period), the DHCP server can reclaim and reuse the IP address for another device. This helps efficiently manage the available IP address pool, especially on networks with many devices.

2. Understanding the DHCP Process

Okay, so in theory, we use a DHCP server to get our IP address and other parameters for our devices.

But how does the DHCP protocol work when we connect to a network?

Good question! Let’s break it down together:

DHCP Ports

The DHCP protocol uses specific ports to communicate:

  • The DHCP client communicates using UDP port 68.
  • The DHCP server listens on UDP port 67.
DHCP Ports Client and Server

Make sure you remember these ports for your CCNA exam!

By using these ports, the protocol follows 4 steps to provide your device with its IP configuration.

Let’s discover theses steps !

DHCP Discover

Step 1: The DHCP client asks if there is a DHCP server on the network that can provide it with an IP address.

Before DHCP Discover

To do this, the client sends out a DHCP Discover message.

DHCP Discover

Let’s take a closer look at this process in Wireshark:

DHCP DISCOVER WIRESHARK IMAGE

Notice that the DHCP DISCOVER is sent using a broadcast address (FF:FF:FF:FF:FF:FF) as the destination MAC address.

Why? Because the client doesn’t know the MAC address of the DHCP server—or even if a server exists! Similarly, the client doesn’t know the server’s IP address. That’s why it needs to broadcast the message to everyone on the network.

Here’s what’s happening in detail:

  • Source IP: 0.0.0.0 (Our PC doesn’t have an IP address yet, so it uses 0.0.0.0).
  • Destination IP: 255.255.255.255 (This is the broadcast IP address since the server’s DHCP IP is unknown).
  • The message travels by using UDP port 68 (client) to UDP port 67 (server).

DHCP Offer

Step 2: When a DHCP server hears the Discover message, it responds with a DHCP Offer. This Offer proposes an IP address to the client.

In our example, the server offers the IP address 192.168.1.11, along with additional details like the subnet mask, default gateway, and DNS servers.

DHCP Offer

Here’s what the DHCP Offer looks like in Wireshark:

DHCP OFFER WIRESHARK IMAGE

Let’s break it down:

  • The DHCP Offer is sent as a unicast to the client’s MAC address. The server learned this MAC address from the Discover message.
  • At the IP level, the destination IP is the proposed IP address for the client.

This time, the ports are reversed:

  • Source Port: UDP 67 (server).
  • Destination Port: UDP 68 (client).

The Your (Client) IP Address field in the DHCP Offer contains the proposed IP address (192.168.1.11 in this example) that the client can use.

Additionally, the DHCP Offer includes several important options, such as:

  • Option 51: Lease time.
  • Option 6: DNS servers.
  • Option 3: Default gateway.

DHCP Request

Step 3: After receiving the Offer, the DHCP client replies with a DHCP Request, asking the server to reserve the proposed IP address (192.168.1.11).

Here’s how it looks:

DHCP Request

In Wireshark:

DHCP REQUEST WIRESHARK IMAGE

Let’s break it down step by step:

  • Broadcast Communication: The DHCP Request is sent as a broadcast (destination MAC: FF:FF:FF:FF:FF:FF). This lets all DHCP servers on the network know that the client has chosen a specific server.
  • Key Details in the Message:
    1. Option 54: The client specifies the IP address of the chosen DHCP server 192.168.1.1 in this example).
      • “This is the DHCP server I’m talking to.”
    2. Option 50: The client requests the IP address 192.168.1.11, which was offered in the previous step.
      • “I would like to use this IP address, please!”
  • IP and Port Details:
    • Source IP: 0.0.0.0 (the client does not yet have an IP address).
    • Destination IP: 255.255.255.255 (broadcast IP Address).
    • Ports: The message travels from UDP 68 (client) to UDP 67 (server).

DHCP ACK

Step 4: Finally, the DHCP server sends a DHCP ACK (Acknowledgment) to confirm the lease of the IP address and configuration parameters.

DHCP Acknowledge

Here’s what the ACK looks like in Wireshark:

DHCP ACK WIRESHARK IMAGE

The DHCP ACK is the final step in the process. Once the client receives this message, it knows it’s authorized to use the assigned IP address (e.g., 192.168.1.11).

The ACK also repeats essential details like:

  • DNS servers
  • Default gateway
  • Lease duration

This message is sent as a unicast using the assigned IP address (192.168.1.11) and the destination MAC address of the client.

  • Source Port: UDP 67 (server).
  • Destination Port: UDP 68 (client).

At this stage, the client is fully configured and ready to communicate on the network!

DHCP CLIENT IS CONFIGURED

3. DHCP DORA

The DHCP process follows four key steps, known as the DORA sequence:

  • 1. Discover: The client searches for a DHCP server.
  • 2. Offer: The server responds with an offered IP address.
  • 3. Request: The client requests to lease the offered IP address.
  • 4. Acknowledge: The server confirms the lease, completing the process !
DHCP DORA PROCESS EXPLAINED

Take the time to fully understand each step—it’s great practice for your CCNA!

4. Conclusion

In this lesson, we explored how DHCP simplifies network management by automatically assigning IP addresses and other parameters. You learned about the DORA process (Discover, Offer, Request, Acknowledge), the ports used by DHCP (UDP 67 for the server and UDP 68 for the client), and how to verify DHCP settings on a device.

What’s Next?

In the next course, we’ll see how to configure a Cisco router as a DHCP server.

Get ready to put your knowledge into action!