---
title: DHCP Server Configuration
slug: routing/dhcp-server-configuration
createdAt: 2025-12-04T04:06:51.837Z
---

## <font color="#1d50a2">DHCP Server Configuration</font>

### <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
+===========+===============+===============+================+=================
| 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 |
+-----------------------+-------------------+-----------+-----------------+
```

### <font color="#1d50a2">show dhcp pool ip-in-use \[A.B.C.D/A\:\:B\]</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 \[A.B.C.D/A\:\:B\]</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]**
View DHCP server dual-active backup configuration

**\[View]**
System view

**\[Use Cases]**

```plaintext
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">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 ip-address *mask*</font>

**\[Command]**
**network *ip-address* *mask***

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

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                                          |
| ------------------------------------------ | ------------------------------------------------------------------------------------- |
| *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]**

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

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

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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">option43 hex *value*</font>

**\[Command]**
**option43 hex *value***

**\[Purpose]**
Enable the option43 function of DHCP Server

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                                     |
| ------------------------------------------ | -------------------------------------------------------------------------------- |
| *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 *bootfile*</font>

**\[Command]**
**bootfile-name *bootfile***

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

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                          |
| ------------------------------------------ | --------------------------------------------------------------------- |
| *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 *ip-address*</font>

**\[Command]**
**next-server *ip-address***

**\[Purpose]**
Configure the network server IP address to be used by DHCP client during the startup process

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                  |
| ------------------------------------------ | ------------------------------------------------------------- |
| *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 *server-name*</font>

**\[Command]**
**tftp-server *server-name***

**\[Purpose]**
Configure the TFTP Server Address for DHCP Clients

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                                                   |
| ------------------------------------------ | ---------------------------------------------------------------------------------------------- |
| *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 *name*</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 *ID*</font>

**\[Command]**
**if-match rule *ID* option 93 hex *VALUE***
**if-match rule *ID* option 82 remote-id *VALUE***

**\[Purpose]**
Configuring matching rules for DHCP user classes

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                                                          |
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| *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]**

```plaintext
sonic(config)# dhcp class test1
sonic(config-dhcp-class-test1)# if-match rule 1 option 93 hex 0000
```

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

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

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

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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 name option-group *ID*</font>

**\[Command]**
**class *name* option-group *ID***

**\[Purpose]**
Bind user classes to option groups.

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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 name address-pool *ip-address-start* *ip-address-end*</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]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                     |
| ------------------------------------------ | ---------------------------------------------------------------- |
| *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
```

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

**\[Command]**
**failover *String***

**\[Purpose]**
Configure the DHCP address pool to be bound with a dual-active backup

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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]**

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

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

**\[Command]**
**address**

**\[Purpose]**
This feature configures the local IP address used for protocol interactions between two DHCP servers in a DHCP failover scenario.

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *Loopback0*                                | Loopback0 IP address                         |
| *A.B.C.D*                                  | IP address of the local device interface     |

**\[View]**
DHCP Failover view

**\[Use Cases]**

```plaintext
sonic(config)# dhcp failover ceshi
sonic(config-dhcp-failover-ceshi)# address Loopback0
```

### <font color="#1d50a2">peer address</font>

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

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *A.B.C.D*                                  | IP address of the peer device interface      |

**\[View]**
DHCP Failover view

**\[Use Cases]**

```plaintext
sonic(config)# dhcp failover ceshi
sonic(config-dhcp-failover-ceshi)# peer address 30.102.0.216
```

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

**\[Command]**
**role**

**\[Purpose]**
Configure the server role during dual-active backup

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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]**

```plaintext
sonic(config)# dhcp failover ceshi
sonic(config-dhcp-failover-ceshi)# role primary
```

### <font color="#1d50a2">max-response-delay</font>

**\[Command]**
**max-response-delay**

**\[Purpose]**
Configure the max-response-delay for communication interruption during dual-active backup

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font>                |
| ------------------------------------------ | ----------------------------------------------------------- |
| *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]**

```plaintext
sonic(config)# dhcp failover ceshi
sonic(config-dhcp-failover-ceshi)# max-response-delay 30
```

### <font color="#1d50a2">auto-partner-down</font>

**\[Command]**
**auto-partner-down**

**\[Purpose]**
Enable the timed delay for dual-active backup

**\[Parameter]**

| <font color="#0C121D">**Parameter**</font> | <font color="#0C121D">**Description**</font> |
| ------------------------------------------ | -------------------------------------------- |
| *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]**

```plaintext
sonic(config)# dhcp failover ceshi
sonic(config-dhcp-failover-ceshi)# auto-partner-down 60
```

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

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

```plaintext
sonic(config)# dhcp failover ceshi
sonic(config-dhcp-failover-ceshi)# split 80
```

