4.4. Configuring DHCP Relay

Overview

Function Introduction

DHCP relay agent is any host that forwards DHCP packets between clients and servers. Relay agents are used to forward requests and replies between clients and servers when they are not on the same physical subnet. Relay agent forwarding is distinct from the normal forwarding of an IP router, where IP datagram are switched between networks somewhat transparently. By contrast, relay agents receive DHCP messages and then generate a new DHCP message to send out on another interface. The relay agent sets the gateway address (girder field of the DHCP packet) and, if configured, adds the relay agent information option (option82) in the packet and forwards it to the DHCP server. The reply from the server is forwarded back to the client after removing option 82.

Principle Description

N/A

Configuration

image

Fig. 4.5 DHCP Relay

This figure is the networking topology for testing DHCP relay functions. We need two Linux boxes and one Switch to construct the test bed.

Computer A is used as DHCP server.

Computer B is used as DHCP client.

Switch is used as DHCP relay agent.

step 1 Enter the configure mode

Switch# configure terminal

step 2 Enter the interface configure mode set the attributes and ip address

Switch(config)# interface eth-0-12
Switch(config-if)# no switchport
Switch(config-if)# ip address 4.4.4.2/24
Switch(config-if)# no shutdown
Switch(config-if)# exit
Switch(config)# interface eth-0-1
Switch(config-if)# no switchport
Switch(config-if)# ip address 5.5.5.2/24
Switch(config-if)# no shutdown
Switch(config-if)# exit

step 3 Create a dhcp server

Switch(config)# dhcp-server 1 4.4.4.1

step 4 Enable DHCP server and option82 for the interface

Switch(config)# interface eth-0-1
Switch(config-if)# dhcp relay information trusted
Switch(config-if)# dhcp-server 1
Switch(config-if)# exit

step 5 Enable DHCP server and DHCP relay globally

Switch(config)# service dhcp enable
Switch(config)# dhcp relay

step 6 Validation

Check the interface configuration:

Switch# show running-config interface eth-0-12

 !

interface eth-0-12
no switchport
ip address 4.4.4.2/24

 !

Switch# show running-config interface eth-0-1

 !

interface eth-0-1
no switchport
dhcp relay information trusted
dhcp-server 1
ip address 5.5.5.2/24

 !

Check the dhcp service status:

Switch# show services
Networking services configuration:
Service Name Status
===========================================================

dhcp enable

Check the dhcp server group configuration:

Switch# show dhcp-server
DHCP server group information:

===========================================================

group 1 ip address list:

[1] 4.4.4.1

Check the dhcp relay statistics:

Switch# show dhcp relay statistics
DHCP relay packet statistics:
===========================================================

Client relayed packets: 20
Server relayed packets: 20
Client error packets: 20
Server error packets: 0
Bogus GIADDR drops: 0
Bad circuit ID packets: 0
Corrupted agent options: 0
Missing agent options: 0
Missing circuit IDs: 0

Check your computer ip address from DHCP server:

Ipconfig /all
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 5.5.5.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 5.5.5.2
DHCP Server . . . . . . . . . . . : 4.4.4.1
DNS Servers . . . . . . . . . . . : 4.4.4.1

Application cases

N/A