跳转到内容
Ask AI

DHCP Server Configuration

此内容尚不支持你的语言。

[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

[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 |
+--------------+-----------------+-------------------+--------------------+

[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

[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

[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)#

[Command] network A.B.C.D mask

[Purpose] Specify the network segment where the DHCP server assigns the IP address to the Client

[Parameter]

ParameterDescription
A.B.C.Dip-address
masksubnet 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

[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]

ParameterDescription
A.B.C.DStart 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

[Command] dns ip_address

[Purpose] Specify the DNS server address

[Parameter]

ParameterDescription
ip_addressThe 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

[Command] lease-time default_time max_time

[Purpose] Specify IP address lease time

[Parameter]

ParameterDescription
default_timeDefault lease time
max_timeMaximum 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

[Command] routers A.B.C.D

[Purpose] Specify the gateway address assigned to the DHCP client by the DHCP server

[Parameter]

ParameterDescription
A.B.C.DIP address

[View] DHCP view

[Use Cases]

sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)# routers 192.168.1.1

[Command] option43 hex value

[Purpose] Enable the option43 function of DHCP Server

[Parameter]

ParameterDescription
valueHexadecimal 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

[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]

ParameterDescription
ip_addressThe IP address carried in the Option 54 field of the DHCP Offer message
loopback 0Use 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

[Command] bootfile-name bootfile no bootfile-name

[Purpose] Configure the boot configuration file name for DHCP clients

[Parameter]

ParameterDescription
bootfileString 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

[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]

ParameterDescription
ip_addressSpecifies 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

[Command] capwap-ac ip_address no capwap-ac

[Purpose] Configure the DHCP client to connect to the controller’s IP address

[Parameter]

ParameterDescription
ip_addressController 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

[Command] tftp-server server_name

[Purpose] Configure the TFTP Server Address for DHCP Clients

[Parameter]

ParameterDescription
server_nameA 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

[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

[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)#

[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]

ParameterDescription
rule_idrange 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

[Command] dhcp option-group id

[Purpose] Create a DHCP option group and enter the option group view

[Parameter]

ParameterDescription
idThe 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

[Command] option-group id

[Purpose] Configure the association between user classes and option groups for DHCP address pools.

[Parameter]

ParameterDescription
idOption 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

[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]

ParameterDescription
nameDHCP user class name
ip_addressStart 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