DHCP Server 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]
View the status and configuration of the created DHCP address pool
[View]
System view
[Use Cases]
sonic# show dhcp pool info ip-version v4+-----------+---------------+---------------+----------------+-----------------+-----------------------+-------------------+-----------+-----------------+| Pool Name | Network | Mask | Lease Start | Lease End | Default Lease Time(s) | Max Lease Time(s) | Bind Info | DNS |+===========+===============+===============+================+=================+=======================+===================+===========+=================+| test | 192.168.200.0 | 255.255.255.0 | 192.168.200.10 | 192.168.200.100 | 6000 | 12000 | Vlan43 | 114.114.114.114 |+-----------+---------------+---------------+----------------+-----------------+-----------------------+-------------------+-----------+-----------------+show dhcp pool ip-in-use
Section titled “show dhcp pool ip-in-use”[Command]
**show dhcp pool ip-in-use ** [ A.B.C.D/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-useReading leases from /var/lib/dhcp/dhcpd.leasesIP MAC hostname binding state starts ends=====================================================================================================20.1.1.41 00:00:12:01:01:15 XINERTEL active 2024-02-26 09:27:00 2024-02-26 09:37:0020.1.1.23 00:00:12:01:01:03 XINERTEL active 2024-02-26 09:27:00 2024-02-26 09:37:0020.1.1.22 00:00:12:01:01:02 XINERTEL active 2024-02-26 09:27:00 2024-02-26 09:37:00total lease :3show dhcp pool expired
Section titled “show dhcp pool expired”[Command]
**show dhcp pool expired ** [ A.B.C.D/A::B ]
[Purpose]
View expired IP addresses in the DHCP address pool
[View]
System view
[Usage Scenario] Display IP addresses that were previously allocated in the DHCP address pool but have expired their lease.
[Use Cases]
sonic# show dhcp pool expiredReading leases from /var/lib/dhcp/dhcpd.leasesIP MAC hostname binding state starts ends=====================================================================================================20.1.1.10 00:00:02:01:01:0a -NA- free 2024-02-26 09:09:57 2024-02-26 09:11:3020.1.1.9 00:00:02:01:01:09 -NA- free 2024-02-26 09:09:57 2024-02-26 09:11:30total lease :2show dhcp class
Section titled “show dhcp class”[Command]
show dhcp class
[Purpose]
Display DHCP class
[View]
System view
[Use Cases]
sonic# show dhcp classdhcp class pc if-match rule 1 option 93 hex 0000dhcp class test1dhcp class x86 if-match rule 1 option 93 hex 0001show dhcp option-group
Section titled “show dhcp option-group”[Command]
show dhcp option-group
[Purpose]
Display dhcp option-group
[View]
System view
[Use Cases]
sonic# show dhcp option-groupdhcp option-group 1 bootfile-name ftp://teraspek:teraspek@150.1.0.1/test.txt option43 hex 8888 force tftp-server 150.1.0.1dhcp option-group 2 bootfile-name ftp://teraspek:teraspek@150.1.0.1/ppap.txt option43 hex 8888 force tftp-server 150.1.0.1show dhcp failover info
Section titled “show dhcp failover info”[Command] show dhcp failover info
[Purpose] Show DHCP server dual-active backup configuration
[View] System View
[Use Cases]
sonic# show dhcp failover info--------------------------------------------------Failover-name : ceshiLocal-address : 30.102.0.230Peer-address : 30.102.0.216Role : primaryMax_response_delay : 60Heartbeat_inteval : 20Local-state : normalPeer-state : normalSplit : 50%show dhcp pool config
Section titled “show dhcp pool config”[Command] show dhcp pool config
[Purpose] Show the binding interface status of the DHCP Server service
[View] System View
[Use Cases]
sonic# show dhcp pool config+-----------------+----------------------+| Interface | dhcp select server |+=================+======================+| Ethernet11 | true |+-----------------+----------------------+| Vlan100 | true |+-----------------+----------------------+| PortChannel0002 | true |+-----------------+----------------------+dhcp pool
Section titled “dhcp pool”[Command]
dhcp pool name
no dhcp pool name
[Purpose]
Create address pools
[View]
System configuration view
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)#network
Section titled “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
[Notes]
When creating DHCP address pools, it is advisable to prioritize the configuration of this command.
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# network 192.168.0.0 255.255.0.0address-pool
Section titled “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
[Notes]
Before specifying the address-pool range, user should first use the network command to confirm the subnet to which the addresses belong. Support configuring multiple address pools, with non-overlapping ranges. Each address pool must fall within the network scope. 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 terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# address-pool 192.168.1.1 192.168.10.1static-bind ip-address
Section titled “static-bind ip-address”[Command]
static-bind ip-address A.B.C.D mac-address nn:nn:nn:nn:nn:nn
[Purpose]
configure static MAC-IP binding on the DHCP server to assign fixed IP addresses to specified terminals
[Parameter]
| Parameter | Description |
|---|---|
| A.B.C.D | address in the format: A.B.C.D |
| nn:nn:nn:nn:nn:nn | termial mac address in the formart: HH:HH:HH:HH:HH:HH |
[View]
DHCP view
[Notes]
Configure the MAC-IP binding with addresses outside the DHCP pool range to ensure fixed IP assignment.
[Use Cases]
sonic(config-dhcp-pool-a)# static-bind ip-address 1.1.1.11 mac-address 00:00:00:00:00:01[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 terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# dns 8.8.8.8lease-time
Section titled “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 terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# lease-time 6000 12000routers
Section titled “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 terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# routers 192.168.1.1server_detect enable
Section titled “server_detect enable”[Command]
server_detect enable
no server_detect enable
[Purpose]
Enable DHCP server connectivity probing function
[View]
DHCP Relay view
[Use Cases]
sonic(config-dhcp-relay-dhcp_relay__v4)# server_detect enableserver_detect interval
Section titled “server_detect interval”[Command]
server_detect interval time
[Purpose]
Configure DHCP server connectivity probe packet interval
[Parameter]
| Parameter | Description |
|---|---|
| time | default 30 seconds, range 30-3600 |
[View]
DHCP Relay view
[Use Cases]
sonic(config-dhcp-relay-dhcp_relay__v4)# server_detect interval 60option43 hex
Section titled “option43 hex”[Command]
option43 hex value
[Purpose]
Enable the option43 function of DHCP Server
[Parameter]
| Parameter | Description |
|---|---|
| value | Hexadecimal number, according to the AC format requirements of different vendors |
[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.
[Use Cases]
sonic(config)# dhcp pool 1sonic(config-dhcp-pool-1)# option43 hex 8007000001ac100102bootfile-name
Section titled “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 1sonic(config-dhcp-pool-1)# bootfile-name test.jsonnext-server
Section titled “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 1sonic(config-dhcp-pool-1)# next-server 192.168.0.10tftp-server
Section titled “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 1sonic(config-dhcp-pool-1)# tftp-server 192.168.0.10dhcp select server
Section titled “dhcp select server”[Command]
dhcp select server
[Purpose]
Enable the DHCP server feature on the interface using the global address pool
[View]
Interface view
[Notes]
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 1sonic(config-if-1)# dhcp select serverdhcp class
Section titled “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 test1sonic(config-dhcp-class-test1)#if-match rule
Section titled “if-match rule”[Command]
if-match rule rule_idoption 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.
[Notes]
Currently, only filtering of option 93 is supported.
[Use Cases]
sonic(config)# dhcp class test1sonic(config-dhcp-class-test1)# if-match rule 1 option 93 hex 0000[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 1sonic(config-dhcp-option-group-1)# bootfile-name test.txtsonic(config-dhcp-option-group-1)# tftp-server 150.1.0.1class option-group
Section titled “class option-group”[Command]
class name option-group id
[Purpose]
Bind user classes to option groups.
[Parameter]
| Parameter | Description |
|---|---|
| name | DHCP class name |
| id | Option group ID |
[View]
DHCP view
[Notes]
A DHCP user class can only be associated with one DHCP option group
[Use Cases]
sonic(config)# dhcp pool testsonic (config-dhcp-pool-test)# class pc option-group 1sonic (config-dhcp-pool-test)# class x86 option-group 2class address-pool
Section titled “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
[Notes]
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 terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# class test address-pool 192.168.1.1 192.168.10.1sonic(config-dhcp-pool-test)# class public address-pool 192.168.20.1 192.168.30.1