DHCP
DHCP Relay View
Section titled “DHCP Relay View”Table 1 DHCP Relay View
| Command | Purpose |
|---|---|
| show dhcp_relay | Display DHCP Relay configuration. |
show dhcp_relay
Section titled “show dhcp_relay”[Command] show dhcp_relay
[Purpose] Display DHCP Relay configuration.
[View] Privileged User View
[Use Cases]
sonic# show dhcp_relay+------------------------------+-------------+-----------+------------+----------+--------+| Name | down link | up link | loopback | server | vrf |+==============================+=============+===========+============+==========+========+| test__v4(v4) | NA | NA | NA | NA | NA |+------------------------------+-------------+-----------+------------+----------+--------+| test_dhcp_over_vxlan__v4(v4) | vlan20 | 0/2 | NA | 21.0.0.2 | vrf 123|+------------------------------+-------------+-----------+------------+----------+--------+| test_dhcp_over_vxlan__v6(v6) | vlan20 | 0/2 | NA | 2123::2 | vrf 123|+------------------------------+-------------+-----------+------------+----------+--------+DHCP Relay Config
Section titled “DHCP Relay Config”Table 2 DHCP Relay Config
| Command | Purpose |
|---|---|
| feature dhcp state enable | Enable feature DHCP. |
| dhcp-relay name {v4|v6} [vrf vrf_name] | Create an IPv4 or IPv6 DHCP Relay instance. |
| downlink vlan vlan-id [giaddr A.B.C.D | option82_sub5 A.B.C.D] | Specify the VLAN for DHCP Relay (on DHCP Client side). |
| giaddr loopback loopback-id | Specify the gateway IP address. |
| server dhcp_server_ip | Set DHCP Server IP. |
| uplink {ethernet|link-aggregation|vlan} interface_name | Specify the uplink port (on DHCP Server side) of DHCP Relay. |
feature dhcp state enable
Section titled “feature dhcp state enable”[Command] feature dhcp state enable
[Purpose] Enable feature DHCP.
[View] Global Configuration View
[Notes] Run command feature dhcp state disable to disable DHCP feature.
[Use Cases]
sonic# configure terminalsonic(config)# feature dhcp state enabledhcp-relay
Section titled “dhcp-relay”[Command] dhcp-relay name {v4|v6} [vrf vrf_name]
[Purpose] Create an IPv4 or IPv6 DHCP Relay instance.
[Parameters]
| Parameter | Description |
|---|---|
| name | Name of DHCP Relay instance. |
| vrf_name | VRF name, specifying the VRF where the DHCP Relay instance is located. |
[View] Global Configuration View
[Notes] Please run feature dhcp state enable to enable DHCP before you configure DHCP Relay.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4downlink vlan
Section titled “downlink vlan”[Command] downlink vlan vlan-id [giaddr A.B.C.D | option82_sub5 A.B.C.D]
[Purpose] Specify the VLAN for DHCPv4 Relay (on DHCP Client side).
[Parameters]
| Parameter | Description |
|---|---|
| vlan-id | VLAN ID, the range is [1,4094]. |
| giaddr | Relay agent address, only supported by DHCPv4 Relay instance. |
| option82_sub5 | Set option82, only supported by DHCPv4 Relay instance. |
[View] DHCP Relay Instance Configuration View
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test)# downlink vlan 10 giaddr 10.0.0.1downlink vlan
Section titled “downlink vlan”[Command] downlink vlan vlan-id [option option client-linklayer-addr]
[Purpose] Specify the VLAN for DHCPv6 Relay (on DHCP Client side).
[Parameters]
| Parameter | Description |
|---|---|
| vlan-id | VLAN ID, the range is [1,4094]. |
| client-linklayer-addr | Relay agent address,only IP,Configure option 79,after configuration, the message forwarded by Relay will carry the MAC address of the client. Only supported by DHCPv6 Relay instance. |
[View] DHCP Relay Instance Configuration View
[Use Cases]
sonic# configure terminalsonic(config)# dhcp-relay test v6sonic(config-dhcp-relay-test)# downlink vlan 100 option client-linklayer-addrgiaddr loopback
Section titled “giaddr loopback”[Command] giaddr loopback loopback-id
[Purpose] Specify the gateway IP address.
[Parameters]
| Parameter | Description |
|---|---|
| loopback-id | Loopback interface number, integer form, range from 0 to 999. |
[View] DHCP Relay Instance Configuration View
[Notes] By default, the switch will set the giaddr to the IP address of the host VLAN interface when it receives a DHCP request.
[Use Cases]
sonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test)# giaddr loopback 0server
Section titled “server”[Command] server dhcp_server_ip
[Purpose] Set DHCP Server IP.
[Parameters]
| Parameter | Description |
|---|---|
| dhcp_server_ip | Specify the DHCP server IP address. |
[View] DHCP Relay Instance Configuration View
[Use Cases]
sonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test)# server 10.248.0.1uplink {ethernet|link-aggregation|vlan}
Section titled “uplink {ethernet|link-aggregation|vlan}”[Command] uplink {ethernet|link-aggregation|vlan} interface_name
[Purpose] Specify the uplink port ( on DHCP Server side) of DHCP Relay.
[Parameters]
| Parameter | Description |
|---|---|
| interface_name | Interface name (eg.0/1) |
[View] DHCP Relay Instance Configuration View
[Use Cases]
sonic(config)# dhcp-relay test v4sonic(config-dhcp-relay-test)# uplink ethernet 0/2DHCP Server
Section titled “DHCP Server”DHCP Server View
Section titled “DHCP Server View”Table 3 DHCP Server View
| Command | Purpose |
|---|---|
| **show dhcp pool info ** [ip-version {v4|v6}] | Display DHCP Server pool information. |
| **show dhcp pool ip-use ** [ip-version {v4|v6}] | Display the address assigned to clients by DHCP Server. |
| **show dhcp pool expired ** [ip-version {v4|v6}] | Display DHCP Server expired ip information. |
| show dhcp class | Display DHCP Server User Class configuration. |
| show dhcp option-group | Display DHCP Server option group configuration. |
show dhcp pool info [ip-version {v4|v6}]
Section titled “show dhcp pool info [ip-version {v4|v6}]”[Command] **show dhcp pool info ** [ip-version {v4|v6}]
[Purpose] Display DHCP Server pool infomation.
[View] Privileged User View
[Notes] When no IP address version is specified, default view of IPv4 version address pool information
[Use Cases]
sonic# show dhcp pool info--------------------------------------------------Pool-name : t1Network : 201.0.0.0Mask : 255.255.255.0Lease : 201.0.0.20 - 201.0.0.50Lease_default_time : 600Lease_max_time : 7200Used Lease : 0Total Lease : 72show dhcp pool ip-use [ip-version {v4|v6}]
Section titled “show dhcp pool ip-use [ip-version {v4|v6}]”[Command] **show dhcp pool ip-use ** [ip-version {v4|v6}]
[Purpose] Display the addresses assigned to clients by DHCP Server.
[View] Privileged User View
[Notes] When no IP address version is specified, the default view is the IP address information assigned by the IPv4 version
[Use Cases]
sonic# show dhcp pool ip-in-use ip-version v4Reading leases from /var/lib/dhcp/dhcpd.leasesIP MAC hostname binding state starts ends==================================================================================================================total lease :0show dhcp pool expired [ip-version {v4|v6}]
Section titled “show dhcp pool expired [ip-version {v4|v6}]”[Command] **show dhcp pool expired ** [ip-version {v4|v6}]
[Purpose] Display DHCP Server expired ip information.
[View] Privileged User View
[Notes] When no IP address version is specified, the default view is the IP address information reclaimed by IPv4 version
[Use Cases]
sonic# show dhcp pool expiredReading leases from /var/lib/dhcp/dhcpd.leasesIP MAC hostname binding state starts ends==================================================================================================================201.0.0.35 18:17:25:37:64:40 -NA- free 2024-10-21 03:07:01 2024-10-21 03:09:07total lease :1show dhcp class
Section titled “show dhcp class”[Command] show dhcp class
[Purpose] Display DHCP Server User Class configuration.
[View] Privileged User View
[Use Cases]
sonic# show dhcp class!dhcp class t1!dhcp class test1 if-match rule 1 option 93 hex ffffshow dhcp option-group
Section titled “show dhcp option-group”[Command] show dhcp option-group
[Purpose] Display DHCP Server option group configuration.
[View] Privileged User View
[Use Cases]
sonic# show dhcp option-group!dhcp option-group 1 option43 hex 01 forceDHCP Server Config
Section titled “DHCP Server Config”Table 4 DHCP Server Config
| Command | Purpose |
|---|---|
| dhcp server | Enable interface DHCP Server function. |
| dhcp pool name [v6] | Create a DHCP server address pool and enter the DHCP pool configuration view. |
| dhcp class name | Create DHCP Server user class and enter DHCP user class configuration view. |
| dhcp option-group id | Create a DHCP Server option group and enter the option group configuration view. |
| network {A.B.C.D A.B.C.D|A::B A::B} | Configure the network of the address pool. |
| address-pool start_ip end_ip | Configure address pool IP range. |
| lease-time default_time max_time | Configure lease time. |
| bootfile name | Configure bootfile option. |
| dns {A.B.C.D|A::B} | Configure DNS option. |
| next-server {A.B.C.D|A::B} | Configure next server option. |
| tftp-server {A.B.C.D|A::B} | Configure tftp server option. |
| capwap-ac A.B.C.D | Configure capwap-ac option. |
| routers A.B.C.D | Configure routers option. |
| option43 hex value force | Configure option43 option. |
| class name address-pool start_ip end_ip | Configure user class IP range. |
| class name option-group id | Bind class and option-group. |
| if-match rule rule_id option option_id | Create user class matching rule. |
| dhcp failover name | Enable DHCP Server failover. |
| adddress {A.B.C.D|loopback 0} | Configure failover local IP. |
| peer address A.B.C.D | Configure failover peer IP. |
| auto-partner-down time | Configure peer offline time. |
| max-response-delay time | Configure maximum communication interruption time. |
| role {primary|secondary} | Configure primary and secondary roles. |
dhcp server
Section titled “dhcp server”[Command] dhcp server
[Purpose] Enable interface DHCP Server function.
[View] Physical Interface / VLANIF Configuration View
[Notes] Run command no dhcp server to disable interface DHCP Server fuction.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1dhcp pool
Section titled “dhcp pool”[Command] dhcp pool name [v6]
[Purpose] Create a DHCP server address pool and enter the DHCP pool configuration view.
[Parameters]
| Parameter | Description |
|---|---|
| name | DHCP Server pool name. |
[View] Global Configuration View
[Notes] Default creation of IPv4 type address pool, with v6 parameter, creates IPv6 type address pool Run command no dhcp pool name [v6] to delete DHCP pool.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1dhcp class
Section titled “dhcp class”[Command] dhcp class name
[Purpose] Create DHCP Server user class and enter DHCP user class configuration view.
[Parameters]
| Parameter | Description |
|---|---|
| name | DHCP Server class name. |
[View] Global Configuration View
[Notes] Run command no dhcp class name to delete DHCP class.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp class t1dhcp option-group
Section titled “dhcp option-group”[Command] dhcp option-group id
[Purpose] Create a DHCP Server option group and enter the option group configuration view.
[Parameters]
| Parameter | Description |
|---|---|
| id | DHCP Server option group ID, with a value range of 1-65535. |
[View] Global Configuration View
[Notes] Run command no dhcp option-group id to delete DHCP option-group.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp option-group 1network {
Section titled “network {”[Command] network {A.B.C.D A.B.C.D|A::B A::B}
[Purpose] Configure the network of the address pool.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D A.B.C.D | IPv4 address and mask. |
| A:;B A::B | IPv6 address and mask. |
[View] DHCP pool Configuration View
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# network 100.0.0.1 255.255.255.0address-pool
Section titled “address-pool”[Command] address-pool start_ip end_ip
[Purpose] Configure address pool IP range.
[Parameters]
| Parameter | Description |
|---|---|
| start_ip | Start_ip. |
| end_ip | End_ip |
[View] DHCP pool Configuration View
[Notes] The end_ip address must be after the start_ip address
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# address-pool 100.0.0.10 100.0.0.100lease-time
Section titled “lease-time”[Command] lease-time default_time max_time
[Purpose] Configure lease time.
[Parameters]
| Parameter | Description |
|---|---|
| default_time | Default lease time, in seconds, with a value range greater than 300, default value is 600. |
| max_time | The maximum lease time, in seconds, needs to be greater than the default lease time, the default value is 7200. |
[View] DHCP pool Configuration View
[Notes] Run command no lease-time to restore lease time to default value
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# lease-time 300 1000bootfile
Section titled “bootfile”[Command] bootfile name
[Purpose] Configure bootfile option.
[Parameters]
| Parameter | Description |
|---|---|
| name | File name. |
[View] DHCP pool Configuration View/DHCP option-group Configuration View
[Notes] Run command no bootfile to delete bootfile option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# bootfile-name test.txt[Command] dns {A.B.C.D|A::B}
[Purpose] Configure DNS option.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
| A::B | IPv6 address. |
[View] DHCP pool Configuration View/ DHCP option-group Configuration View
[Notes] Run command no dns to delete DNS option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# dns 8.8.8.8next-server {
Section titled “next-server {”[Command] next-server {A.B.C.D|A::B}
[Purpose] Configure next-server option.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
| A::B | IPv6 address. |
[View] DHCP pool Configuration View
[Notes] Run command no next-server to delete next-server option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# next-server 1.1.1.1tftp-server {
Section titled “tftp-server {”[Command] tftp-server {A.B.C.D|A::B}
[Purpose] Configure tftp-server option.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
| A::B | IPv6 address. |
[View] DHCP pool Configuration View/DHCP option-group Configuration View
[Notes] Run command no tftp-server to delete tftp-server option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# tftp-server 2.2.2.2capwap-ac
Section titled “capwap-ac”[Command] capwap-ac A.B.C.D
[Purpose] Configure capwap-ac option.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
[View] DHCP pool Configuration View/DHCP option-group Configuration View
[Notes] Run command no capwap-ac to delete capwap-ac option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# capwap-ac 3.3.3.3routers
Section titled “routers”[Command] routers A.B.C.D
[Purpose] Configure routers option.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
[View] DHCP pool Configuration View/DHCP option-group Configuration View
[Notes] Only supports IPv4 addresses Run command no routers to delete routers option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# routers 100.0.0.1option43 hex
Section titled “option43 hex”[Command] option43 hex value force
[Purpose] Configure option43 option.
[Parameters]
| Parameter | Description |
|---|---|
| value | Hexadecimal number. |
[View] DHCP pool Configuration View/DHCP option-group Configuration View
[Notes] Run command no option43 to delete routers option
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# option43 hex 10 force[Command] class name address-pool start_ip end_ip
[Purpose] Configure DHCP user class IP range.
[Parameters]
| Parameter | Description |
|---|---|
| name | Class name |
| start_ip | Start_ip |
| end_ip | End_ip |
[View] DHCP pool Configuration View
[Notes] Run command no class name address-pool to delete DHCP user class IP range
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# class test1 address-pool 100.0.0.110 100.0.0.150[Command] class name option-group id
[Purpose] Bind class and option-group.
[Parameters]
| Parameter | Description |
|---|---|
| name | Class name. |
| id | Option-group ID |
[View] DHCP pool Configuration View
[Notes] Run command no class name option-group to unbind class and option-group
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool test1sonic(config-dhcp-pool-t1)# class test1 option-group 1if-match rule
Section titled “if-match rule”[Command] if-match rule rule_id option option_id
[Purpose] Create user class matching rule.
[Parameters]
| Parameter | Description |
|---|---|
| rule_id | Rule id, also indicating priority, with a value range of 1-16. The larger the value, the higher the priority. |
| option_id | Option ID, currently only supports 82 and 93. |
[View] DHCP class Configuration View
[Notes] Run command no if-match rule rule_id to delete user class matching rule.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp class test1sonic(config-dhcp-class-test1)# if-match rule 1 option 93 hex ffffdhcp failover
Section titled “dhcp failover”[Command] dhcp failover name
[Purpose] Enable DHCP Server failover.
[Parameters]
| Parameter | Description |
|---|---|
| name | Instance name. |
[View] Global Configuration View
[Notes] Run command no dhcp failover name to disable DHCP Server failover.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp failover t456adddress {
Section titled “adddress {”[Command] adddress {A.B.C.D|loopback 0}
[Purpose] Configure local IP.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
[View] DHCP failover Configuration View
[Notes] Run command no address to delete local IP
[Use Cases]
sonic# configure terminalsonic(config)# dhcp failover t456sonic(config-dhcp-failover-t456)# address 20.0.0.1peer address
Section titled “peer address”[Command] peer address A.B.C.D
[Purpose] Configure peer IP.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
[View] DHCP failover Configuration View
[Notes] Run command no peer address to delete peer IP
[Use Cases]
sonic# configure terminalsonic(config)# dhcp failover t456sonic(config-dhcp-failover-t456)# peer address 20.0.0.2auto-partner-down
Section titled “auto-partner-down”[Command] auto-partner-down time
[Purpose] Configure peer offline time.
[Parameters]
| Parameter | Description |
|---|---|
| time | Peer offline time, in seconds and ranging from 1 to 3600. By default, peers will not go offline. |
[View] DHCP failover Configuration View
[Notes] Run command auto-partner-down to disable peer offline function
[Use Cases]
sonic# configure terminalsonic(config)# dhcp failover t456sonic(config-dhcp-failover-t456)# auto-partner-down 100max-response-delay
Section titled “max-response-delay”[Command] max-response-delay time
[Purpose] Configure maximum communication interruption time.
[Parameters]
| Parameter | Description |
|---|---|
| time | The maximum communication interruption time, measured in seconds, ranges from 30 to 3600, with a default value of 60. |
[View] DHCP failover Configuration View
[Notes] Run command nomax-response-delay to restore maximum communication time to default value
[Use Cases]
sonic# configure terminalsonic(config)# dhcp failover t456sonic(config-dhcp-failover-t456)# max-response-delay 100role {primary|secondary}
Section titled “role {primary|secondary}”[Command] role {primary|secondary}
[Purpose] Configure primary and secondary roles.
[Parameters]
| Parameter | Description |
|---|---|
| A.B.C.D | IPv4 address. |
[View] DHCP failover Configuration View
[Use Cases]
sonic# configure terminalsonic(config)# dhcp failover t456sonic(config-dhcp-failover-t456)# role primary