Configuring DHCP Server (IPv4)
Introduction
Dynamic Host Configuration Protocol (DHCP) is a protocol that dynamically configures and centrally manages the network parameters of the hosts based on TCP / IP protocol, which can be used to:
Dynamically assign IP addresses to network hosts. Assign an IP address to a host via DHCP with an expiration time (often called a lease time). The default lease time is one hour.
Provide other network parameters for network hosts, such as the IP address of the DNS server, domain name information and default gateway address.
Configuration Notes
Pay attention to the following points when configuring DHCP server:
Enabling DHCP client, DHCP relay or DHCP server functions in block VLAN is not supported.
Enabling DHCP client, DHCP snooping/relay and DHCP server functions in the same VLAN is not supported. Where DHCP snooping and DHCP relay don’t have this limitation, they can be enabled in the same VLAN.
Enabling both DHCP relay and DHCP server functions in the same VRF is supported.
If both DHCP server and DHCP relay are deployed on the same switch, don’t use the VLAN interface enabled with DHCP server to connect to the remote DHCP server.
DHCP server feature supports only IPv4, and doesn’t support IPv6.
DHCP server supports VRF by binding the address pool and the VLAN interface (which is connected to the DHCP client side) to the same VRF.
One VRF will run a DHCP server instance. So different VRFs will have different DHCP server instances.
In each VRF, at most 1000 DHCP clients are allowed.Â
Multiple address pools can be configured in the same VRF, but there cannot be address overlap between individual pools. However, address pools in different VRFs do not have this restriction.
When multiple address ranges are configured under one address pool, there should be no address overlap between these ranges.
The default router is the default gateway of the DHCP client, which is required to be on the same network segment as the address pool.
In a VRRP topology, if the DHCP server function is enabled, the address pool configured on the master cannot overlap with that configured on the backup switch.
Adding, deleting and modifying any parameter in the DHCP address pool will result in the deletion of DHCP server binding table in this VRF.
Configuring DHCP Server
Procedure
Step 1Â Â Â Â Create an address pool and specify the IPv4 network segment that can be dynamically allocated to the DHCP clients.
set protocols dhcp server pool <pool-name> network <IPv4Net>
Step 2Â Â Â Â Configure the VLAN interface connected to the DHCP client.
set vlans vlan-id <vlan-id>
 set vlans vlan-id <vlan-id> l3-interface <interface-name>
 set l3-interface vlan-interface <interface-name> address <ip-address> prefix-length <number>
Step 3Â Â Â Â (Optional) Associate the VLAN interface with a VRF.
 If you want to configure the DHCP server for a user-defined VRF, you need to configure this step.
 set l3-interface vlan-interface <interface-name> vrf <vrf-name>
Step 4    (Optional) Configure the lower and upper boundaries of an address range in the address pool. Â
     set protocols dhcp server pool <pool-name> range <range-name> low <ipv4-address>
     set protocols dhcp server pool <pool-name> range <range-name> high <ipv4-address>
NOTEs:
The address range is optional. If not configured, it means that all the IP addresses in the address pool are available for address assignment. However, if configured, only addresses in the range can be used for address assignment.
When multiple address ranges are configured under an address pool, there should be no address overlap between different ranges.
Step 5Â Â Â Â (Optional) Configure a lease time for the IP addresses in an address pool.
set protocols dhcp server pool <pool-name> lease-time <lease-time>
 By default, the lease time is 60 minutes.
Step 6Â Â Â Â (Optional) In a DHCP relay scenario, the following command needs to be used to enable the DHCP server function on the Layer 3 interface.
 set protocols dhcp server interface <interface-name> disable <true | false>
Step 7Â Â Â Â (Optional) Configure the IP address of the DNS server and domain name for the DHCP address pool.
 a) Configure the IP address of the DNS server.
 set protocols dhcp server pool <pool-name> dns-server <dns-server-ip>
NOTEs:
By default, no DNS server IP address is configured in a DHCP address pool.
Each address pool can be configured with a maximum of eight DNS server IP addresses.
b) Configure a domain name for the DHCP clients.
set protocols dhcp server pool <pool-name> domain-name <domain-name>
Step 8Â Â Â Â (Optional) Configure a default gateway address for the DHCP clients.
 set protocols dhcp server pool <pool-name> default-router <router-ip address>
Step 9Â Â Â Â (Optional) Assign a DHCP address pool to a VRF.
         set protocols dhcp server pool <pool-name> vrf <vrf-name>
 By default, no VRF is configured for an address pool, the address pool belongs to the default VRF.
Step 10Â Â Â Â Â (Optional) Configure the IP address for the TFTP server. After the client sends request packets to the DHCP server, the TFTP server with this IP address will be replied.
set protocols dhcp server pool <pool-name> tftp-server <tftp-server-ip>
Step 11Â Â Â Â Â (Optional) Configure the IP address for the Syslog server. After the client sends request packets to the DHCP server, the Syslog server with this IP address will be replied.
set protocols dhcp server pool <pool-name> log-server <log-server-ip>
Step 12Â Â Â Â Â (Optional) Configure the file name with path on the TFTP server or the file name with URL on the HTTP server. After the client sends request packets to the DHCP server, the file name with path or URL will be replied.
set protocols dhcp server pool <pool-name> bootfile-name {file-path <file-path> | url <url>}
Step 13Â Â Â Â Â (Optional) Configure the file name with path on the TFTP server or the file name with URL on the HTTP server. After the client sends request packets to the DHCP server, the file name with path or URL will be replied.
set protocols dhcp server pool <pool-name> bootfile-name {file-path <file-path> | url <url>}
NOTEs:
If commands of set protocols dhcp server pool tftp-server and set protocols dhcp server pool bootfile-name url are both configured, the TFTP server is valid, and error prompt appears for the script in the TFTP server cannot be obtained.
Commonly, the commands of TFTP server and Syslog server are applied for the ZTP function. For details of ZTP, see Zero Touching Provisioning (ZTP).
By default, no TFTP and Syslog server IP address is configured in a DHCP address pool.
Each address pool can be respectively configured with one TFTP server address and one Syslog server address.
If you configure the IP address of TFTP server or Syslog server through ZTP provision script, it will be used in preference to the configurations in the DHCP server.
Configuration Example
Networking Requirements
Figure 1. DHCP Server Configuration Example
As shown in Figure 1, an enterprise has planned two network segments for the office terminals. PCs in the network segment 10.1.10.0/24 are the fixed terminals, and the network segment 10.2.10.0/24 is used for temporary users accessing to the network. To facilitate unified administration, the enterprise terminals can automatically obtain IP address and DNS server address from the DHCP server.
By configuring DHCP server on Pica8 switch, IP address and DNS server address can be dynamically assigned to the terminals in the two separate network segments of the enterprise. Among them, the PCs in network segment 10.1.10.0/24 are the fixed office terminal, and the IP lease time is 30 days; the network segment 10.2.10.0/24 provides temporary accesses to the network for business travelers, and the IP lease time is 2 days.
Procedure
Step 1Â Â Â Â Configure the VLAN interface connected to the DHCP client.
admin@Xorplus# set vlans vlan-id 100
admin@Xorplus# set vlans vlan-id 200
admin@Xorplus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 100
admin@Xorplus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 200
admin@Xorplus# set vlans vlan-id 100 l3-interface vlan100
admin@Xorplus# set vlans vlan-id 200 l3-interface vlan200
admin@Xorplus# set l3-interface vlan-interface vlan100 address 10.1.10.11 prefix-length 24
admin@Xorplus# set l3-interface vlan-interface vlan200 address 10.2.10.11 prefix-length 24
Step 2Â Â Â Â Create two address pools and specify the IPv4 network segment that can be dynamically allocated to the DHCP clients.
admin@Xorplus# set protocols dhcp server pool pool1 network 10.1.10.0/24
admin@Xorplus# set protocols dhcp server pool pool2 network 10.2.10.0/24
Step 3Â Â Â Â Configure the lease time for the IP addresses in the address pool.
admin@Xorplus# set protocols dhcp server pool pool1 lease-time 43200
admin@Xorplus# set protocols dhcp server pool pool2 lease-time 2880
         By default, the IP address lease is one hour.
Step 4Â Â Â Â Configure the IP address of the DNS server and domain name for the DHCP clients.
 a) Configure the IP address of the DNS server for each address pool.
         By default, no DNS server is configured in an address pool.
 b) Configure domain name for the DHCP clients.
Verify the Configuration
The IP address and DNS server address of the 10.1.10.0/24 network segment can be obtained from the DHCP server by the PCs in the zone of DHCP client A, and the IP address and DNS server address of the 10.2.10.0/24 network segment can be obtained from the DHCP server by the PCs in the zone of DHCP client B.
Run the command run show dhcp server binding on the switch to view the allocated IP address binding information.
Â
Â
Copyright © 2024 Pica8 Inc. All Rights Reserved.