How to Configure DHCP Relay Agent on Cisco Routers

This tutorial explains the DHCP relay agent configuration in detail. Learn how to use the 'ip helper-address' command to configure DHCP relay agents on Cisco routers through a packet tracer example.

Configuring a router's interface as a DHCP relay agent is much easier than you might think. To configure a router's interface as a DHCP relay agent, use the following command in interface configuration mode.

Router(config-if)#ip helper-address [ip-address-of-the-dhcp-server]

The 'ip helper-address' command tells the interface to forward the incoming DHCP message to the configured DHCP server. Use this command on all interfaces that are connected to the local subnets containing DHCP clients.

Before we take a practical example to understand how to use this command to configure a router's interface as the DHCP relay agent, I assume that you know how a DHCP relay agent functions. To learn what a DHCP relay agent is and how it works, please check the previous parts of this tutorial.

Packet tracer practice lab setup

  • Create a network that contains five subnets: 10.0.0.0/8, 20.0.0.0/8, 30.0.0.0/8, 40.0.0.0/8, and 50.0.0.0/8.
  • Add some hosts in each network except the fifth subnet. In the fifth subnet add a DHCP Server.
  • To connect subnets, use three routers: Router0, Router1, and Router2.
  • Connect subnets 10.0.0.0/8 and 20.0.0.0/8 to Router1's FastEthernet 0/0 and FastEthernet0/1 interfaces, respectively.
  • Connect subnets 30.0.0.0/8 and 40.0.0.0/8 to Router2's FastEthernet 0/0 and FastEthernet0/1 interfaces, respectively.
  • Connect the serial 0/0/0 interface of Router1 to the serial 0/0/0 interface of Router0. Use the subnet 192.168.1.0/252 for the IP configuration on this connection.
  • Connect the serial 0/0/1 interface of Router2 to the serial 0/0/1 interface of Router0. Use the subnet 192.168.4.0/252 for the IP configuration on this connection.
  • Configure RIP routing between routers and test connectivity between subnets.

The following image shows this network.

packet tracer lab for the practice of dhcp relay agent

Objective
  • Configure the hosts of the first four subnets to obtain IP addresses from the DHCP server that is available in the fifth subnet.
  • On the DHCP server, create four DHCP pools and assign one pool to each subnet.
  • Configure routers to act as DHCP relay agents.
Pre-created practice lab

Instead of replicating this lab, if you want to download and use the practice lab used in this tutorial, you can download it from the following link.

Packet Tracer LAB without configuration

Let's configure this lab and complete all the above-listed objectives step by step.

Assigning IP configuration

The following table lists all necessary commands to assign IP configuration on a router's interface.

Command Description (used for)
Router>enable To start the command prompt and to change the command mode to privileged-exec mode.
Router#configure terminal To navigate to global configuration mode.
Router(config)#interface [interface name] [interface number] To navigate to interface mode
Router(config-if)#ip address [ip address] [subnet mask] To set the IP address on the interface
Router(config-if)#clock rate 64000 To set the clock rate to 64000. (Use only if the interface is serial DCE)
Router(config-if)#bandwidth 64 To set the bandwidth to 64 (Use only if the interface is serial DCE)
Router(config-if)#no shutdown To enable the interface
Router(config-if)#exit To exit interface mode

If you want to learn more about the above commands, you can check the following tutorial.
RIP Protocol configuration Guide with Examples
This tutorial explains how to enable a Cisco router's interface and how to configure RIP routing on Cisco routers in detail.

Access the command prompt of each router and configure its interfaces as shown below.

Router0 IP configuration
Router>enable
Router#configure terminal
Router(config)#interface fastethernet 0/0
Router(config-if)#ip address 50.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/0
Router(config-if)#ip address 192.168.1.2 255.255.255.252
Router(config-if)#clock rate 64000
Router(config-if)#bandwidth 64
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/1
Router(config-if)#ip address 192.168.1.6 255.255.255.252
Router(config-if)#clock rate 64000
Router(config-if)#bandwidth 64
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#

The following image shows the above configuration on the packet tracer.

router 0 interface ip configuration

Router1 IP configuration
Router>enable
Router#configure terminal
Router(config)#interface fastethernet 0/0
Router(config-if)#ip address 10.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastethernet 0/1
Router(config-if)#ip address 20.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#

The following image shows the above configuration on the packet tracer.

router 1 ip configuration

Router2 IP configuration
Router>enable
Router#configure terminal
Router(config)#interface fastethernet 0/0
Router(config-if)#ip address 30.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastethernet 0/1
Router(config-if)#ip address 40.0.0.1 255.0.0.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface serial 0/0/1
Router(config-if)#ip address 192.168.1.5 255.255.255.252
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#

The following image shows the above configuration on the packet tracer.

router 2 interface ip configuration

Configuring RIP routing

The following table lists all necessary commands to configure RIP routing on a router.

Command Description (Used for)
Router>enable To enter privileged-exec mode
Router#configure terminal To enter global configuration mode
Router(config)#router rip To enable RIP routing and enter routing configuration mode
Router(config-router)#network [network] To add the locally available network to the list of networks that the RIP will advertise.
Router(config-router)#version 2 To use the RIP version 2.
Router(config-router)#no auto-summary To support the classless subnets or to disable the auto-summary feature.
Router(config-router)#exit To exit from routing configuration mode.

Access the CLI prompt of each router and configure RIP routing as shown below.

Router0
Router>enable
Router#configure terminal
Router(config)#router rip
Router(config-router)#network 50.0.0.0
Router(config-router)#network 192.168.1.0
Router(config-router)#network 192.168.4.0
Router(config-router)#version 2
Router(config-router)#no auto-summary
Router(config-router)#exit
Router(config)#

The following image shows the above configuration on the packet tracer.

rip routing configuration router 0

Router1
Router>enable
Router#configure terminal
Router(config)#router rip
Router(config-router)#network 10.0.0.0
Router(config-router)#network 20.0.0.0
Router(config-router)#network 192.168.1.0
Router(config-router)#version 2
Router(config-router)#no auto-summary
Router(config-router)#exit
Router(config)#

The following image shows the above configuration on the packet tracer.

rip routing configuration router 1

Router2
Router>enable
Router#configure terminal
Router(config)#router rip
Router(config-router)#network 30.0.0.0
Router(config-router)#network 40.0.0.0
Router(config-router)#network 192.168.1.4
Router(config-router)#version 2
Router(config-router)#no auto-summary
Router(config-router)#exit
Router(config)#

The following image shows the above configuration on packet tracer.

rip routing configuration router 2

Assigning static IP to DHCP server

Before we configure the DHCP service on the server, we have to assign a static IP address to the server.

To assign a static IP address to the server, click Server and click Config and click the interface that is connected to Router0's FastEthernet 0/0. In the IP configuration section, select the Static option, and set the IP address.

The following image shows this process.

static IP configuration dhcp server

Since the server is connected to the network through the Router0's FastEthernet 0/0 interface, we will set the IP address of Router0's FastEthernet 0/0 interface as the default gateway IP address on the server.

To set default gateway IP, click the Settings button in the left pane and choose the Static option in the IP configuration section of the right pane and set the IP address of the default gateway.

The following image shows this process.

setting default gateway IP on dhcp server

Enabling and Configuring DHCP Service on the Server

To enable DHCP service on the Server, click Server and click Services. In the left pane click DHCP and in the right pane select the 'On' option. This will enable the DHCP service.

DHCP service uses DHCP pools to provide IP addresses. A DHCP pool is a group of IP configurations that the DHCP server assigns to a specific subnet. We have to create pools equal to subnets. In our network, since we have four subnets, we have to create four pools.

If you don't know the DHCP pool and its options, please take a pause here and check the previous part of this article. For this tutorial, I assume that you know the DHCP pool and its options.

To create and add a pool, fill entries and click the Add button. Make sure that you add the correct default gateway IP in each pool. DHCP service uses the default gateway IP to identify the subnet.

The following image shows the entries for the first pool.

enabling dhcp service on dhcp server

The following image shows the entries for the second pool.

adding dhcp pool for network 20

The following image shows the entries for the third pool.

adding dhcp pool for network 30

The following image shows the entries for the fourth pool.

adding dhcp pool for network 40

The following image shows all the pools configured.

all pool configured on dhcp server

Configuring DHCP clients

To configure the device as a DHCP client, we need to select the DHCP option in its IP configuration. To do this, click the device and click Desktop and click the IP Configuration and select the DHCP option.

The following image shows how to set the DHCP option in the IP configuration section.

configure dhcp client

Set all PCs as DHCP clients by following the steps described above.

Configuring DHCP relay agents

We configure a DHCP relay agent only on the interface that is directly connected to a local subnet. In this network, four interfaces are directly connected to the local subnets. These interfaces are the following.

Router Interface Connected local subnet
Router1 Fa0/0 10.0.0.0/8
Router1 Fa0/1 20.0.0.0/8
Router2 Fa0/0 30.0.0.0/8
Router2 Fa0/1 40.0.0.0/8

To configure the above-listed interfaces as DHCP relay agents, use the 'ip helper-address' command as shown below.

Router1

Router>enable
Router#configure terminal
Router(config)#interface fastethernet 0/0
Router(config-if)#ip helper-address 50.0.0.10
Router(config-if)#exit
Router(config)#interface fastethernet 0/1
Router(config-if)#ip helper-address 50.0.0.10
Router(config-if)#exit
Router(config)#

The following image shows the above configuration.

ip helper-address command

Router2
Router>enable
Router#configure terminal
Router(config)#interface fastethernet 0/0
Router(config-if)#ip helper-address 50.0.0.10
Router(config-if)#exit
Router(config)#interface fastethernet 0/1
Router(config-if)#ip helper-address 50.0.0.10
Router(config-if)#exit
Router(config)#

The following image shows the above configuration.

ip helper-address command

Verifying DHCP relay

To verify that all DHCP relays are configured properly, check the IP configuration of their connected devices. To check the IP configuration of a client device, click the device and click the Desktop option and click the IP configuration. If the device shows the correct IP configuration, the DHCP relay is configured properly.

The following image shows this process.

verifying dhcp relay agent

If you prefer the command prompt, you can use the 'ipconfig' command to view the received IP configuration. The following image shows how to view IP configuration on PC2 at the command prompt.

verifying dhcp client dhcp relay agent

Configured practice lab

The following download link provides the configured LAB of this example.

Packet Tracer LAB with configuration

That's all for this part. In the next part of this tutorial, we will understand what the DHCP snooping is and how it works. If you like this tutorial, please don't forget to share it with friends through your favorite social channel.

ComputerNetworkingNotes CCNA Study Guide How to Configure DHCP Relay Agent on Cisco Routers