---
title: DHCP Server Configuration
slug: enterprise-v5p2/dhcp-server-configuration
description: ip service
createdAt: 2025-11-14T03:58:42.429Z
---

### <font color="#1d50a2">show dhcp pool info ip-version \{v4|v6\}</font>

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

```plaintext
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 |
+-----------+---------------+---------------+----------------+-----------------+-----------------------+-------------------+-----------+-----------------+
```

### <font color="#1d50a2">show dhcp pool ip-in-use</font>

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

```plaintext
sonic# show dhcp pool ip-in-use
Reading leases from /var/lib/dhcp/dhcpd.leases
IP         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:00
20.1.1.23  00:00:12:01:01:03 XINERTEL   active       2024-02-26 09:27:00  2024-02-26 09:37:00
20.1.1.22  00:00:12:01:01:02 XINERTEL   active       2024-02-26 09:27:00  2024-02-26 09:37:00
total lease :3
```

### <font color="#1d50a2">show dhcp pool expired</font>

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

```plaintext
sonic# show dhcp pool expired
Reading leases from /var/lib/dhcp/dhcpd.leases
IP           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:30
20.1.1.9    00:00:02:01:01:09 -NA-     free         2024-02-26 09:09:57  2024-02-26 09:11:30
total lease :2
```

### <font color="#1d50a2">show dhcp class</font>

**\[Command]**
**show dhcp class**

**\[Purpose]**
Display DHCP class

**\[View]**
System view

**\[Use Cases]**

```plaintext
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
```

### <font color="#1d50a2">show dhcp option-group</font>

**\[Command]**
**show dhcp option-group**

**\[Purpose]**
Display dhcp option-group

**\[View]**
System view

**\[Use Cases]**

```plaintext
sonic# show dhcp option-group
dhcp option-group 1
 bootfile-name ftp://teraspek:teraspek@150.1.0.1/test.txt
 option43 hex 8888 force
 tftp-server 150.1.0.1
dhcp option-group 2
 bootfile-name ftp://teraspek:teraspek@150.1.0.1/ppap.txt
 option43 hex 8888 force
 tftp-server 150.1.0.1
```

### <font color="#1d50a2">show dhcp failover info</font>

**\[Command]**
**show dhcp failover info**

**\[Purpose]**
Show DHCP server dual-active backup configuration

**\[View]**
System View

**\[Use Cases]**

```none
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%
```

### <font color="#1d50a2">show dhcp pool config</font>

**\[Command]**
**show dhcp pool config**

**\[Purpose]**
Show the binding interface status of the DHCP Server service

**\[View]**
System View

**\[Use Cases]**

```none
sonic# show dhcp pool config
+-----------------+----------------------+
| Interface       | dhcp select server   |
+=================+======================+
| Ethernet11      | true                 |
+-----------------+----------------------+
| Vlan100         | true                 |
+-----------------+----------------------+
| PortChannel0002 | true                 |
+-----------------+----------------------+
```

### <font color="#1d50a2">dhcp pool</font>

**\[Command]**
**dhcp pool** *name*
**no dhcp pool** *name*

**\[Purpose]**
Create address pools

**\[View]**
System configuration view

**\[Use Cases]**

```plaintext
sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)#
```

### <font color="#1d50a2">network</font>

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

```plaintext
sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)# network 192.168.0.0 255.255.0.0
```

### <font color="#1d50a2">address-pool</font>

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

```plaintext
sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)# address-pool 192.168.1.1 192.168.10.1
```

### <font color="#1d50a2">static-bind ip-address *A.B.C.D* mac-address *nn\:nn\:nn\:nn\:nn*\:nn</font>

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

```plaintext
sonic(config-dhcp-pool-a)# static-bind ip-address 1.1.1.11 mac-address 00:00:00:00:00:01
```

### <font color="#1d50a2">dns</font>

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

```plaintext
sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)# dns 8.8.8.8
```

### <font color="#1d50a2">lease-time</font>

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

```plaintext
sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)# lease-time 6000 12000
```

### <font color="#1d50a2">routers</font>

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

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

### <font color="#1d50a2">server\_detect enable</font>

**\[Command]**
**server\_detect enable**
**no server\_detect enable**

**\[Purpose]**
Enable DHCP server connectivity probing function

**\[View]**
DHCP Relay view

**\[Use Cases]**

```plaintext
sonic(config-dhcp-relay-dhcp_relay__v4)# server_detect enable
```

### <font color="#1d50a2">server\_detect interval</font>

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

```plaintext
sonic(config-dhcp-relay-dhcp_relay__v4)# server_detect interval 60
```

### <font color="#1d50a2">option43 hex</font>

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

```plaintext
sonic(config)# dhcp pool 1
sonic(config-dhcp-pool-1)# option43 hex 8007000001ac100102
```

### <font color="#1d50a2">bootfile-name</font>

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

```plaintext
sonic(config)# dhcp pool 1
sonic(config-dhcp-pool-1)# bootfile-name test.json
```

### <font color="#1d50a2">next-server</font>

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

```plaintext
sonic(config)# dhcp pool 1
sonic(config-dhcp-pool-1)# next-server 192.168.0.10
```

### <font color="#1d50a2">tftp-server</font>

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

```plaintext
sonic(config)# dhcp pool 1
sonic(config-dhcp-pool-1)# tftp-server 192.168.0.10
```

### <font color="#1d50a2">dhcp select server</font>

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

```plaintext
sonic(config)# interface ethernet 1
sonic(config-if-1)# dhcp select server
```

### <font color="#1d50a2">dhcp class</font>

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

```plaintext
sonic(config)# dhcp class test1
sonic(config-dhcp-class-test1)#
```

### <font color="#1d50a2">if-match rule</font>

**\[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.

**\[Notes]**
Currently, only filtering of option 93 is supported.

**\[Use Cases]**

```plaintext
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]**

| **Parameter** | **Description**                     |
| ------------- | ----------------------------------- |
| *id*          | The range of values from 1 to 65535 |

**\[View]**
System configuration view

**\[Use Cases]**

```plaintext
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
```

### <font color="#1d50a2">class option-group</font>

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

```plaintext
sonic(config)# dhcp pool test
sonic (config-dhcp-pool-test)# class pc option-group 1
sonic (config-dhcp-pool-test)# class x86 option-group 2
```

### <font color="#1d50a2">class address-pool</font>

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

```plaintext
sonic# configure terminal
sonic(config)# dhcp pool test
sonic(config-dhcp-pool-test)# class test address-pool 192.168.1.1 192.168.10.1
sonic(config-dhcp-pool-test)# class public address-pool 192.168.20.1 192.168.30.1
```

###

