Configuring DHCP on Routers and Switches: A Complete Guide

DHCP (Dynamic Host Configuration Protocol) can be configured on routers and switches to automatically assign IP addresses to devices in a network. This eliminates manual IP configuration and simplifies network management.

1. Why Configure DHCP on Routers/Switches?

Key Benefits:

  • ✅ Automates IP assignment – No need to manually set IPs for each device.
  • ✅ Centralized control – Manage IP ranges, DNS, and gateways from one place.
  • ✅ Prevents IP conflicts – The DHCP server ensures no two devices get the same IP.
  • ✅ Supports multiple subnets – DHCP Relay (ip helper-address) allows serving multiple VLANs.

When to Use DHCP:

  • Small networks – Router acts as DHCP server.
  • Enterprise networks – Core router or dedicated server handles DHCP.
  • Multi-VLAN environments – Switches forward DHCP requests via ip helper-address.

2. How DHCP Works on Routers & Switches

Two Main Roles:

  • DHCP Server – Assigns IPs to clients (router/switch/server).
  • DHCP Relay Agent – Forwards requests to remote DHCP servers (router/switch).

3. DHCP Configuration on a Router (as a Server)

Network Setup:

  • Subnet: 192.168.1.0/24
  • DHCP Pool: 192.168.1.10 - 192.168.1.100
  • Default Gateway: 192.168.1.1
  • DNS: 8.8.8.8

Step-by-Step Configuration

Router> enable
Router# configure terminal

! Define DHCP pool
Router(config)# ip dhcp pool LAN_POOL
Router(dhcp-config)# network 192.168.1.0 255.255.255.0
Router(dhcp-config)# default-router 192.168.1.1
Router(dhcp-config)# dns-server 8.8.8.8
Router(dhcp-config)# lease 7

! Exclude static IPs
Router(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.9

! Enable DHCP service (if disabled)
Router(config)# service dhcp
Router(config)# end
Router# write memory

Verification Commands

Router# show ip dhcp binding
Router# show ip dhcp pool
Router# debug ip dhcp server events

4. DHCP Relay (ip helper-address) on a Switch/Router

When to Use: When the DHCP server is in a different subnet or VLAN.

Example Setup:

  • VLAN 10: 192.168.10.0/24
  • DHCP Server: 10.0.0.5
Switch> enable
Switch# configure terminal

! Enable IP routing
Switch(config)# ip routing

! VLAN interface
Switch(config)# interface vlan 10
Switch(config-if)# ip address 192.168.10.1 255.255.255.0
Switch(config-if)# ip helper-address 10.0.0.5
Switch(config-if)# no shutdown
Switch(config-if)# end
Switch# write memory

Verification

Switch# show ip interface vlan 10
Switch# debug ip dhcp relay

5. DHCP on a Switch (Layer 2 vs. Layer 3)

  • Layer 2 Switch: Cannot assign IPs; may forward requests with ip helper-address.
  • Layer 3 Switch: Can act as a DHCP server.
Switch(config)# ip dhcp pool OFFICE_POOL
Switch(dhcp-config)# network 192.168.20.0 255.255.255.0
Switch(dhcp-config)# default-router 192.168.20.1
Switch(dhcp-config)# dns-server 8.8.8.8

6. Real-World Example: Office Network

Scenario:

  • Main Router provides DHCP for 192.168.1.0/24.
  • Switch connects VLANs (HR, IT, Guest).
  • DHCP Server at 10.0.0.5.
! Router DHCP config
ip dhcp pool MAIN_LAN
 network 192.168.1.0 255.255.255.0
 default-router 192.168.1.1

! Switch as relay
interface vlan 20
 ip helper-address 10.0.0.5

7. Troubleshooting DHCP Issues

ProblemSolution
Clients not getting IPCheck ip helper-address, DHCP pool, lease availability
IP conflictsUse ip dhcp excluded-address for reserved/static IPs
DHCP server unreachableVerify routing and firewall rules
show ip dhcp conflict
clear ip dhcp binding *

8. Summary

  • Router as DHCP Server: Best for small networks
  • Switch as DHCP Relay: For VLAN/multi-subnet environments
  • Enterprise: Use central DHCP server + relay agents

By configuring DHCP correctly, you ensure automatic, conflict-free IP assignment across your network.

DHCP Configuration on Routers & Switches - Quiz

1. Why configure DHCP on routers or switches?

Correct answer is B. DHCP automates IP assignment and centralizes control for easier network management.

2. In small networks, which device usually acts as the DHCP server?

Correct answer is D. Routers typically act as DHCP servers in small or home networks.

3. What role does a DHCP Relay Agent perform?

Correct answer is B. DHCP Relay forwards client requests to a DHCP server on a different subnet.

4. In the Cisco DHCP server configuration, what does the command ip dhcp excluded-address do?

Correct answer is A. It excludes static IPs like router or servers from being dynamically assigned.

5. Which command enables DHCP relay on a Cisco switch interface?

Correct answer is C. ip helper-address configures the switch to forward DHCP requests to the specified server.

6. Which type of switch can act as a DHCP server?

Correct answer is C. Layer 3 switches have routing and DHCP server capabilities.

7. What is the default DNS server IP used in the example DHCP pool configuration?

Correct answer is B. 8.8.8.8 is Google's public DNS used in the example.

8. Which command shows currently leased IP addresses on a Cisco router DHCP server?

Correct answer is D. show ip dhcp binding lists active DHCP leases.

9. In a multi-VLAN environment, how do switches forward DHCP requests?

Correct answer is C. Switches forward DHCP requests using ip helper-address configured on VLAN interfaces.

10. What should you verify if clients are not getting IP addresses from DHCP?

Correct answer is A. Misconfigured ip helper-address or exhausted DHCP pools often cause client IP assignment failure.

← Back to Home