DHCP Relay
In small networks with only one IP subnet, DHCP clients can communicate directly with DHCP servers. In large networks, DHCP servers provide IP addresses for multiple subnets. In such cases, a DHCP client that has not yet obtained an IP address from the DHCP server cannot communicate with the DHCP server using IP routing.
A DHCP relay agent forwards DHCP packets between clients and servers when they are not on the same physical subnet. The relay agent receives the broadcast from the DHCP client and unicasts it to one or more DHCP servers.
DHCP VLAN Relay can be applied in a scenario where a DHCP server is deployed to offer IP addresses to clients in multiple VLANs. These VLANs do not have VLAN interfaces.
DHCP VLAN Relay can manually designate a Layer 3 interface for all VLANs as the default relay agent interface. All DHCP packets can be forwarded through this interface so that the clients can get IP addresses from the DHCP server.
This document assumes that the DHCP client and DHCP server, which are beyond the scope of this document, are configured and ready.
IPv4 DHCP Relay
Add DHCP Relay Destination IP Address to a VLAN Interface
Follow the steps below to add a DHCP Relay Destination IP address for a VLAN interface. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface.
|
Step |
Command |
Description |
|---|---|---|
|
1 |
config feature state dhcp_relay enabled |
Enable the DHCP relay. |
|
2 |
config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ip> |
Add a DHCP Relay Destination IP address to the VLAN.
|
|
3 |
show vlan brief |
Display the configured VLAN information. |
|
4 |
sudo config save –y |
Optional: Save the current configuration to be part of the startup configuration. |
The following example shows how to add a DHCP Relay Destination IPv4 address for a VLAN.
|
#Add an IP 192.168.200.20 as a DHCP Relay address for VLAN 100 |
|||||
|
admin@sonic: ~$ sudo config feature state dhcp_relay enabled |
|||||
|
admin@sonic: ~$ sudo config vlan dhcp_relay add 100 192.168.200.20 |
|||||
|
admin@sonic: ~$ show vlan brief |
|||||
|
- - - |
- - - |
- - - |
- - - |
- - - |
- - - |
|
VLAN ID |
IP Address |
Ports |
Port Tagging |
Proxy ARP |
DHCP Helper Address |
|
___ |
___ |
___ |
___ |
___ |
___ |
|
100 |
192.168.100.1 |
Ethernet0 |
untagged |
disabled |
192.168.200.20 |
|
- - - |
- - - |
- - - |
- - - |
- - - |
- - - |
|
|
|
|
|
|
|
|
#Add another IP 192.168.200.22 as a DHCP Relay address for VLAN 100 |
|||||
|
admin@sonic: ~$ sudo config vlan dhcp_relay add 100 192.168.200.22 |
|||||
|
admin@sonic: ~$ show vlan brief |
|||||
|
- - - |
- - - |
- - - |
- - - |
- - - |
- - - |
|
VLAN ID |
IP Address |
Ports |
Port Tagging |
Proxy ARP |
DHCP Helper Address |
|
___ |
___ |
___ |
___ |
___ |
___ |
|
100 |
192.168.100.1 |
Ethernet0 |
untagged |
disabled |
192.168.200.20 |
|
|
|
|
|
|
192.168.200.22 |
|
- - - |
- - - |
- - - |
- - - |
- - - |
- - - |
Remove DHCP Relay Destination IP Address from a VLAN Interface
Follow the steps below to remove an DHCP Relay Destination IP address from a VLAN interface.
|
Step |
Command |
Description |
|---|---|---|
|
1 |
config vlan dhcp_relay del <vlan_id> <dhcp_relay_destination_ip> |
Delete a configured DHCP Relay Destination IP address from a VLAN interface.
|
|
2 |
show vlan brief |
Display the configured VLAN information. |
|
3 |
sudo config save –y |
Optional: Save the current configuration to be part of the startup configuration. |
The following example shows how to remove a DHCP Relay Destination IPv4 address from a VLAN.
|
admin@sonic: ~$ sudo config vlan dhcp_relay del 100 192.168.200.22 |
|||||
|
admin@sonic: ~$ show vlan brief |
|||||
|
- - - |
- - - |
- - - |
- - - |
- - - |
- - - |
|
VLAN ID |
IP Address |
Ports |
Port Tagging |
Proxy ARP |
DHCP Helper Address |
|
___ |
___ |
___ |
___ |
___ |
___ |
|
100 |
192.168.100.1 |
Ethernet0 |
untagged |
disabled |
192.168.200.20 |
|
- - - |
- - - |
- - - |
- - - |
- - - |
- - - |
IPv6 DHCP Relay
Add DHCP Relay Destination IP Address for a VLAN Interface
Follow the steps below to add a DHCP Relay Destination IP address for a VLAN interface. Note that more than one DHCP Relay Destination IP address can be added on a VLAN interface.
|
Step |
Command |
Description |
|---|---|---|
|
1 |
config feature state dhcp_relay enabled |
Enable the DHCP relay. |
|
2 |
config vlan dhcp_relay add <vlan_id> <dhcp_relay_destination_ip> |
Add a DHCP Relay Destination IP address to the VLAN.
|
|
3 |
show vlan brief |
Display the configured VLAN information. |
|
4 |
sudo config save –y |
Optional: Save the current configuration to be part of the startup configuration. |
The following example shows how to add a DHCP Relay Destination IPv6 address for a VLAN.
|
admin@sonic: ~$ sudo config feature state dhcp_relay enabled |
|
|
admin@sonic: ~$ sudo config vlan dhcp_relay add 10 2001:192:168:20::120 |
|
|
admin@sonic: ~$ sudo config dhcp_relay ipv6 destination add 10 2001:192:168:20::120 |
|
|
admin@sonic: ~$ show dhcprelay_helper ipv6 |
|
|
- - - |
- - - |
|
Interface |
DHCP Relay Address |
|
___ |
___ |
|
Vlan10 |
2001:192:168:20::120 |
|
- - - |
- - - |
|
admin@sonic: ~$ show dhcp_relay ipv6 destination |
|
|
- - - |
- - - |
|
Vlan10 |
2001:192:168:20::120 |
|
- - - |
- - - |
Remove DHCP Relay Destination IP Address for a VLAN Interface
Follow the steps below to remove a DHCP Relay Destination IP address from a VLAN interface.
|
Step |
Command |
Description |
|---|---|---|
|
1 |
config vlan dhcp_relay del <vlan_id> <dhcp_relay_destination_ip> |
Delete a configured DHCP Relay Destination IP address from a VLAN interface.
|
|
2 |
show vlan brief |
Display the configured VLAN information. |
|
3 |
sudo config save –y |
Optional: Save the current configuration to be part of the startup configuration. |
The following example shows how to remove a DHCP Relay Destination IPv6 address from a VLAN.
|
admin@sonic: ~$ sudo config vlan dhcp_relay del 10 2001:192:168:20::120 |
