Config Lab: DHCP Relay

Wendell Odom
By Wendell Odom October 8, 2021 09:05

Most DHCP servers sit in a centralized location. To make that work, routers need to participate in the DHCP process to a small degree using a feature called the DHCP Relay Agent. For this lab, you think about a classic case of using DHCP Relay Agent and build the configuration required to enable it in the correct places.

All about Config Labs

The blog has a series of lab exercises called “Config Labs.” Each lab presents a topology with the relevant initial configuration for each device. The lab also lists new requirements, after which you should create the additional configuration to meet those requirements. You can do the lab on paper, in a text editor, or use software tools like Cisco Packet Tracer or Cisco Modeling Labs.

Once you have created your answer, you can click various tabs at the bottom of this post to see the lab answers, comments about the lab, and other helpful information.

The Lab Exercise

Lab Requirements

This lab focuses on DHCP, specifically the DHCP Relay Agent feature of Cisco routers. To that end, the lab begins with all routers working for all features except DHCP Relay Agent. Specifically, all routers have IPv4 addresses configured on the interfaces shown in Figure 1, all running OSPF, and all learning all routes. If implemented, all routers would be able to ping all IP addresses on the other routers.

The lab also assumes that a DHCP Server is preconfigured. If you want to build this in your lab, you can, and you can even use a Cisco router as the DHCP server. The initial configurations below include the DHCP Server configuration on a router that would support this lab exercise. That configuration:

    1. Removes the first 100 addresses in each subnet from the DHCP pool so that the range of leased addresses begins with the fourth octet of .101.
    2. Sets the correct default gateway in each subnet.

The lab asks you to make the DHCP Clients work by deciding where to configure the DHCP Relay feature and then configuring that feature. The three PCs in the figure act as DHCP clients. The specific steps for this lab are as follows:

    1. Examine the initial configuration and topology while thinking about the DHCP Relay feature. Ask yourself:
      1. Should any DHCP Clients work without any DHCP Relay Agent configuration? If so, which ones?
      2. Do any DHCP Clients need the DHCP Relay Agent feature to work? If so, which ones?
      3. Plan your DHCP Relay Agent configuration.
    2. Once planned, create the DHCP Relay Agent configuration.
    3. If implementing in real gear, Cisco Packet Tracer, CML, or any other environment, check to ensure all three PCs lease an IP address.

Figure 1: Network for this Lab


Initial Configuration

Examples 1, 2, and 3 show the initial IP addresses and OSPF configuration on the three routers. Note that none of the routers have any DHCP-related configuration.

Example 1: R1 Initial Configuration


Example 2: R2 Initial Configuration


Example 3: R3 Initial Configuration


Example 4 shows how you could configure a router to act as a DHCP server. However, you do NOT need to understand the configuration in Example 4 before doing this lab. In the example, the first few configuration lines give the router IP connectivity and enable OSPF to communicate. Most of the configuration creates the DHCP server.

Example 4: Cisco Router as DHCP Server

Answer Options - Click Tabs to Reveal

You can learn a lot and strengthen real learning of the topics by creating the configuration – even without a router or switch CLI. In fact, these labs were originally built to be used solely as a paper exercise!

To answer, just think about the lab. Refer to your primary learning material for CCNA, your notes, and create the configuration on paper or in a text editor. Then check your answer versus the answer post, which is linked at the bottom of the lab, just above the comments section.

You can also implement the lab using the Cisco Packet Tracer network simulator. With this option, you use Cisco’s free Packet Tracer simulator. You open a file that begins with the initial configuration already loaded. Then you implement your configuration and test to determine if it met the requirements of the lab.

(Use this link for more information about Cisco Packet Tracer.)

Use this workflow to do the labs in Cisco Packet Tracer:

  1. Download the .pkt file linked below.
  2. Open the .pkt file, creating a working lab with the same topology and interfaces as the lab exercise.
  3. Add your planned configuration to the lab.
  4. Test the configuration using some of the suggestions below.

Download this lab’s Packet Tracer File

You can also implement the lab using Cisco Modeling Labs – Personal (CML-P). CML-P (or simply CML) replaced Cisco Virtual Internet Routing Lab (VIRL) software in 2020, in effect serving as VIRL Version 2.

If you prefer to use CML, use a similar workflow as you would use if using Cisco Packet Tracer, as follows:

  1. Download the CML file (filetype .yaml) linked below.
  2. Import the lab’s CML file into CML and then start the lab.
  3. Compare the lab topology and interface IDs to this lab, as they may differ (more detail below).
  4. Add your planned configuration to the lab.
  5. Test the configuration using some of the suggestions below.

Download this lab’s CML file!


Network Device Info:

This table lists the interfaces listed in the lab exercise documentation versus those used in the sample CML file.

Device Lab Port  CML Port
SW1 F0/1 G0/0
R1 G0/0/0 G0/2
R1 G0/1/0 G0/3
R2 G0/0/0 G0/1
R3 G0/0/0 G0/1

Lab Answers Below: Spoiler Alert

Lab Answers: Configuration (Click Tab to Reveal)

Lab Configuration

Figure 1: Network for this Lab


Example 1: R2 Config


Example 2: R3 Config

Commentary, Issues, and Verification Tips (Click Tabs to Reveal)

Lab Commentary

Networks need the DHCP Relay Agent feature to support clients that reside in a different subnet than the DHCP server. In this lab, PC1 resides in the same subnet as the DHCP server, so that subnet does not need a DHCP Relay Agent. However, PC2 and PC3 reside in other subnets, so at least one router in each subnet must provide the DHCP Relay Agent function.

A router needs the ip helper-address command on the interface connected to the subnet to implement the DHCP Relay Agent. This command needs to refer to the unicast IP address of the DHCP server, in this case, Those combinations of facts mean that router R1 needs no additional configuration, but both R2 and R3 need the ip helper-address command under their LAN interfaces.

The Relay Agent feature tells a router to listen for IP broadcasts entering the interface (packets with destination addresses like and to change the destination address of the packet – and then forward the packet. Figure 2 shows the idea following the numbered steps in the figure. PC2 sends a DHCP message, for instance, and DHCP Discover message, as a local subnet broadcast (destined to address  The DHCP Relay Agent feature causes router R2 to notice the packet and change the packet’s destination to the configured address. At step 3, R2 routes the packet just like any other unicast packet.

Figure 2: Relay Agent Logic from R2’s Subnet

Known Issues in this Lab

This section of each Config Lab Answers post hopes to help with those issues by listing any known issues with Packet Tracer related to this lab. In this case, the issues are:

# Summary Detail
1 None No known issues related to this lab.


Why Would Cisco Packet Tracer Have Issues?

(Note: The below text is the same in every Config Lab.)

Cisco Packet Tracer (CPT) simulates Cisco routers and switches. However, CPT does not run the same software that runs in real Cisco routers and switches. Instead, developers wrote CPT to predict the output a real router or switch would display given the same topology and configuration – but without performing all the same tasks, an actual device has to do. On a positive note, CPT requires far less CPU and RAM than a lab full of devices so that you can run CPT on your computer as an app. In addition, simulators like CPT help you learn about the Cisco router/switch user interface – the Command Line Interface (CLI) – without having to own real devices.

CPT can have issues compared to real devices because CPT does not run the same software as Cisco devices. CPT does not support all commands or parameters of a command. CPT may supply output from a command that differs in some ways from what an actual device would give. Those differences can be a problem for anyone learning networking technology because you may not have experience with that technology on real gear – so you may not notice the differences. So this section lists differences and issues that we have seen when using CPT to do this lab.

Beyond comparing your answers to this lab’s Answers post, you can test in Cisco Packet Tracer (CPT) or Cisco Modeling Labs (CML). In fact, you can and should explore the lab once configured. For this lab, once you have completed the configuration, try these verification steps. 

  1. Confirm that PC2 and PC3 successfully lease an address using DHCP.
    1. From the PC2 and PC3 command prompt, use the ipconfig /all command to display the current IPv4 settings.
    2. If the PCs do not have an address from their respective and subnets, then use the ipconfig /release and ipconfig /renew commands to force a new attempt for a DHCP lease.
  2. Confirm PC2 and PC3 can send packets:
    1. Discover PC1’s IP address.
    2. From both PC2 and PC3, use the ping command to ping PC1’s IP address.


More Labs with Related Content!

Config Lab: Basic Port Security 4
Config Lab: Router as DHCP Client
Wendell Odom
By Wendell Odom October 8, 2021 09:05
Write a comment


  1. Maroof Hossain November 23, 08:10

    Hi, in the packet tracer file, router 2 and 3 already have a DHCP relay agent configured.

    Reply to this comment
    • certskills November 30, 13:35

      Whoops. Kinda spoils the lab!
      I updated the .pkt file and replaced it so that it should be fixed for the future. Thanks for letting me know!

      Reply to this comment
View comments

Write a comment

Comment; Identify w/ Social Media or Email