Command Line Reference
IP Service
DHCP Server Configuration
42 min
dhcp server configuration show dhcp pool info {v4|v6} \[command] show dhcp pool info {v4|v6} \[purpose] view the configuration information for the created dhcp address pool \[view] system view \[ use cases ] sonic# show dhcp pool info v4 \ pool name test subnet 140 1 1 0/24 lease na na lease default time 3600 lease max time 7200 show dhcp pool ip in use \[command] show dhcp pool ip in use \[ a b c d/a b ] show dhcp pool ipv6 in use \[ a b ] \[purpose] view dhcp address pool ip address allocation status \[view] system view \[usage scenario] display ip addresses already assigned in the dhcp pool \[ use cases ] sonic# show dhcp pool ip in use + + + + + \| ip address | mac address | lease start | lease end | +==============+=================+===================+====================+ \| 100 142 0 205|00 00 02 01 7f 9a|2025 08 23 06 09 00|2025 08 23 06 19 00 | + + + + + show dhcp class \[command] show dhcp class \[purpose] display dhcp class \[view] system view \[ use cases ] sonic# show dhcp class dhcp class pc if match rule 1 option 93 hex 0000 dhcp class test1 dhcp class x86 if match rule 1 option 93 hex 0001 show dhcp option group \[command] show dhcp option group \[purpose] display dhcp option group \[view] system view \[ use cases ] sonic# show dhcp option group option group id bootfile name router tftp server capwap ac option43 \ 1 test123 150 1 0 1 8003010203 show dhcp failover info \[command] show dhcp failover info \[purpose] view dhcp server dual active backup configuration \[view] system view \[ use cases ] sonic# show dhcp failover info \ failover name ceshi local address 30 102 0 230 peer address 30 102 0 216 role primary max response delay 60 heartbeat inteval 20 local state normal peer state normal split 50% dhcp pool \[command] dhcp pool name no dhcp pool name \[purpose] create address pools \[view] system configuration view \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# network \[command] network a b c d mask \[purpose] specify the network segment where the dhcp server assigns the ip address to the client \[parameter] parameter description a b c d ip address mask subnet mask \[view] dhcp view \[comment] when creating dhcp address pools, it is advisable to prioritize the configuration of this command \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# network 192 168 0 0 255 255 0 0 address pool \[command] address pool a b c d a b c d \[purpose] specify the range of ip addresses assigned to client by dhcp server \[parameter] parameter description a b c d start ip address and end ip address in the format a b c d/a b \[view] dhcp view \[comment] before specifying the address pool range, user should first use the network command to confirm the subnet to which the addresses belong if this address pool is already bound to a specific vlan, any necessary modifications require unbinding and rebinding to take effect \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# address pool 192 168 1 1 192 168 10 1 dns \[command] dns ip address \[purpose] specify the dns server address \[parameter] parameter description ip address the format is a b c d/a b \[view] dhcp view \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# dns 8 8 8 8 lease time \[command] lease time default time max time \[purpose] specify ip address lease time \[parameter] parameter description default time default lease time max time maximum lease time \[view] dhcp view \[usage scenario] clients use ip addresses assigned by dhcp servers for network communication when the default lease time is reached, clients must either renew their lease or obtain a new ip address from the dhcp server if a client fails to renew its lease after the default lease time, it will continue using the ip address lease until it reaches the maximum lease time once the maximum lease time expires, the client must request a new ip address \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# lease time 6000 12000 routers \[command] routers a b c d \[purpose] specify the gateway address assigned to the dhcp client by the dhcp server \[parameter] parameter description a b c d ip address \[view] dhcp view \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# routers 192 168 1 1 option43 hex \[command] option43 hex value \[purpose] enable the option43 function of dhcp server \[parameter] parameter description value hexadecimal values should be entered according to the ac format requirements of different manufacturers and must comply with the tlv format \[view] dhcp view \[usage scenario] option 43 is used to specify the ip address of the ac for the ap so that the ap can establish a connection with the ac \[comment] before configuring option43, use the network command to verify the address's subnet if the address pool is already bound to a specific vlan, modify the relevant settings after making changes, unbind the pool and rebind it for the changes to take effect \[ use cases ] sonic(config)# dhcp pool 1 sonic(config dhcp pool 1)# option43 hex 8007000001ac100102 server identifier \[command] server identifier { ip address | loopback 0} no server identifier \[purpose] configure the ip address carried in the option 54 field of the dhcp offer message \[parameter] parameter description ip address the ip address carried in the option 54 field of the dhcp offer message loopback 0 use the ip address of device loopback 0 as the ip address carried in the option 54 field of the dhcp offer message \[view] dhcp view \[usage scenario] after obtaining an ip address via dhcp, the terminal populates the option 54 field in the request message with the ip address from the option 54 field in the offer message this informs other dhcp servers which specific dhcp server assigned the terminal its ip address \[ use cases ] sonic(config)# dhcp pool 1 sonic(config dhcp pool 1)# server identifier loopback 0 bootfile name \[command] bootfile name bootfile no bootfile name \[purpose] configure the boot configuration file name for dhcp clients \[parameter] parameter description bootfile string format, case sensitive, specifying the configuration file name \[view] dhcp view \[usage scenario] dhcp servers can provide network configuration parameters needed by clients, such as boot configuration files, in addition to assigning ip addresses to clients by configuring this command, the dhcp server includes the specified file name in offer and ack messages sent to clients subsequently, dhcp clients can use this file name to retrieve the boot configuration file from a designated file server \[ use cases ] sonic(config)# dhcp pool 1 sonic(config dhcp pool 1)# bootfile name test json next server \[command] next server ip address no next server \[purpose] configure the network server ip address to be used by dhcp client during the startup process \[parameter] parameter description ip address specifies the server ip address to be used by the dhcp client \[view] dhcp view \[usage scenario] in addition to assigning ip addresses to dhcp clients, dhcp servers can also allocate server ip addresses for providing network services to dhcp clients for example, some clients like ip phones may require connecting to a specified server to install software after obtaining an ip address automatically by executing this command to configure the server address that the client should use after automatically obtaining an ip address, the client will request configuration information from the specified server after acquiring an ip address automatically \[ use cases] sonic(config)# dhcp pool 1 sonic(config dhcp pool 1)# next server 192 168 0 10 capwap ac \[command] capwap ac ip address no capwap ac \[purpose] configure the dhcp client to connect to the controller's ip address \[parameter] parameter description ip address controller ip address \[view] dhcp view \[usage scenario] when the dhcp server assigns ip addresses to dhcp clients, it populates the option 138 field in the dhcp message with the controller's ip address upon receiving this address, the terminal can use it to connect to the controller and establish an online connection \[notes] before configuring capwap ac, use the network command to verify the address's subnet \[ use cases ] sonic(config)# dhcp pool 1 sonic(config dhcp pool 1)# capwap ac 192 168 0 1 tftp server \[command] tftp server server name \[purpose] configure the tftp server address for dhcp clients \[parameter] parameter description server name a case sensitive string specifying the tftp server address or domain name used by dhcp clients \[view] dhcp view \[usage scenario] after booting up, devices may need to access configuration files from a tftp server by configuring this option, dhcp clients can obtain the ip address of a tftp server while acquiring an ip address, enabling them to access the server after booting up to retrieve necessary information \[ use cases ] sonic(config)# dhcp pool 1 sonic(config dhcp pool 1)# tftp server 192 168 0 10 dhcp select server \[command] dhcp select server \[purpose] enable the dhcp server feature on the interface using the global address pool \[view] interface view \[comment] this command is used for the dhcp server when the dhcp server receives a dhcp message from a dhcp client, it will look up a suitable ip address from the address pool to assign to the client \[ use cases ] sonic(config)# interface ethernet 1 sonic(config if 1)# dhcp select server dhcp class \[command] dhcp class name \[purpose] creating a dhcp user class \[view] system configuration view \[usage scenario] creating a dhcp user class involves configuring a set of parameters and options that are associated with a specific class of dhcp clients \[ use cases ] sonic(config)# dhcp class test1 sonic(config dhcp class test1)# if match rule \[command] if match rule rule id option 93 hex value if match rule rule id option 82 remote id value \[purpose] configuring matching rules for dhcp user classes \[parameter] parameter description rule id range 1 16, the higher number has higher priority \[view] dhcp class view \[usage scenario] the dhcp server determines the dhcp user class to which a dhcp client belongs by matching the messages sent by the dhcp client with the rules configured in this command within the dhcp user class view, multiple matching rules can be configured by repeatedly executing the "if match" command as long as any rule successfully matches, the dhcp client is considered part of that user class, and the contents bound to the option group for that user class can be assigned to the client \[ use cases ] sonic(config)# dhcp class test1 sonic(config dhcp class test1)# if match rule 1 option 93 hex 0000 dhcp option group \[command] dhcp option group id \[purpose] create a dhcp option group and enter the option group view \[parameter] parameter description id the range of values from 1 to 65535 \[view] system configuration view \[ use cases ] sonic(config)# dhcp option group 1 sonic(config dhcp option group 1)# bootfile name test txt sonic(config dhcp option group 1)# tftp server 150 1 0 1 option group \[command] option group id \[purpose] configure the association between user classes and option groups for dhcp address pools \[parameter] parameter description id option group id \[view] dhcp class view \[usage scenario] when a terminal binds to an option group, it will use the parameters configured within that bound option group when matching the class during dhcp ip acquisition \[comment] a dhcp user class can only be associated with one dhcp option group \[ use cases ] sonic (config)# dhcp class test sonic (config dhcp class test)# option group 1 class address pool \[command] class name address pool ip address start ip address end \[purpose] configure the assignment of specific address pools based on the user class of the dhcp address pool \[parameter] parameter description name dhcp user class name ip address start ip address and end ip address in the format a b c d/a b \[view] dhcp view \[usage scenario] after binding to a class, the dhcp server assigns the terminal an ip address within the range specified by that class upon successful matching \[comment] before specifying an address pool range, use the network command to confirm the address belongs to the correct subnet \[ use cases ] sonic# configure terminal sonic(config)# dhcp pool test sonic(config dhcp pool test)# class test address pool 140 1 1 200 140 1 1 220 sonic(config dhcp pool test)# do show dhcp pool info v4 \ pool name test subnet 140 1 1 0/24 lease na na lease default time 3600 lease max time 7200 class name test lease 140 1 1 200 140 1 1 220 dhcp failover \[command] dhcp failover \[purpose] configure the dhcp address pool to be bound with a dual active backup \[view] dhcp view \[usage scenario] this scenario applies to environments like mc lag where dual device load balancing is implemented in such setups, dhcp servers are deployed on two devices that share the same address pool if one of the servers fails, the other server takes over and manages the allocation of all dhcp addresses from the shared pool this redundancy ensures continuous availability and reliability of ip address assignments for network clients \[ use cases ] sonic# configure terminal sonic(config)# dhcp failover sonic(config dhcp failover)# address loopback 0 \[command] address loopback 0 \[purpose] this command specifies the source ip address for dhcp server high availability protocol interaction as the local loopback0 address \[view] dhcp failover view \[ use cases ] sonic(config)# dhcp failover ceshi sonic(config dhcp failover ceshi)# address loopback 0 peer address \[command] peer address a b c d \[purpose] this command specifies the destination ip address for dhcp server high availability protocol interaction \[parameter] parameter description a b c d ip address of the peer device interface \[view] dhcp failover view \[ use cases ] sonic(config)# dhcp failover ceshi sonic(config dhcp failover ceshi)# peer address 30 102 0 216 role \[command] role {primary|secondary} \[purpose] configure the server role during dual active backup \[parameter] parameter description primary primary server secondary backup server \[view] dhcp failover view \[comment] the primary dhcp server allows you to specify a split value, which determines the percentage of the address pool it will manage \[ use cases ] sonic(config)# dhcp failover ceshi sonic(config dhcp failover ceshi)# role primary max response delay \[command] max response delay interval \[purpose] configure the max response delay for communication interruption during dual active backup \[parameter] parameter description interval time interval, range 30 3600 seconds, default is 60 seconds \[view] dhcp failover view \[usage scenario] if a server does not receive messages from its failover peer after the set time, it considers the communication link between the two servers interrupted each server then manages its own address pool when receiving a dhcp request from a client, both servers will allocate different ip addresses, with the client confirming the address from the first dhcp relay message once communication between the dhcp servers is restored, they will synchronize the address allocation that occurred during the failure \[ use cases ] sonic(config)# dhcp failover ceshi sonic(config dhcp failover ceshi)# max response delay 30 auto partner down \[command] auto partner down second \[purpose] enable the timed delay for dual active backup \[parameter] parameter description second time interval, range 1 3600 \[view] dhcp failover view \[usage scenario] when the two servers are in a state of communication link interruption, after the configured delay timer, the servers will automatically enter the partner down state the surviving dhcp server will consider its peer to be down after the lease time configured for the address pool, the active server will have full authority to allocate addresses from the entire address pool to clients \[ use cases ] sonic(config)# dhcp failover ceshi sonic(config dhcp failover ceshi)# auto partner down 60 split \[command] split percent \[purpose] set the server address allocation weight \[parameter] parameter description percent load balancing split percent,range 0 100 \[view] dhcp failover view \[usage scenario] when the two servers can achieve load balancing and failover, they calculate a hash value in the range of 1 255 based on the client identifier field in the dhcp request message these 255 values are divided according to the configured weight ratio for example, if the primary server's weight is set to 80 and the backup server's weight is set to 20, then 80% of these 255 values will be allocated to the primary server, and the remaining 20% will go to the backup server \[ use cases ] sonic(config)# dhcp failover ceshi sonic(config dhcp failover ceshi)# split 80
