DHCP Relay Configuration
show dhcp relay config
Section titled “show dhcp relay config”[Command]
show dhcp relay config
[Purpose]
Display DHCP relay related configuration
[View]
System view
[Use Cases]
sonic# show dhcp relay config+--------+-------------+------------+------------+----------+------------+----------+--------+| Name | down link | up link | loopback | server | option82 | mode | sourceip+========+=============+============+============+==========+============+==========+========+| a(v4) | Vlan100 | Ethernet11 | NA | 1.1.1.1 | false | strategy | NA |+--------+-------------+------------+------------+----------+------------+----------+--------+| b(v4) | Vlan200 | Ethernet11 | Loopback0 | 1.1.1.1 | true | NA | NA |+--------+-------------+------------+------------+----------+------------+----------+--------+dhcp-relay {v4|v6}
Section titled “dhcp-relay {v4|v6}”[Command]
dhcp-relay name {v4|v6}
no dhcp-relay name {v4|v6}
[Purpose]
Configuring DHCP relay instance
[Parameter]
| Parameter | Description |
|---|---|
| name | DHCP Relay name |
[View]
System configuration view
[Usage Scenario] When users and DHCP servers are in different broadcast domains (different subnets), the device can act as a DHCP relay agent to encapsulate the user’s DHCP request broadcast message into a unicast message and send it to the DHCP server.
[Notes]
The device supports the configuration of multiple DHCP instances as DHCP relay for the scenario that different terminals use different DHCP Server.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test__v4)#down_link interface vlan
Section titled “down_link interface vlan”[Command]
down_link interface vlan vlan_id
no down_link interface vlan vlan_id
[Purpose]
Specify the interface ID of the connected terminal in the relay instance
[Parameter]
| Parameter | Description |
|---|---|
| vlan_id | VLAN ID of the physical port to which the terminal is connected |
[View]
DHCP-relay view
[Usage Scenario] To allow users who need to obtain IP addresses dynamically, specify the VLAN where these users are located as the downstream interface of the Relay instance. All users within this VLAN can then obtain IP addresses from the DHCP server configured within this instance.
[Notes]
Multiple VLAN interfaces are supported to be configured under the same instance. Modify down link interface related content, such as: SVI port corresponding VLAN add member interface, modify the interface IP address, MAC address, etc., need to reconfigure Relay instance.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test__v4)# down_link interface vlan 10up_link interface
Section titled “up_link interface”[Command]
up_link interface { interface_type } { interface_name }
no up_link interface { interface_type } { interface_name }
[Purpose]
Specify the interface ID of the Relay instance to which the DHCP server is connected
[Parameter]
| Parameter | Description |
|---|---|
| interface_type | Supported configurations:ethernet, link-aggregation, vlan |
| interface_name | Supported configurations: ethernet_num, lag_id, vlan_id |
[View]
DHCP-relay view
[Usage Scenario] In a DHCP relay environment, to ensure that only legitimate DHCP response packets from a specified interface are accepted, you can use this command to specify the interface. This prevents illegal servers from providing unauthorized IP addresses to users, thereby maintaining network security.
[Notes]
Multiple interfaces are supported to be configured under the same instance.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test__v4)# up_link interface ethernet 1server_ip
Section titled “server_ip”[Command]
server_ip { A.B.C.D | A:B:C:D:E:F:G:H }
no server_ip { A.B.C.D | A:B:C:D:E:F:G:H }
[Purpose]
Specify the DHCP server IP address of the relay instance
[Parameter]
| Parameter | Description |
|---|---|
| A.B.C.D | ipv4 address |
| A:B:C:D:E:F:G:H | ipv6 address |
[View]
DHCP-relay view
[Notes]
Up to two DHCP Serve configurations are supported under the same instance. The DHCP Server under different instances can be different. The relay will send DHCP request packets to all DHCP servers and forward all received response packets to the client. The client will then choose from these responses.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test __v4)# server_ip 150.1.0.1loopback_interface loopback
Section titled “loopback_interface loopback”[Command]
loopback_interface loopback loopback_id
no loopback_interface loopback loopback_id
[Purpose]
To configure the DHCP relay packet’s relay agent address as the IP address of a Loopback interface
[View]
DHCP-relay view
[Usage Scenario] In scenarios where users utilize a distributed gateway, if the DHCP relay still uses the user gateway’s IP address as the Relay Agent IP address, the DHCP server will be unable to communicate with the relay through that IP address, resulting in unreachable response packets. Users can use this command to specify the Relay Agent IP address as the IP address of a Loopback interface that uniquely identifies a device. This allows the DHCP server to forward response packets to the requesting DHCP relay.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test __v4)# loopback_interface loopback 0dhcp-agent address
Section titled “dhcp-agent address”[Command]
dhcp-agent address A.B.C.D
[Purpose]
Specify the DHCP Server IP address of the Relay instance
[View]
Interface vlan view
[Usage Scenario] By default, DHCP relays insert the option82 field into DHCP request packets, populating the DHCP relay interface’s IP address with the “link-selection” field within option82. DHCP servers use this field to select an IP address pool for allocation. However, some DHCP servers do not support parsing the “link-selection” field. In such cases, you need to configure this command to specify the Relay Agent IP so that the server can select an IP address pool based on this field.
[Notes]
When used in a distributed gateway scenario, different relay devices should be configured with different IP addresses to ensure that the DHCP server can forward response packets to the originating DHCP relay.
[Use Cases]
sonic# configure terminalsonic(config)# interface vlan 100sonic(config-vlanif-100)# dhcp-agent address 192.168.1.10no_option82
Section titled “no_option82”[Command]
no_option82
no no_option82
[Purpose]
Enable no option82 mode
[View]
DHCP-relay view
[Notes]
After configuring this command, DHCP relay will no longer include the option82 field in forwarded DHCP packets. This command should be used in conjunction with the dhcp-agent address command.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test __v4)# no_option82dhcp option82 encapsulation remote-id
Section titled “dhcp option82 encapsulation remote-id”[Command]
dhcp option82 encapsulation remote-id value
[Purpose]
Configuring the addition of the “remote-id” sub-option in option82
[View]
interface vlan view
[Usage Scenario] To configure the addition of the “remote-id” sub-option in Option 82, you may need to specify the relevant settings based on your networking equipment or DHCP server software. In general, Option 82 is often associated with DHCP and is used to carry additional information about the client.
[Use Cases]
sonic(config)# interface vlan 100sonic(config-vlanif-100)# dhcp option encapsulation remote-id clientUsersource_ip
Section titled “source_ip”[Command]
source_ip A.B.C.D
no source_ip
[Purpose]
Specify the source IP for DHCP message interactions.
[View]
DHCP-relay view
[Usage Scenario] This command allows you to specify the Ethernet layer source IP address for DHCP relay messages.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test1__v4)# source_ip 30.102.0.216[Command]
option 79 no option 79
[Purpose]
Specify that the DHCP Relay V6 encapsulated packet carries the terminal’s MAC address.
[View]
DHCP-Relay View
[Use Cases]
text
sonic# configure terminalsonic(config)# dhcp-relay test v6sonic(config-dhcp-relay-test1__v6)# option 79