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+===========+===============+===============+================+=================| test | 192.168.200.0 | 255.255.255.0 | 192.168.200.10 | 192.168.200.100+-----------+---------------+---------------+----------------+-----------------+-----------------------+-------------------+-----------+-----------------+| Default Lease Time(s) | Max Lease Time(s) | Bind Info | DNS |+=======================+===================+===========+=================+| 6000 | 12000 | Vlan43 | 114.114.114.114 |+-----------------------+-------------------+-----------+-----------------+show dhcp pool ip-in-use [A.B.C.D/A::B]
Section titled “show dhcp pool ip-in-use [A.B.C.D/A::B]”[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 [A.B.C.D/A::B]
Section titled “show dhcp pool expired [A.B.C.D/A::B]”[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 pcif-match rule 1 option 93 hex 0000dhcp class test1dhcp class x86if-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 1bootfile-name ftp://teraspek:teraspek@150.1.0.1/test.txtoption43 hex 8888 forcetftp-server 150.1.0.1dhcp option-group 2bootfile-name ftp://teraspek:teraspek@150.1.0.1/ppap.txtoption43 hex 8888 forcetftp-server 150.1.0.1show dhcp failover info
Section titled “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 : ceshiLocal-address : 30.102.0.230Peer-address : 30.102.0.216Role : primaryMax_response_delay : 60Heartbeat_inteval : 20Local-state : normalPeer-state : normalSplit : 50%dhcp pool
Section titled “dhcp pool”[Command] dhcp poolname no dhcp poolname
[Purpose] Create address pools
[View] System configuration view
[Use Cases]
sonic# configure terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)#network ip-address
Section titled “network ip-address”[Command] networkip-address mask
[Purpose] Specify the network segment where the DHCP server assigns the IP address to the Client
[Parameter]
| Parameter | Description |
|---|---|
| ip-address | Supports configuration of IPv4 and IPv6 addresses in the format of A.B.C.D/A::B |
| Mask | IPv4 subnet mask in dotted decimal format; IPv6 network prefix in X:X:X:X:X:X:X:X |
[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-poolip-address ip-address
[Purpose] Specify the range of IP addresses assigned to client by DHCP server
[Parameter]
| Parameter | Description |
|---|---|
| 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)# address-pool 192.168.1.1 192.168.10.1[Command] dnsip-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-timedefault-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] routersA.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.1option43 hex
Section titled “option43 hex”[Command] option43 hexvalue
[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-namebootfile
[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-serverip-address
[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-serverserver-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 classname
[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 ruleIDoption 93 hexVALUE if-match ruleIDoption 82 remote-idVALUE
[Purpose] Configuring matching rules for DHCP user classes
[Parameter]
| Parameter | Description |
|---|---|
| ID | Rule ID, the range of values from 1 to 16. A smaller number indicates a higher priority |
| VALUE | Specifies the content used to match the specified option in the message, in hexadecimal string format |
[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 0000dhcp option-group
Section titled “dhcp option-group”[Command] dhcp option-groupID
[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 name option-group
Section titled “class name option-group”[Command] classnameoption-groupID
[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 name address-pool
Section titled “class name address-pool”[Command] classnameaddress-poolip-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.1failover
Section titled “failover”[Command] failoverString
[Purpose] Configure the DHCP address pool to be bound with a dual-active backup
[Parameter]
| Parameter | Description |
|---|---|
| String | failover name |
[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 terminalsonic(config)# dhcp pool testsonic(config-dhcp-pool-test)# failover testaddress
Section titled “address”[Command] address
[Purpose] This feature configures the local IP address used for protocol interactions between two DHCP servers in a DHCP failover scenario.
[Parameter]
| Parameter | Description |
|---|---|
| Loopback0 | Loopback0 IP address |
| A.B.C.D | IP address of the local device interface |
[View] DHCP Failover view
[Use Cases]
sonic(config)# dhcp failover ceshisonic(config-dhcp-failover-ceshi)# address Loopback0peer address
Section titled “peer address”[Command] peer address
[Purpose] This feature configures the peer IP address used for protocol interactions between two DHCP servers in a DHCP failover scenario.
[Parameter]
| Parameter | Description |
|---|---|
| A.B.C.D | IP address of the peer device interface |
[View] DHCP Failover view
[Use Cases]
sonic(config)# dhcp failover ceshisonic(config-dhcp-failover-ceshi)# peer address 30.102.0.216[Command] role
[Purpose] Configure the server role during dual-active backup
[Parameter]
| Parameter | Description |
|---|---|
| primary | Primary server |
| Secondary | backup server |
[View] DHCP Failover view
[Notes] 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 ceshisonic(config-dhcp-failover-ceshi)# role primarymax-response-delay
Section titled “max-response-delay”[Command] max-response-delay
[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 ceshisonic(config-dhcp-failover-ceshi)# max-response-delay 30auto-partner-down
Section titled “auto-partner-down”[Command] auto-partner-down
[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 ceshisonic(config-dhcp-failover-ceshi)# auto-partner-down 60[Command] split
[Purpose] Set the server address allocation weight
[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 ceshisonic(config-dhcp-failover-ceshi)# split 80