PTL-0012 Network Services

Configuring Cisco IOS DHCPv4 Server and Relay Agent

Configure an enterprise Cisco router as a DHCPv4 server with excluded addresses, network pools, default routers, and DNS parameters, and configure an IP helper-address relay agent across routed interfaces.

Level
Intermediate
Time
40 min
Packet Tracer
8.2+
Simulator
Tested in Packet Tracer
You configure
R1, R2, S1, S2
Last reviewed

Packet Tracer files for Configuring Cisco IOS DHCPv4 Server and Relay Agent

FILES Packet Tracer topology

Download starter file

starter.pkt, 61 KB. Open it in Cisco Packet Tracer 8.2+. Install Packet Tracer.

Solution / reference file

The completed topology with every task configured. Try the lab first and use this to check your work or when you are stuck.

Download solution file

completed.pkt, 62 KB.

File checksums (SHA-256)
starter.pkt
86dd4eb12b2edd58a2461db2ac7c2b0f5cc5680556efa56ca693dd63b65bdc56
completed.pkt
5847222d3a727d248fdccf2bcb04d6fc554e48a1a697e89b53b0f03e055e9d43

Part of BSIT Networking Curriculum Learning Path (step 35 of 56) and CCNA-Aligned Topical Study Path (step 35 of 56).

Category: network-services · Difficulty: intermediate · Lab ID: PTL-0012 · Document: reviewed · Simulator: tested pass

Manually configuring static IP addresses on hundreds of client workstations is prone to typographical errors, address conflicts, and heavy administrative overhead. The Dynamic Host Configuration Protocol (DHCP) automates the assignment of IPv4 addresses, subnet masks, default gateways, and DNS server settings. In enterprise environments, a Cisco router can serve directly as a DHCP server for attached subnets. Furthermore, when DHCP clients reside on a remote network across a router, the router can act as a DHCP Relay Agent using the ip helper-address command to forward broadcast DHCP discovery messages to a centralized DHCP server.


Learning Objectives#

  • Explain the 4-step DHCPv4 client-server message exchange: Discover, Offer, Request, and Acknowledgment (DORA).
  • Configure IPv4 address exclusions (ip dhcp excluded-address) to protect statically assigned gateways and servers.
  • Configure Cisco IOS DHCP pools with network subnets, default routers, and domain name system (DNS) servers.
  • Configure ip helper-address on router interfaces to relay broadcast DHCP traffic across Layer 3 boundaries.
  • Inspect active IP address leases using show ip dhcp binding and monitor pool utilization with show ip dhcp pool.

Prerequisites#

  • Understanding of IPv4 addressing and default gateway configuration.
  • Familiarity with Cisco IOS router interface configuration.
  • Cisco Packet Tracer 8.0 or newer.

Topology#

PTL-0012 Topology Diagram
PTL-0012 Topology Diagram

The topology models an enterprise branch office connected across a routed WAN link to a centralized corporate headquarters (HQ). Router R2 acts as the centralized Cisco IOS DHCP server managing address pools for both locations. Router R1 acts as the Branch Gateway and DHCP Relay Agent, utilizing ip helper-address to relay client broadcast DHCP requests across the routed transit link to R2:

[PC-Client-1]──Fa0 ───── Gi0/1──[Switch S1]──Gi0/2 ───── Gi0/0/0──[Router R1]
(Branch Client: DHCP)            (Branch Access)                   (Branch Gateway & DHCP Relay)
                                                                       │ Gi0/0/1 (10.0.0.1/30)
                                                                       │ (Routed WAN Link)
                                                                       │ Gi0/0/1 (10.0.0.2/30)
[PC-Client-2]──Fa0 ───── Gi0/1──[Switch S2]──Gi0/2 ───── Gi0/0/0──[Router R2]
(HQ Client: DHCP)                (HQ Access)                       (HQ Gateway & IOS DHCP Server)
Device Name Model Interface Connected Device Neighbor Interface Network Subnet
R1 ISR 4321 GigabitEthernet0/0/0 Switch S1 GigabitEthernet0/2 192.168.10.0/24 (Branch LAN)
R1 ISR 4321 GigabitEthernet0/0/1 Router R2 GigabitEthernet0/0/1 10.0.0.0/30 (WAN Transit)
R2 ISR 4321 GigabitEthernet0/0/0 Switch S2 GigabitEthernet0/2 192.168.20.0/24 (HQ LAN)
R2 ISR 4321 GigabitEthernet0/0/1 Router R1 GigabitEthernet0/0/1 10.0.0.0/30 (WAN Transit)
Switch S1 2960-24TT GigabitEthernet0/1 PC-Client-1 FastEthernet0 Access Port (Branch LAN)
Switch S1 2960-24TT GigabitEthernet0/2 Router R1 GigabitEthernet0/0/0 Uplink to R1
Switch S2 2960-24TT GigabitEthernet0/1 PC-Client-2 FastEthernet0 Access Port (HQ LAN)
Switch S2 2960-24TT GigabitEthernet0/2 Router R2 GigabitEthernet0/0/0 Uplink to R2

Addressing Table#

Device Interface IPv4 Address Subnet Mask DHCP Pool Name Address Range Assigned
R1 Gi0/0/0 192.168.10.1 255.255.255.0 N/A (ip helper-address 10.0.0.2) Default Gateway for Branch LAN
R1 Gi0/0/1 10.0.0.1 255.255.255.252 N/A Transit Link to R2
R2 Gi0/0/0 192.168.20.1 255.255.255.0 HQ_POOL Default Gateway for HQ LAN
R2 Gi0/0/1 10.0.0.2 255.255.255.252 N/A Transit Link to R1
PC-Client-1 FastEthernet0 DHCP Assigned 255.255.255.0 BRANCH_POOL (via Relay) Gateway: 192.168.10.1, DNS: 208.67.222.222
PC-Client-2 FastEthernet0 DHCP Assigned 255.255.255.0 HQ_POOL (Direct) Gateway: 192.168.20.1, DNS: 208.67.222.222

Lab Tasks#

  1. Cable the topology in Packet Tracer according to the port assignment table.
  2. Configure IP addresses and routing on Router R1 and Central Router R2.
  3. Configure DHCP address exclusions on Central Router R2 to protect .1 through .10 on both subnets.
  4. Configure DHCP pool BRANCH_POOL on R2 with default gateway 192.168.10.1 and DNS server 208.67.222.222.
  5. Configure DHCP pool HQ_POOL on R2 with default gateway 192.168.20.1 and DNS server 208.67.222.222.
  6. Configure ip helper-address 10.0.0.2 on R1 interface Gi0/0/0 to enable DHCP Relay.
  7. Switch PC-Client-1 and PC-Client-2 from Static to DHCP in Packet Tracer desktop settings.
  8. Verify that both client PCs successfully lease IPv4 configuration parameters via the DORA process.
  9. Inspect active leases on Central Router R2 using show ip dhcp binding and pool utilization using show ip dhcp pool.

Configuration Walkthrough#

1. Central Router R2 Configuration (IOS DHCP Server)#

Connect to Router R2 CLI and configure IP addresses, static routes, exclusions, and pools:

Router> enable
Router# configure terminal
Router(config)# hostname R2

! Exclude statically assigned IP addresses before pool creation
! Exclude .1 through .10 on Branch Subnet (protects gateway R1 Gi0/0/0 and future static hosts)
R2(config)# ip dhcp excluded-address 192.168.10.1 192.168.10.10

! Exclude .1 through .10 on HQ Subnet (protects gateway R2 Gi0/0/0 and management devices)
R2(config)# ip dhcp excluded-address 192.168.20.1 192.168.20.10

! Configure DHCP Pool for Remote Branch LAN (Serviced via R1 Relay Agent)
R2(config)# ip dhcp pool BRANCH_POOL
R2(dhcp-config)# network 192.168.10.0 255.255.255.0
R2(dhcp-config)# default-router 192.168.10.1
R2(dhcp-config)# dns-server 208.67.222.222
R2(dhcp-config)# domain-name lab.local
R2(dhcp-config)# exit

! Configure DHCP Pool for Local HQ LAN
R2(config)# ip dhcp pool HQ_POOL
R2(dhcp-config)# network 192.168.20.0 255.255.255.0
R2(dhcp-config)# default-router 192.168.20.1
R2(dhcp-config)# dns-server 208.67.222.222
R2(dhcp-config)# domain-name lab.local
R2(dhcp-config)# exit

! Configure Routed Transit Interface to Branch Router R1
R2(config)# interface GigabitEthernet0/0/1
R2(config-if)# description Routed Transit Link to R1
R2(config-if)# ip address 10.0.0.2 255.255.255.252
R2(config-if)# no shutdown
R2(config-if)# exit

! Configure HQ Local LAN Interface
R2(config)# interface GigabitEthernet0/0/0
R2(config-if)# description HQ Client LAN
R2(config-if)# ip address 192.168.20.1 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)# exit

! Static Route returning traffic to Remote Branch Subnet via R1
R2(config)# ip route 192.168.10.0 255.255.255.0 10.0.0.1
R2(config)# end
R2# copy running-config startup-config

2. Branch Router R1 Configuration (DHCP Relay Agent)#

Connect to Router R1 CLI and configure IP addresses, static routes, and the ip helper-address:

Router> enable
Router# configure terminal
Router(config)# hostname R1

! Configure Interface for Branch Client LAN with DHCP Relay
R1(config)# interface GigabitEthernet0/0/0
R1(config-if)# description Branch Client LAN
R1(config-if)# ip address 192.168.10.1 255.255.255.0
! Relay client DHCP broadcast requests as unicast to Central DHCP Server R2
R1(config-if)# ip helper-address 10.0.0.2
R1(config-if)# no shutdown
R1(config-if)# exit

! Configure Interface for Routed Transit Link to R2
R1(config)# interface GigabitEthernet0/0/1
R1(config-if)# description Routed Transit Link to R2
R1(config-if)# ip address 10.0.0.1 255.255.255.252
R1(config-if)# no shutdown
R1(config-if)# exit

! Static Route to Reach Central HQ Subnets via R2
R1(config)# ip route 192.168.20.0 255.255.255.0 10.0.0.2
R1(config)# end
R1# copy running-config startup-config

Verification#

1. Verify Remote Client DHCP Acquisition via Relay (PC-Client-1)#

  1. In Packet Tracer, click PC-Client-1 -> Desktop -> IP Configuration.
  2. Select the DHCP radio button.
  3. Observe the client status print:
    DHCP request successful.
    IP Address: 192.168.10.11
    Subnet Mask: 255.255.255.0
    Default Gateway: 192.168.10.1
    DNS Server: 208.67.222.222
    

2. Verify Local Client DHCP Acquisition (PC-Client-2)#

  1. Click PC-Client-2 -> Desktop -> IP Configuration.
  2. Select the DHCP radio button.
  3. Confirm that PC-Client-2 receives an IP from HQ_POOL:
    DHCP request successful.
    IP Address: 192.168.20.11
    Subnet Mask: 255.255.255.0
    Default Gateway: 192.168.20.1
    DNS Server: 208.67.222.222
    

3. Inspect Active DHCP Bindings on Central Server R2#

R2# show ip dhcp binding

(Sample expected output — illustrative):

Bindings from all pools :
IP address          Client-ID/              Lease expiration        Type
                    Hardware address/
                    User name
192.168.10.11       0001.9654.A101          --                      Automatic
192.168.20.11       0002.1678.B202          --                      Automatic

4. Inspect DHCP Pool Statistics on Central Server R2#

R2# show ip dhcp pool

(Sample expected output — illustrative):

Pool BRANCH_POOL :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (lines/total)      : 1 / 254
 Addresses                      : 254
 Leased addresses               : 1
 Excluded addresses             : 10
 Subnet prefix                  : 192.168.10.0/24

Pool HQ_POOL :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (lines/total)      : 1 / 254
 Addresses                      : 254
 Leased addresses               : 1
 Excluded addresses             : 10
 Subnet prefix                  : 192.168.20.0/24

Troubleshooting#

  • Problem: Branch client PC displays 169.254.x.x with message DHCP failed. APIPA is being used..
    • Explanation: Automatic Private IP Addressing (APIPA) occurs when a client broadcasts a DHCP Discover message but receives no DHCP Offer before the discovery timer expires.
    • Check 1: Verify physical cabling and interface status with show ip interface brief on R1 and R2.
    • Check 2: Confirm ip helper-address 10.0.0.2 is configured on the exact client-facing interface (R1 Gi0/0/0) and not on the transit link.
    • Check 3: Verify Layer 3 routing between R1 and R2. Central Server R2 must have an explicit route back to 192.168.10.0/24 via 10.0.0.1 so that the unicast DHCP Offer can be returned.
  • Problem: Client receives an IP address that collides with a static server or default gateway.
    • Check: ip dhcp excluded-address must be configured before clients request addresses. If an address was already leased, clear the binding on R2 with clear ip dhcp binding *.

Key Takeaways#

  • The DHCPv4 exchange consists of four messages: Discover (broadcast), Offer (unicast/broadcast), Request (broadcast), and Acknowledge (unicast).
  • ip dhcp excluded-address protects static infrastructure IPs from being dynamically allocated to clients.
  • Cisco IOS matches the incoming giaddr field (the IP of the relay agent interface that forwarded the request) against defined pool network subnets to allocate from the correct remote pool.
  • The ip helper-address command forwards eight UDP broadcast services by default (including DHCP ports 67 and 68, DNS port 53, and TFTP port 69) across routers as unicast traffic.

References#


Files and Validation Status#

Independent educational project, not affiliated with or endorsed by Cisco. Lab passwords are provided for educational simulation purposes only.

Reference configurations

Final device configurations from the solution. Like the solution file, these give the answers away.

R1 R1.txt, 824 B
! ==========================================
! Router R1 (Branch Gateway & DHCP Relay Agent)
! Lab: Configuring Cisco IOS DHCPv4 Server and Relay Agent (PTL-0012)
! ==========================================
enable
configure terminal
hostname R1

! LAN 1 Interface (Client Subnet with DHCP Relay)
interface GigabitEthernet0/0/0
 description Branch Client LAN
 ip address 192.168.10.1 255.255.255.0
 ! Forward client DHCP broadcasts across routed link to Central DHCP Server R2
 ip helper-address 10.0.0.2
 no shutdown
 exit

! Routed WAN Transit Interface to Central Site R2
interface GigabitEthernet0/0/1
 description Routed Transit Link to R2
 ip address 10.0.0.1 255.255.255.252
 no shutdown
 exit

! Static Route to Central Server LAN
ip route 192.168.20.0 255.255.255.0 10.0.0.2

end
copy running-config startup-config

Download R1.txt

R2 R2.txt, 1.6 KB
! ==========================================
! Router R2 (Central Headquarters & IOS DHCP Server)
! Lab: Configuring Cisco IOS DHCPv4 Server and Relay Agent (PTL-0012)
! ==========================================
enable
configure terminal
hostname R2

! Exclude statically assigned IP addresses before pool creation
! Exclude .1 through .10 on Branch Subnet (protects gateway R1 Gi0/0/0 and future static hosts)
ip dhcp excluded-address 192.168.10.1 192.168.10.10

! Exclude .1 through .10 on HQ Subnet (protects gateway R2 Gi0/0/0 and management devices)
ip dhcp excluded-address 192.168.20.1 192.168.20.10

! ------------------------------------------
! DHCP Pool for Remote Branch LAN (Serviced via R1 Relay Agent)
! ------------------------------------------
ip dhcp pool BRANCH_POOL
 network 192.168.10.0 255.255.255.0
 default-router 192.168.10.1
 dns-server 208.67.222.222
 domain-name lab.local
 exit

! ------------------------------------------
! DHCP Pool for Local HQ LAN
! ------------------------------------------
ip dhcp pool HQ_POOL
 network 192.168.20.0 255.255.255.0
 default-router 192.168.20.1
 dns-server 208.67.222.222
 domain-name lab.local
 exit

! Routed Transit Interface to Branch Router R1
interface GigabitEthernet0/0/1
 description Routed Transit Link to R1
 ip address 10.0.0.2 255.255.255.252
 no shutdown
 exit

! HQ Local LAN Interface
interface GigabitEthernet0/0/0
 description HQ Client LAN
 ip address 192.168.20.1 255.255.255.0
 no shutdown
 exit

! Static Route returning traffic to Remote Branch Subnet via R1
ip route 192.168.10.0 255.255.255.0 10.0.0.1

end
copy running-config startup-config

Download R2.txt

S1 S1.txt, 673 B
! ==========================================
! Switch S1 (Branch Access Switch)
! Lab: Configuring Cisco IOS DHCPv4 Server and Relay Agent (PTL-0012)
! ==========================================
enable
configure terminal
hostname S1

! FastEthernet 0/1 connects to PC-Client-1 (Branch Client)
interface FastEthernet0/1
 description Branch Client Access Port
 switchport mode access
 switchport access vlan 1
 no shutdown
 exit

! GigabitEthernet 0/1 connects to Branch Router R1 Gi0/0/0
interface GigabitEthernet0/1
 description Uplink to Branch Router R1 Gi0/0/0
 switchport mode access
 switchport access vlan 1
 no shutdown
 exit

end
copy running-config startup-config

Download S1.txt

S2 S2.txt, 653 B
! ==========================================
! Switch S2 (HQ Access Switch)
! Lab: Configuring Cisco IOS DHCPv4 Server and Relay Agent (PTL-0012)
! ==========================================
enable
configure terminal
hostname S2

! FastEthernet 0/1 connects to PC-Client-2 (HQ Client)
interface FastEthernet0/1
 description HQ Client Access Port
 switchport mode access
 switchport access vlan 1
 no shutdown
 exit

! GigabitEthernet 0/1 connects to HQ Router R2 Gi0/0/0
interface GigabitEthernet0/1
 description Uplink to HQ Router R2 Gi0/0/0
 switchport mode access
 switchport access vlan 1
 no shutdown
 exit

end
copy running-config startup-config

Download S2.txt

  • Network Services
  • DHCP
  • DHCP Relay
  • IP Helper Address
  • Cisco IOS

This page is generated from labs/network-services/dhcp-server-and-relay/README.md in the repository. Corrections go there.

Search

Type at least two letters, for example OSPF, DHCP relay or VLAN.