DHCP Relay

Dynamic Host Configuration Protocol (DHCP) Relay is a network function that facilitates the forwarding of DHCP requests and responses between clients and servers on different network segments.

DHCP is a network protocol that is commonly used to automatically assign IP addresses and other network parameters to devices configured as DHCP clients.

When a DHCP client sends a DHCP request to a DHCP server, the server responds with an assigned IP address and any applicable network settings. In Layer 3 networks, where devices are separated by routers and exist in different broadcast domains, DHCP Relay agents are configured to intercept and forward DHCP requests and responses between clients and servers across these separate subnets, ensuring seamless IP address allocation and network configuration.

DHCP Relay Configuration Commands

  • Add a DHCP relay destination IP address or multiple IP addresses to a VLAN using the config vlan dhcp_relay add command:
admin@sonic:~$ sudo config vlan dhcp_relay add -h
Usage: config vlan dhcp_relay add [OPTIONS] <vid>
                                  DHCP_RELAY_DESTINATION_IPS...

  Add a destination IP address to the VLAN's DHCP relay

Options:
  -h, -?, --help  Show this message and exit.
admin@sonic:~$ 

For example:

admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7
Added DHCP relay destination address ['7.7.7.7'] to Vlan1000
Restarting DHCP relay service...

You can add more than one DHCP relay destination IP address on a VLAN interface. For example:

admin@sonic:~$ sudo config vlan dhcp_relay add 1000 7.7.7.7 1.1.1.1
Added DHCP relay destination address ['7.7.7.7', '1.1.1.1'] to Vlan1000
Restarting DHCP relay service...
  • Add IPv4 DHCP relay helper addresses to a VLAN using the config dhcp_relay ipv4 helper add command:
admin@sonic:~$ sudo config dhcp_relay ipv4 helper add -h
Usage: config dhcp_relay ipv4 helper add [OPTIONS] <vid> DHCP_RELAY_HELPERS...

Options:
  -h, -?, --help  Show this message and exit.
  • Delete IPv4 DHCP relay helper addresses from a VLAN using the config dhcp_relay ipv4 helper del command:
admin@sonic:~$ sudo config dhcp_relay ipv4 helper del -h
Usage: config dhcp_relay ipv4 helper del [OPTIONS] <vid> DHCP_RELAY_HELPERS...

Options:
  -h, -?, --help  Show this message and exit.

For example:

admin@sonic:~$ sudo config dhcp_relay ipv4 helper add 1000 7.7.7.7 1.1.1.1
Added DHCP relay address [7.7.7.7, 1.1.1.1] to Vlan1000
Restarting DHCP relay service...

Similarly, IPv6 DHCP relay destination addresses can be assigned to a VLAN.

  • Add IPv6 DHCP relay helper addresses to a VLAN using the config dhcp_relay ipv6 destination add command:
admin@sonic:~$ sudo config dhcp_relay ipv6 destination add -h
Usage: config dhcp_relay ipv6 destination add [OPTIONS] <vid>
                                              DHCP_RELAY_DESTINATIONS...

Options:
  -?, -h, --help  Show this message and exit.
  • Delete IPv6 DHCP relay helper addresses from a VLAN using the config dhcp_relay ipv6 destination del command:
admin@sonic:~$ sudo config dhcp_relay ipv6 destination del -h
Usage: config dhcp_relay ipv6 destination del [OPTIONS] <vid>
                                              DHCP_RELAY_DESTINATIONS...

Options:
  -?, -h, --help  Show this message and exit.

For example:

admin@sonic:~$ sudo config dhcp_relay ipv6 destination add 1000 fc02:2000::1 fc02:2000::2
Added DHCP relay address [fc02:2000::1, fc02:2000::2] to Vlan1000
Restarting DHCP relay service...
  • Verify the configuration using the show dhcp_relay command.

For example:

admin@sonic:~$ show dhcp_relay ipv4 helper
-------- ---------
Vlan1000 192.0.0.1
192.0.0.2
-------- ---------