DHCP Configuration
The Dynamic Host Configuration Protocol (DHCP) applies to various networks to ensure proper IP address allocation and save IP addresses.
Overview of DHCP
DHCP enables a client to dynamically obtain a valid IP address from a server.
Introduction
The Dynamic Host Configuration Protocol (DHCP) dynamically assigns IP addresses to hosts and centrally manages host configurations. DHCP uses the client/server model. A client applies to the server for configuration parameters, such as an IP address, subnet mask, and default gateway address; the server replies with the requested configuration parameters.
- DHCP client
A DHCP client exchanges messages with a DHCP server to obtain an IP address and other configuration parameters. A device interface can function as a DHCP client to dynamically obtain configuration parameters from a DHCP server. This facilitates configuration and centralized management.
- DHCP relay agent
A DHCP relay agent forwards DHCP messages exchanged between a DHCP client and a DHCP server that are located on different network segments, allowing them to complete their address configuration. The use of a DHCP relay agent eliminates the need for deploying a DHCP server on each network segment. This reduces network deployment costs and facilitates device management.
DHCP relay agents are not mandatory in the DHCP architecture. A DHCP relay agent is required only when the server and client are located on different network segments.
- DHCP serverA DHCP server processes address allocation, lease extension, and address release requests originating from a DHCP client or forwarded by a DHCP relay agent and assigns IP addresses and other configuration parameters to the client.
To protect a DHCP server against network attacks, such as man-in-the-middle attacks, starvation attacks, and DoS attacks by changing the CHADDR value, configure DHCP snooping on the intermediate device directly connecting to a DHCP client to provide DHCP security services.
Limitations for DHCP
Limitations for DHCP on NE20E-S2E
Restrictions |
Guidelines |
Impact |
---|---|---|
The DHCP server cannot assign IP addresses to DHCP clients with the same MAC address but in different VLANs. |
Enable one-to-many mapping between one MAC address and multiple sessions on the DHCP server. |
None |
Limitations for DHCP on NE20E-S2F
Restrictions |
Guidelines |
Impact |
---|---|---|
The DHCP server cannot assign IP addresses to DHCP clients with the same MAC address but in different VLANs. |
Enable one-to-many mapping between one MAC address and multiple sessions on the DHCP server. |
None |
One-to-many mapping between one MAC address and multiple sessions cannot be configured if an online user exists on the DHCP server. In addition, this function does not support multiple VRs. |
Log out the online user for the one-to-many mapping between one MAC address and multiple sessions to take effect. |
None |
If the UNR generated after a Layer 3 web user goes online from the BRAS conflicts with the ARP Vlink route, the Vlink route is not generated. |
None |
None |
When the BRAS gateway address and the network-side DHCP relay gateway address are the same, users with duplicate MAC addresses are not allowed. |
Properly plan the network. |
Users with duplicate MAC addresses on the network-side DHCP relay may fail to go online. |
Configuring DHCP Relay
This section describes how to configure DHCP relay so that DHCP messages can be relayed between DHCP clients and the DHCP server that reside on different network segments.
Usage Scenario
As shown in Figure 4-1, DHCP clients are located on network A, and the DHCP server is located on network B. The DHCP clients request configuration parameters, such as IP addresses from the DHCP server. To allow the DHCP clients to obtain IP addresses from the DHCP server, configure DHCP relay so that the DHCP relay agent can forward DHCP messages between the DHCP clients and the DHCP server.
Pre-configuration Tasks
Before configuring DHCP relay, complete the following tasks:
- Configure a DHCP server.
- Configure a DHCP relay interface.
- Configure a route from the DHCP relay agent to the DHCP server.
Configuration Procedures
Configuring Relay
After a DHCP relay agent is configured, it can forward DHCP Request messages form DHCP clients to the DHCP server on a different network segment.
Context
If the DHCP clients and DHCP server reside on different network segments, configure DHCP relay on an interface to forward DHCP Request messages from the DHCP clients to the DHCP server so that the clients can dynamically obtain IP addresses from the DHCP server.
If the DHCP relay has multiple clients, and multiple interfaces on the DHCP relay function as gateways, each gateway uses a public IP address, which wastes resources. If the relay interface on a router uses an unnumbered address as the gateway address, public IP address resources will be greatly saved.
- The DHCP relay generates a user table for the users who go online from the relay interface and saves information, such as users' MAC addresses, online interface, and belonging VLAN.
- Upon receipt of a response packet from the server, the DHCP relay searches the user table based on the chaddr field for the corresponding online interface and forwards the response packet from this interface.
- ARP entry used to notify the ARP module of adding online users
- Entry used to notify the route management module of delivering the user's host routes
Procedure
- Configure basic DHCP relay functions on a common interface.
- Configure basic DHCP relay functions on an unnumbered interface.
Follow-up Procedure
(Optional) Run dhcp dscp-outbound dscp
The differentiated services code point (DSCP) value is set for DHCP messages.
(Optional) Run dhcp ip-ttl ttl-value
The time to live (TTL) value is set for DHCP messages.
(Optional) Run dhcp relay reply broadcast-always
The DHCP relay is enabled to broadcast response packets upon receipt of client requests.
(Optional) Requesting the DHCP Server to Release the Client IP Address
The DHCP relay agent can request the DHCP server for releasing the IP address assigned to the client.
Context
When a DHCP client does not need an IP address or a user needs to be logged out, run the dhcp relay release command on the DHCP relay agent to send a Release message to the DHCP server. After the DHCP server receives the Release message, the server releases the specified IP address.
Perform the following steps on the Device that functions as a DHCP relay agent:
(Optional) Configuring Option 82 Field Insertion
After the Option 82 function is enabled on a device, the device can record the location information of the DHCP client or create binding entries with accurate interface information based on the Option 82 information.
Context
The Option 82 field contains the location information of Dynamic Host Configuration Protocol (DHCP) hosts, such as information about the login interface, virtual local area network (VLAN), and address. After the Option 82 field insertion function is configured, the device can set up dynamic binding entries with accurate interface information. Based on the Option 82 field, the DHCP server assigns IP addresses and policies for DHCP clients.
Procedure
- Configure Option 82 field insertion in a VLAN view.
- Configure Option 82 field insertion in the BD view.
- Configure Option 82 field insertion for an interface.
Follow-up Procedure
After Option 82 field insertion is enabled, you can configure the formats of the Option 82 field as required.
- Configure the format of the Option 82 field in a VLAN view.
- Run system-view
The system view is displayed.
- Run vlan vlan-id
The VLAN view is displayed.
- Run dhcp option82 format { type1 | type2 | self-define self-define | cn-telecom } interface interface-type interface-number
The format of the Option 82 field is configured for the VLAN.
- Run commit
The configuration is committed.
- Run system-view
- Configure the format of the Option 82 field for an interface.
- Run system-view
The system view is displayed.
- Run interface interface-type interface-number
The interface view is displayed.
Run
dhcp option82 format { self-define extendtex | type1 | type2 | cn-telecom }
Or dhcp option82 { circuit-id | remote-id } format self-define extendtex
The format of the Option 82 field is configured for the interface.
- Run commit
The configuration is committed.
- Run system-view
Configuring a DHCP Server
A DHCP server selects available IP addresses from the global address pool and assigns these IP addresses to DHCP clients.
Usage Scenario
A DHCP server that uses a global address pool is configured to dynamically assign IP addresses to computers that are indirectly connected to the DHCP server, as shown in Figure 4-2.
Pre-configuration Tasks
Before configuring the DHCP server, complete the following tasks:
Implement the connectivity between the DHCP client and server.
(Optional) Configure a DNS server.
(Optional) Configure a network basic input/output system (NetBIOS) server.
(Optional) Configure routes between the DNS server and NetBIOS server.
(Optional) Configure the DHCP global address pool option.
Configuring IP Address Assignment
IP address assignment includes specifying such basic information as a gateway address and address segments, as well as configuring static binding.
Context
After an address pool is created on the DHCP server, a gateway address and an address segment need to be specified, with the IP addresses in the address segment belonging to the gateway address segment. By default, all IP addresses in the address segment can be assigned to DHCP clients. If the NetBiOS server and DNS server reside in the address segment, fixed IP addresses need to be bound to the servers. Before such binding, the two IP addresses need to be removed from the address segment so that they will not be dynamically assigned to other DHCP clients.
Procedure
- Configure the basic functions of IP address assignment.
- (Optional) Configure the static address assignment function.
- (Optional) Configure IP address assignment based on Option 60.
- (Optional) Run dhcp reply { unicast-always | broadcast-always }
The type of the packets sent by the DHCP server as a reply is specified.
- (Optional) Run vpn-instance vpn-instance-name
A VPN instance is configured for the address pool.
If a VPN has the DHCP service, the address pool created on the DHCP server needs to be bound to a VPN instance.
- (Optional) Run quit
Return to the system view.
- (Optional) Run dhcp server identifier dest-ip
The DHCP server is enabled to use the destination IP address in the packet forwarded by the DHCP relay as the server identifier.
This command is used when a DHCP client is connected to a DHCP relay (first PE) over a VPN and the DHCP relay sends a DHCP request to the DHCP server (second PE). The DHCP server assigns an IP address to the DHCP client over the VPN. The server IP address specified by the DHCP server is generally the IP address of a non-public interface on the DHCP server, but the DHCP request is received by a public interface on the DHCP server. By default, the DHCP server uses the inbound interface IP address in the DHCP request (public interface IP address) as the server identifier. As a result, the DHCP client fails to extend the lease. To address this problem, run the dhcp server identifier dest-ip command to enable the DHCP server to use the destination IP address in the packet forwarded by the DHCP relay as the server identifier.
- (Optional) Run dhcp server ping { packetspacket-number | timeouttimeout-interval }
The maximum number of ping packets that a DHCP server sends and the maximum timeout period of each ping reply are set.
Before assigning an IP address to a DHCP client, the DHCP server must ping the IP address to check whether this IP address is being used. This prevents address conflicts.
- Run commit
The configuration is committed.
(Optional) Configuring IP Address Management
IP address management includes backing up and restoring data in an address pool, configuring alarm thresholds, and reclaiming IP addresses.
Procedure
- Run system-view
The system view is displayed.
- The DHCP server is enabled to save and restore DHCP data.
- Configure the address resource alarm function.
- Configure the IP address reclaiming function.
- Run lock
The address pool is locked.
If you want to delete an address pool that is currently in use, you can run this command to lock the address pool and then delete the address pool after all the users using this address pool go offline.
- Run commit
The configuration is committed.
(Optional) Configuring Address Pool Attributes
Configuring address pool attributes includes specifying an IP address lease, configuring the application server address and customized items. The address pool attributes are contained in option information that is sent by the DHCP server to clients.
(Optional) Configuring DHCP Server Dual-Device Hot Backup
Dual-device hot backup of a DHCP server can be enabled to achieve backup of user session information between devices. When a network node or link experiences an abnormality, fast user service switching is triggered, which enhances service reliability.
Prerequisites
Before configuring DHCP server dual-device hot backup, ensure that the same DHCP server configuration has been performed on the master and slave devices. Otherwise, a master/slave switchover may lead to an abnormality in new user access and user renewal.
Background
As shown in Figure 4-3, the DHCP client is connected to DeviceA and DeviceB over a switch. A VRRP backup group is configured between DeviceA and DeviceB to establish the master/backup relationship, with DeviceA as the master device and DeviceB as the backup device. Both DeviceA and DeviceB serve as a DHCP server to assign IP addresses to DHCP clients.
In normal cases, DeviceA implements new user access and online user renewal. When DeviceA or the link between DeviceA and the switch becomes faulty, a master/backup VRRP switchover is implemented and DeviceB takes over to become the master device. DeviceB can properly perform address assignment for new users and renewal requests for online users only when user session information has been synchronized from DeviceA to DeviceB.
To prevent abnormalities of new user access and online user renewal after a master/backup switchover due to a failure to synchronize user session information from DeviceA to DeviceB, deploy DHCPv4 server dual-device hot backup on DeviceA and DeviceB.
Perform the following operations on the DHCP servers that back up each other:
Verifying the Configuration of a DHCP Server
After configuring the DHCP server, verify the configuration.
Procedure
- Run display ip pool
The address pool configurations and address statistics are displayed.
- Run display ip pool pool-usage
The address usage of the address pool is displayed.
- Run display ip pool max-usage
The maximum address usage of the address pool is displayed.
- Run display client-option pool-usage
The option that will be sent as a reply to a user request is displayed.
- Run display dhcp server database
The saved DHCP server data is displayed.
- Run display remote-backup-profile [ profile-name ]
Information about the configured RBP is displayed.
- Run display remote-backup-service [ service-name [ verbose ] ]
Information about the configured RBS is displayed.
Configuring DHCP-PNP
This section describes how to configure Dynamic Host Configuration Protocol (DHCP) plug-and-play (PNP). DHCP PNP enables the network management system (NMS) to remotely configure and commission devices. This feature improves the working process and reduces operation and maintenance (O&M) costs.
Usage Scenario
Mobile networks have lots of access devices. Software commissioning engineers need to configure and commission these devices on site. This network construction method requires significant human and material resources, causing high capital expenditure (CAPEX) and operational expenditure (OPEX). DHCP PNP has been developed to resolve the problem.
DHCP PNP enables the NMS to use DHCP to automatically configure and commission devices remotely. This solution reduces the time required to commission devices on site and frees personnel from working in unfavorable outdoor environments. It improves the working process and reduces costs. Figure 4-4 shows the DHCP PNP networking.
This feature is supported only on the Admin-VS.
Pre-configuration Tasks
Configure a DHCP server.
Configure a DHCP relay agent if the DHCP client and DHCP server are not on the same network segment.
Procedure
- If the plug-and-play function is required, perform the following operations when the DHCP client and server are on different network segments:
- If the plug-and-play function is not required, use serial interfaces to connect to the DHCP client. In the system view, run the undo pnp enable command on the DHCP client to disable DHCP PNP. This function protects user configurations from being affected by automatic VLAN learning.
Result
After the configuration is complete, run the following commands on the DHCP client to check the result:
Run the display pnp state command to check whether the device is in the DHCP PNP state.
<HUAWEI> display pnp state
PNP State!!!PLEASE UNDO PNP enable for manual Setup! You can undo PNP in system view with "undo pnp enable
Run the display nms-vpn-instance ip-address ip-address command to view VPN instances to which the specified IP address is bound.
<HUAWEI> display nms-vpn-instance ip-address 3.3.3.3
IP Address Interface VPN-Instance
--------------------------------------------------------------------------------
3.3.3.3 gigabitethernet0/3/2 vpna
Configuring a DHCP Client
With the DHCP client function configured, a device uses DHCP to dynamically request an IP address from the DHCP server. This achieves appropriate assignment and centralized management of IP addresses.
Background
The Dynamic Host Configuration Protocol (DHCP) dynamically assigns IP addresses to hosts and centrally manages host configurations. DHCP uses the client/server model. A client applies to the server for configuration parameters, such as an IP address, subnet mask, and default gateway address; the server replies with the requested configuration parameters.
Some DHCP clients use a fixed IP address for a long time, and some DHCP clients use a temporary IP address. After a DHCP client's lease time is expired, the DHCP server reclaims the IP address of the DHCP client and allocates this IP address to another DHCP client. You can configure an expected lease time for a DHCP client as required. In this case, while assigning an address lease time, the DHCP server compares the expected lease time with the address lease time of the current address pool and provides the DHCP client an appropriate lease time based on address assignment rules.
Prerequisites
Before configuring the DHCP client function, complete the following tasks:
Configure another device on the network as a DHCP server. For details, see Configuring a DHCP Server.
Procedure
Run system-view
The system view is displayed.
- (Optional) Run dhcpc option60 redefined option60Value
The Option60 to be carried in DHCP messages is configured.
- (Optional) Run dhcpc unicast-flag enable
The Bootp flags field value in a DHCP request message is set to 0x0000 (Unicast).
By default, DHCP request and response messages are broadcast ones. If the client requires the server to respond in unicast mode for security, run the dhcpc unicast-flag enable command to set the Bootp flags field value in a DHCP request message to 0x0000 (Unicast) before enabling the DHCP client function.
Run interface interface-type interface-number
The view of the interface to be enabled with the DHCP client function is displayed.
Run ip address dhcp-alloc
The DHCP client function is enabled on the interface.
After the DHCP client function is enabled, pay attention to the following points:
When multiple logical interfaces apply for an IP address from the same DHCP server, configure different MAC addresses for the logical interfaces. Otherwise, address assignment may fail.
- After the DHCP client function is enabled on an interface, the interface cannot process FORCE RENEW packets any more.
(Optional) Run dhcp client expected-lease lease-time
The expected IP address lease time for the DHCP client is configured.
(Optional) Run dhcpc option60 redefined option60Value
The Option60 to be carried in DHCP messages is configured.
If the Option60 is configured in both the system view and interface view, the configuration in the interface view takes effect.
Run commit
The configuration is committed.
Follow-up Procedure
When a DHCP client no longer uses the assigned IP address, run the dhcp release command so that the DHCP client proactively sends a DHCP Release message to the DHCP server to notify the DHCP server of releasing IP address. If this command is run in the system view, the IP addresses requested by all interfaces from the DHCP server are released. If this command is run in the interface view, only the IP address requested by the specific interface is released from the DHCP server.
Maintaining a DHCP Client
Maintaining a DHCP client includes monitoring the running status of the DHCP client and clearing statistics on the DHCP client.
Monitoring the Operating Status of a DHCP Client
DHCP Server Maintenance
DHCP server maintenance includes monitoring the operating status of the DHCP server and clearing DHCP server statistics.
Monitoring the DHCP Server Operating Status
Clearing DHCP Server Statistics
This section describes how to use reset commands to clear DHCP server statistics.
Context
Cleared DHCP server statistics cannot be restored. Therefore, exercise caution when running reset commands.
Procedure
- Run the reset dhcp server statistics command in the user view to clear DHCP server statistics.
- Run the reset conflict-ip-address command in the IP address pool view to identify a conflicting address.
- Run the reset ip-pool max-usage command in the user view to display the historical maximum usage of IPv4 addresses.
DHCP Relay Maintenance
DHCP relay maintenance includes monitoring the DHCP relay running status and clearing DHCP relay statistics and recording exchange information with the DHCP relay client.
Monitoring the DHCP Relay Operating Status
Clearing DHCP Relay Statistics
Recording Exchange Messages with a DHCP Relay Client
A DHCP relay agent can record information exchanged between DHCP servers and clients based on a specific option or sub-option in DHCP packets to facilitate fault location.
Usage Scenario
If a DHCP client cannot obtain an IP address properly, a DHCP relay agent can be configured to record the information exchanged between DHCP servers and DHCP clients to help locate the fault. Then, the DHCP relay agent records the information exchanged between the DHCP client and server based on the specified option code and sub-option code in DHCP packets.
Procedure
- Run system-view
The system view is displayed.
- The cleared history records of information exchange cannot be restored. Exercise caution while running the reset dhcp relay client-info command.
- (Optional) Run reset dhcp relay client-info [ interface interface-type interface-number [ pevlan pevlan-id [ end-pevlan-id ] [ cevlan cevlan-id [ end-cevlan-id ] ] ] | mac-address mac-address | option option-value ]
The history records of exchanges between the DHCP client and server over the DHCP relay agent have been cleared.
- Run dhcp relay client-info option option-code [ sub-option sub-option-code ]
The DHCP relay agent has been configured to specify the DHCP packets to recorded.
- Run commit
The configuration is committed.
Checking the Configurations
- Run the display dhcp relay client-info option configuration command in any view to view the DHCP option code or sub-option code based on which the DHCP relay agent records DHCP packets.
- Run the display dhcp relay client-info [ interface interface-type interface-number [ pevlan pevlan-id [ end-pevlan-id ] [ cevlan cevlan-id [ end-cevlan-id ] ] ] | mac-address mac-address | option option-value ] command in any view to view history records of the information exchanged between the DHCP client and server over the DHCP relay agent.
Configuration Examples for DHCP
This section provides DHCP configuration examples, including networking requirements, networking diagram, configuration notes, configuration roadmap, and configuration procedure.
Example for Configuring DHCP Relay
This section provides an example for configuring a DHCP relay agent to forward DHCP messages between the DHCP clients and the DHCP server on different network segments. This configuration is available only on carrier IP devices.
Networking Requirements
As shown in Figure 4-5, the DHCP clients reside on the network segment 10.100.0.0/16, and the DHCP server resides on the network segment 172.16.0.0/16. To allow the DHCP clients to obtain IP addresses from the DHCP server, configure a DHCP relay agent to forward DHCP messages between the clients and server and configure a route from the DHCP server to the network segment 10.100.0.0.
The network segment of the DHCP client is 10.100.0.0/16. The IP address of the DNS server is 10.100.1.2/16, the IP address of the NetBIOS server is 10.100.1.3/16, and the IP address of the gateway is 10.100.1.1. On the DHCP server, the routing table contains at least one reachable route to network segment 10.100.0.0.
Configuration Roadmap
The configuration roadmap is as follows:
- Configure a DHCP relay agent.
- Configure an IP address for GE 0/2/0.
- Specify the DHCP server address and enable DHCP relay on GE 0/1/0 and enable DHCP relay on GE 0/1/0.
- Configure the DHCP server.
- Configure a route from DHCP server that functions as the DHCP server to GE 0/1/0 on DHCP relay.
- Configure an IP address for GE 0/1/0.
- Configure IP addresses for the DNS server, NetBIOS server, and egress gateway.
- Configure an address pool on DHCP server.
Data Preparation
To complete the configuration, you need the following data:
IP address of the interface to have DHCP relay enabled
IP address of the DHCP server
Procedure
- Configure a DHCP relay agent.
# Configure an IP address for GE 0/2/0.
<HUAWEI> system-view
[~HUAWEI] sysname DeviceA
[*HUAWEI] commit
[~DeviceA] interface GigabitEthernet 0/2/0
[~DeviceA-GigabitEthernet0/2/0] ip address 172.16.1.1 255.255.0.0
[*DeviceA-GigabitEthernet0/2/0] undo shutdown
[*DeviceA-GigabitEthernet0/2/0] commit
[~DeviceA-GigabitEthernet0/2/0] quit
# Specify the DHCP server address and enable DHCP relay on GE 0/1/0.
[~DeviceA] dhcp enable
[~DeviceA] interface gigabitethernet 0/1/0
[*DeviceA-GigabitEthernet0/1/0] ip address 10.100.1.1 255.255.0.0
[*DeviceA-GigabitEthernet0/1/0] ip relay address 172.16.1.2
[*DeviceA-GigabitEthernet0/1/0] ip relay giaddr 10.100.20.1
[*DeviceA-GigabitEthernet0/1/0] dhcp select relay
[*DeviceA-GigabitEthernet0/1/0] undo shutdown
[*DeviceA-GigabitEthernet0/1/0] commit
[~DeviceA-GigabitEthernet0/1/0] quit
- Configure the DHCP server.
The configuration details are not provided. The DHCP server must meet the following conditions:
- An address pool is configured and the range of IP addresses that can be assigned is specified.
- A domain name is configured, and the IP addresses of the DNS server, NetBIOS server, and egress gateway are configured.
- The address pool lease is configured to improve IP address utilization.
- Verify the configuration.
Run the display dhcp relay address command on the DHCP relay device to view configurations of the relay IP address.
[~DeviceA] display dhcp relay address all
** GigabitEthernet0/1/0 DHCP Relay Address **
Dhcp Option Relay Agent IP Server IP
* 10.100.20.1 172.16.1.2
Configuration Files
DHCP relay configuration file
#
sysname DeviceA
#
dhcp enable
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 10.100.1.1 255.255.0.0
dhcp select relay
ip relay address 172.16.1.2
ip relay giaddr 10.100.20.1
#
interface GigabitEthernet 0/2/0
undo shutdown
ip address 172.16.1.1 255.255.0.0
#
return
Example for Configuring a DHCP Server for Clients on the Same Network Segment
This section provides an example for configuring a DHCP server for clients on the same network segment.
Networking Requirements
In a rather large network, if the PCs are connected to the routing device through other devices instead of being directly connected to the routing device through Ethernet interfaces, a network-side DHCPv4 server needs to be configured so that the PCs can dynamically obtain IP addresses from the routing device.
On the network shown in Figure 1, the DHCPv4 server assigns IP addresses to clients on the same network segment. The address pool resides in network segment 10.1.1.0/24 which is divided into two subnets: 10.1.1.0/25 and 10.1.1.128/25. The DHCPv4 server has two GE interfaces whose IP addresses are 10.1.1.1/25 and 10.1.1.129/25, respectively.
The lease of the IP addresses on the network segment 10.1.1.0/25 is 10 days and 12 hours, and the domain name is huawei.com. The DNS server address is 10.1.1.2. There is no NetBIOS address. The gateway address is 10.1.1.1.
The lease of the IP addresses on the network segment 10.1.1.128/25 is 5 days, and the DNS suffix is huawei.com. The DNS server address is 10.1.1.2. The NetBIOS address is 10.1.1.4. The gateway address is 10.1.1.129.
Configuration Roadmap
The configuration roadmap is as follows:
Configure interface IP addresses.
- Configure an address pool.
- Configure a gateway address, an address segment, and the IP addresses that do not take part in automatic assignment (including the DNS server address, NetBIOS server address, and gateway address).
- Configure the NetBIOS server address, DNS server address, and DNS domain name suffix.
- Configure an address lease.
Data Preparation
To complete the configuration, you need the following data:
Interface IP addresses
Gateway address
Address segment number and range
IP addresses prohibited from being assigned
DNS domain name suffix and DNS server address
Address lease period
Procedure
- Configure interface IP addresses on the DHCPv4 server.
<HUAWEI> system-view
[~HUAWEI] interface gigabitethernet 0/1/0
[~HUAWEI-GigabitEthernet0/1/0] ip address 10.1.1.1 255.255.255.128
[*HUAWEI-GigabitEthernet0/1/0] undo shutdown
[*HUAWEI-GigabitEthernet0/1/0] quit
[*HUAWEI] interface gigabitethernet 0/1/1
[*HUAWEI-GigabitEthernet0/1/1] ip address 10.1.1.129 255.255.255.128
[*HUAWEI-GigabitEthernet0/1/1] undo shutdown
[*HUAWEI-GigabitEthernet0/1/1] quit
[*HUAWEI] commit
- Configure address pool 1 on the DHCPv4 server.
# Configure a gateway address, an address segment, and the IP address that do not take part in automatic assignment.
[~HUAWEI] dhcp enable
[*HUAWEI] ip pool huawei1 server
[*HUAWEI-ip-pool-huawei1] gateway 10.1.1.1 255.255.255.128
[*HUAWEI-ip-pool-huawei1] section 0 10.1.1.2 10.1.1.126
[*HUAWEI-ip-pool-huawei1] excluded-ip-address 10.1.1.2
[*HUAWEI-ip-pool-huawei1] excluded-ip-address 10.1.1.4
# Configure the DNS server address and DNS domain name suffix.
[*HUAWEI-ip-pool-huawei1] dns-server 10.1.1.2
[*HUAWEI-ip-pool-huawei1] dns-suffix huawei.com
# Configure an address lease period.
[*HUAWEI-ip-pool-huawei1] lease 10 12
[*HUAWEI-ip-pool-huawei1] quit
[*HUAWEI] commit
- Configure address pool 2 on the DHCPv4 server.
# Configure a gateway address and an address segment.
[~HUAWEI] ip pool huawei2 server
[*HUAWEI-ip-pool-huawei2] gateway 10.1.1.129 255.255.255.128
[*HUAWEI-ip-pool-huawei2] section 0 10.1.1.130 10.1.1.254
# Configure the NetBIOS server address, DNS server address, and DNS domain name suffix.
[*HUAWEI-ip-pool-huawei2] netbios-name-server 10.1.1.4
[*HUAWEI-ip-pool-huawei2] dns-server 10.1.1.2
[*HUAWEI-ip-pool-huawei2] dns-suffix huawei.com
# Configure an address lease period.
[*HUAWEI-ip-pool-huawei2] lease 5
[*HUAWEI-ip-pool-huawei2] quit
[*HUAWEI] commit
- Verify the configuration.
# Run the display ip pool command on the DHCP server to view the IP address pool configuration.
[~HUAWEI] display ip pool name huawei1
Pool-Name : huawei1 Pool-No : 1 Pool-constant-index: - Lease : 10 Days 12 Hours 0 Minutes NetBios Type : N-Node Auto recycle : 30 Option 3 : Enable DNS-Suffix : huawei.com Dom-Search-List0: - Dom-Search-List1: - Dom-Search-List2: - Dom-Search-List3: - Option-Code 125 : enterprise-code : 2011, string: - Position : Server Status : Unlocked RUI-Flag : - Attribute : Private Gateway : 10.1.1.1 Mask : 255.255.255.128 Vpn instance : -- Unnumbered gateway: - Profile-Name : - Server-Name : - Total Idle : 123 Have Dhcp IP : 1 Timeouts : 0 Timeout Count : 0 Sub Option Count : 0 Option Count : 0 Force-reply Count: 0 Codes: CFLCT(conflicted) --------------------------------------------------------------------------------------- ID start end total used idle CFLCT disable reserved static-bind --------------------------------------------------------------------------------------- 0 10.1.1.2 10.1.1.126 125 0 123 0 2 0 0 ---------------------------------------------------------------------------------------
[~HUAWEI] display ip pool name huawei2
Pool-Name : huawei2 Pool-No : 2 Pool-constant-index: - Lease : 5 Days 0 Hours 0 Minutes NetBios Type : N-Node Auto recycle : 30 Option 3 : Enable DNS-Suffix : huawei.com Dom-Search-List0: - Dom-Search-List1: - Dom-Search-List2: - Dom-Search-List3: - Option-Code 125 : enterprise-code : 2011, string: - Position : Server Status : Unlocked RUI-Flag : - Attribute : Private Gateway : 10.1.1.129 Mask : 255.255.255.128 Vpn instance : -- Unnumbered gateway: - Profile-Name : - Server-Name : - Total Idle : 125 Have Dhcp IP : 1 Timeouts : 0 Timeout Count : 0 Sub Option Count : 0 Option Count : 0 Force-reply Count: 0 Codes: CFLCT(conflicted) --------------------------------------------------------------------------------------- ID start end total used idle CFLCT disable reserved static-bind --------------------------------------------------------------------------------------- 0 10.1.1.130 10.1.1.254 125 0 125 0 0 0 0 ---------------------------------------------------------------------------------------
Configuration File
DHCP server configuration file
# dhcp enable # ip pool huawei1 server gateway 10.1.1.1 255.255.255.128 section 0 10.1.1.2 10.1.1.126 excluded-ip-address 10.1.1.2 excluded-ip-address 10.1.1.4 dns-server 10.1.1.2 dns-suffix huawei.com lease 10 12 # ip pool huawei2 server gateway 10.1.1.129 255.255.255.128 section 0 10.1.1.130 10.1.1.254 dns-server 10.1.1.2 dns-suffix huawei.com netbios-name-server 10.1.1.4 lease 5 # interface GigabitEthernet0/1/0 undo shutdown ip address 10.1.1.1 255.255.255.128 # interface GigabitEthernet0/1/1 undo shutdown ip address 10.1.1.129 255.255.255.128 # return
Example for Configuring a DHCP Server to Assign IP Addresses to Users with the Same MAC Address in Different VLANs for Login
This section provides an example for configuring a DHCP server (with no relay agent configured) to assign IP addresses to Ethernet users with the same MAC addresses in different VLANs.
Networking Requirements
IP addresses of different network segments need to be applied for VoIP and IPTV services deployed on different user planes. DHCP clients that support these services use one MAC address to apply for IP addresses of different network segments and differentiate services based on VLAN IDs. This requires the DHCP server to assign IP addresses to users with the same MAC address in different VLANs.
On the network shown in Figure 1, the DHCP server is configured to dynamically assign IP addresses to DHCP clients. When receiving a user packet in which the VLAN ID is 100, the DHCP server selects the address pool huawei1 to assign an IP address to the user based on the gateway address 10.10.10.1/24. When receiving a user packet in which the VLAN ID is 200, the DHCP server selects the address pool huawei2 to assign an IP address to the user based on the gateway address 10.10.20.1/24.
The DHCP server can only assign IP addresses from different address pools to users with the same MAC address in different VLANs.
Configuration Roadmap
The configuration roadmap is as follows:
Configure an IP address for the interface through which users go online.
Configure gateway addresses and address segments for address pools.
Configure Layer 3 sub-interfaces.
Data Preparation
To complete the configuration, you need the following data:
IP address of the interface through which users go online
Gateway addresses
Numbers and ranges of address segments
Procedure
- Configure an IP address for the interface through which users go online.
<HUAWEI> system-view
[~HUAWEI] sysname DHCP Server
[*HUAWEI] commit
[~DHCP Server] interface gigabitethernet 0/1/1
[~DHCP Server-GigabitEthernet0/1/1] ip address 10.1.1.1 255.255.255.0
[*DHCP Server-GigabitEthernet0/1/1] commit
[~DHCP Server-GigabitEthernet0/1/1] quit
- Configure gateway addresses and address segments for address pools.
# Configure an address pool huawei1.
[~DHCP Server] dhcp enable
[*DHCP Server] ip pool huawei1 server
[*DHCP Server-ip-pool-huawei1] gateway 10.10.10.1 255.255.255.0
[*DHCP Server-ip-pool-huawei1] section 0 10.10.10.20 10.10.10.30
[*DHCP Server-ip-pool-huawei1] commit
[~DHCP Server-ip-pool-huawei1] quit
# Configure an address pool huawei2.
[~DHCP Server] ip pool huawei2 server
[*DHCP Server-ip-pool-huawei2] gateway 10.10.20.1 255.255.255.0
[*DHCP Server-ip-pool-huawei2] section 0 10.10.20.20 10.10.20.30
[*DHCP Server-ip-pool-huawei2] commit
[~DHCP Server-ip-pool-huawei2] quit
- Configure a Layer 3 sub-interface (taking the Dot1q termination sub-interface as an example).
[~DHCP Server] interface gigabitethernet 0/1/1.1
[*DHCP Server-GigabitEthernet0/1/1.1] ip address 10.10.10.1 255.255.255.0
[*DHCP Server-GigabitEthernet0/1/1.1] encapsulation dot1q-termination
[*DHCP Server-GigabitEthernet0/1/1.1] dot1q termination vid 100
[*DHCP Server-GigabitEthernet0/1/1.1] commit
[~DHCP Server-GigabitEthernet0/1/1.1] quit
[~DHCP Server] interface gigabitethernet 0/1/1.2
[*DHCP Server-GigabitEthernet0/1/1.2] ip address 10.10.20.1 255.255.255.0
[*DHCP Server-GigabitEthernet0/1/1.2] encapsulation dot1q-termination
[*DHCP Server-GigabitEthernet0/1/1.2] dot1q termination vid 200
[*DHCP Server-GigabitEthernet0/1/1.2] commit
[~DHCP Server-GigabitEthernet0/1/1.2] quit
- Verify the configuration.
# Run the display ip pool command on the DHCP server to check the configurations of IP address pools.
[~DHCP Server] display ip pool name huawei1
Pool-Name : huawei1 Pool-No : 2 Pool-constant-index: - Lease : 3 Days 0 Hours 0 Minutes NetBios Type : N-Node Auto recycle : 30 Option 3 : Enable DNS-Suffix : - Dom-Search-List0: - Dom-Search-List1: - Dom-Search-List2: - Dom-Search-List3: - Option-Code 125 : enterprise-code : 2011, string: - Position : Server Status : Unlocked RUI-Flag : - Attribute : Private Gateway : 10.10.10.1 Mask : 255.255.255.0 Vpn instance : -- Unnumbered gateway: - Profile-Name : - Server-Name : - Total Idle : 11 Have Dhcp IP : 1 Timeouts : 0 Timeout Count : 0 Sub Option Count : 0 Option Count : 0 Force-reply Count: 0 Codes: CFLCT(conflicted) --------------------------------------------------------------------------------------- ID start end total used idle CFLCT disable reserved static-bind --------------------------------------------------------------------------------------- 0 10.10.10.20 10.10.10.30 11 0 11 0 0 0 0 ---------------------------------------------------------------------------------------
[~DHCP Server] display ip pool name huawei2
Pool-Name : huawei2 Pool-No : 3 Pool-constant-index: - Lease : 3 Days 0 Hours 0 Minutes NetBios Type : N-Node Auto recycle : 30 Option 3 : Enable DNS-Suffix : - Dom-Search-List0: - Dom-Search-List1: - Dom-Search-List2: - Dom-Search-List3: - Option-Code 125 : enterprise-code : 2011, string: - Position : Server Status : Unlocked RUI-Flag : - Attribute : Private Gateway : 10.10.20.1 Mask : 255.255.255.0 Vpn instance : -- Unnumbered gateway: - Profile-Name : - Server-Name : - Total Idle : 11 Have Dhcp IP : 1 Timeouts : 0 Timeout Count : 0 Sub Option Count : 0 Option Count : 0 Force-reply Count: 0 Codes: CFLCT(conflicted) --------------------------------------------------------------------------------------- ID start end total used idle CFLCT disable reserved static-bind --------------------------------------------------------------------------------------- 0 10.10.20.20 10.10.20.30 11 0 11 0 0 0 0 ---------------------------------------------------------------------------------------
Configuration Files
DHCP server configuration file
# sysname DHCP Server # dhcp enable # ip pool huawei1 server gateway 10.10.10.1 255.255.255.0 section 0 10.10.10.20 10.10.10.30 # ip pool huawei2 server gateway 10.10.20.1 255.255.255.0 section 0 10.10.20.20 10.10.20.30 # interface GigabitEthernet0/1/1 ip address 10.1.1.1 255.255.255.0 # interface GigabitEthernet0/1/1.1 ip address 10.10.10.1 255.255.255.0 encapsulation dot1q-termination dot1q termination vid 100 # interface GigabitEthernet0/1/1.2 ip address 10.10.20.1 255.255.255.0 encapsulation dot1q-termination dot1q termination vid 200 # return
Example for Configuring DHCP Server Dual-Device Hot Backup
This section describes how to configure DHCP server dual-device hot backup on a VRRP backup group. After master/slave switching is implemented for the VRRP backup group, the new master device can properly process services with no need for re-synchronizing user session information.
Networking Requirements
On the network shown in Figure 1, the DHCP client is connected to DeviceA and DeviceB over a switch. A VRRP backup group is configured between DeviceA and DeviceB to establish the master/backup relationship, with DeviceA as the master device and DeviceB as the backup device. Both DeviceA and DeviceB serve as a DHCP server to assign IP addresses to DHCP clients.
In normal cases, DeviceA implements new user access and online user renewal. When DeviceA or the link between DeviceA and the switch becomes faulty, a master/backup VRRP switchover is implemented and DeviceB takes over to become the master device. DeviceB can properly perform address assignment for new users and renewal requests for online users only when user session information has been synchronized from DeviceA to DeviceB.
To prevent abnormalities of new user access and online user renewal after a master/backup switchover due to a failure to synchronize user session information from DeviceA to DeviceB, deploy DHCPv4 server dual-device hot backup on DeviceA and DeviceB.
Configuration Roadmap
The configuration roadmap is as follows:
Create a VLAN and configure the Layer 2 forwarding function.
Configure the address assignment function.
Establish a dual-device backup platform.
Enable remote backup for the DHCP server.
Data Preparation
To complete the configuration, you need the following data:
VLAN ID of DeviceA and DeviceB: 100
Gateway address of the address pool named huawei1: 10.10.10.1/24; start IP address of the address segment: 10.10.10.1; end IP address of the address segment: 10.10.10.100
ID of the VRRP backup group established between DeviceA and DeviceB: 1; virtual IP address of the VRRP backup group: 10.10.10.100
Priority of the VRRP backup group on DeviceA: 200; preemption delay: 420s
Name of the RBS and RBP: service1; user backup ID: 1
DHCP server identifier of DeviceA and DeviceB: 10.10.10.100
Procedure
- Create a VLAN and configure the Layer 2 forwarding function.
# Configure DeviceA.
<HUAWEI> system-view
[~HUAWEI] sysname DeviceA
[*HUAWEI] commit
[~DeviceA] vlan 100
[*DeviceA-vlan100] commit
[~DeviceA-vlan100] quit
[~DeviceA] interface gigabitethernet 0/1/1
[~DeviceA-GigabitEthernet0/1/1] portswitch
[*DeviceA-GigabitEthernet0/1/1] undo shutdown
[*DeviceA-GigabitEthernet0/1/1] port link-type trunk
[*DeviceA-GigabitEthernet0/1/1] port trunk allow-pass vlan 100
[*DeviceA-GigabitEthernet0/1/1] commit
[~DeviceA-GigabitEthernet0/1/1] quit
# Configure DeviceB.
<HUAWEI> system-view
[~HUAWEI] sysname DeviceB
[*HUAWEI] commit
[~DeviceB] vlan 100
[*DeviceB-vlan100] commit
[~DeviceB-vlan100] quit
[~DeviceB] interface gigabitethernet 0/1/1
[~DeviceB-GigabitEthernet0/1/1] portswitch
[*DeviceB-GigabitEthernet0/1/1] undo shutdown
[*DeviceB-GigabitEthernet0/1/1] port link-type trunk
[*DeviceB-GigabitEthernet0/1/1] port trunk allow-pass vlan 100
[*DeviceB-GigabitEthernet0/1/1] commit
[~DeviceB-GigabitEthernet0/1/1] quit
- Configure the address assignment function.
# Configure DeviceA.
[~DeviceA] ip pool huawei1 server
[*DeviceA-ip-pool-huawei1] gateway 10.10.10.1 255.255.255.0
[*DeviceA-ip-pool-huawei1] section 0 10.10.10.1 10.10.10.100
[*DeviceA-ip-pool-huawei1] commit
[~DeviceA-ip-pool-huawei1] quit
# Configure DeviceB.
[~DeviceB] ip pool huawei1 server
[*DeviceB-ip-pool-huawei1] gateway 10.10.10.1 255.255.255.0
[*DeviceB-ip-pool-huawei1] section 0 10.10.10.1 10.10.10.100
[*DeviceB-ip-pool-huawei1] commit
[~DeviceB-ip-pool-huawei1] quit
- Establish a dual-device backup platform.
Configure basic functions of a VRRP backup group.
# Configure DeviceA.
[~DeviceA] interface Vlanif 100
[*DeviceA-Vlanif100] ip address 10.10.10.1 255.255.255.0
[*DeviceA-Vlanif100] vrrp vrid 1 virtual-ip 10.10.10.100
[*DeviceA-Vlanif100] vrrp vrid 1 priority 200
[*DeviceA-Vlanif100] vrrp vrid 1 preempt-mode timer delay 600
[*DeviceA-Vlanif100] commit
[~DeviceA-Vlanif100] quit
# Configure DeviceB.
[~DeviceB] interface Vlanif 100
[*DeviceB-Vlanif100] ip address 10.10.10.2 255.255.255.0
[*DeviceB-Vlanif100] vrrp vrid 1 virtual-ip 10.10.10.100
[*DeviceB-Vlanif100] commit
[~DeviceB-Vlanif100] quit
Configure an RBS.
# Configure DeviceA.
[~DeviceA] remote-backup-service service1
[*DeviceA-rm-backup-srv-service1] peer 10.10.10.2 source 10.10.10.1 port 10000
[*DeviceA-rm-backup-srv-service1] commit
[~DeviceA-rm-backup-srv-service1] quit
# Configure DeviceB.[~DeviceB] remote-backup-service service1
[*DeviceB-rm-backup-srv-service1] peer 10.10.10.1 source 10.10.10.2 port 10000
[*DeviceB-rm-backup-srv-service1] commit
[~DeviceB-rm-backup-srv-service1] quit
Configure an RBP.
# Configure DeviceA.
[~DeviceA] remote-backup-profile service1
[*DeviceA-rm-backup-prf-service1] peer-backup hot
[*DeviceA-rm-backup-prf-service1] vrrp-id 1 interface Vlanif 100
[*DeviceA-rm-backup-prf-service1] backup-id 1 remote-backup-service service1
[*DeviceA-rm-backup-prf-service1] commit
[~DeviceA-rm-backup-prf-service1] quit
# Configure DeviceB.[~DeviceB] remote-backup-profile service1
[*DeviceB-rm-backup-prf-service1] peer-backup hot
[*DeviceB-rm-backup-prf-service1] vrrp-id 1 interface Vlanif 100
[*DeviceB-rm-backup-prf-service1] backup-id 1 remote-backup-service service1
[*DeviceB-rm-backup-prf-service1] commit
[~DeviceB-rm-backup-prf-service1] quit
- Enable remote backup for the DHCP server.# Enable remote backup for the DHCP server in the RBP view of DeviceA and bind the RBP to the address pool named huawei1.
[~DeviceA] remote-backup-profile service1
[~DeviceA-rm-backup-prf-service1] service-type dhcp-server
[*DeviceA-rm-backup-prf-service1] commit
[~DeviceA-rm-backup-prf-service1] quit
[~DeviceA] ip pool huawei1
[~DeviceA-ip-pool-huawei1] remote-backup-profile service1
[*DeviceA-ip-pool-huawei1] server identifier ip 10.10.10.100
[*DeviceA-ip-pool-huawei1] commit
[~DeviceA-ip-pool-huawei1] quit
# Enable remote backup for the DHCP server in the RBP view of DeviceA and bind the RBP to the address pool named huawei1.[~DeviceB] remote-backup-profile service1
[~DeviceB-rm-backup-prf-service1] service-type dhcp-server
[*DeviceB-rm-backup-prf-service1] commit
[~DeviceB-rm-backup-prf-service1] quit
[~DeviceB] ip pool huawei1
[~DeviceB-ip-pool-huawei1] remote-backup-profile service1
[*DeviceB-ip-pool-huawei1] server identifier ip 10.10.10.100
[*DeviceB-ip-pool-huawei1] commit
[~DeviceB-ip-pool-huawei1] quit
- Verify the configuration.After completing the configurations, run the display remote-backup-profile command on DeviceA. The command output shows that the RBP service1 has been created and bound to the address pool huawei1.
<DeviceA> display remote-backup-profile service1
----------------------------------------------- Profile-Index : 0x1000 Profile-Name : service1 Service : dhcp-server Remote-backup-service: service1 Backup-ID : 1 track protocol : VRRP VRRP-ID : 1 VRRP-Interface : Vlanif100 Access-Control : -- State : Master Peer State : -- Interface : Backup mode : hot Slot-Number : -- Card-Number : -- Port-Number : --
Run the display remote-backup-profile command on DeviceB. The command output shows that the RBP service1 has been created and bound to the address pool huawei1.<DeviceB> display remote-backup-profile service1
----------------------------------------------- Profile-Index : 0x1000 Profile-Name : service1 Service : dhcp-server Remote-backup-service: service1 Backup-ID : 1 track protocol : VRRP VRRP-ID : 1 VRRP-Interface : Vlanif100 Access-Control : -- State : Slave Peer State : -- Interface : Backup mode : hot Slot-Number : -- Card-Number : -- Port-Number : --
Run the display remote-backup-service command on Device. The command output shows that the RBS service1 has been created.<DeviceA> display remote-backup-service service1
---------------------------------------------------------- Service-Index : 1 Service-Name : service1 TCP-State : Connected Peer-ip : 10.10.10.2 Source-ip : 10.10.10.1 TCP-Port : 10000 Track-BFD : -- SSL-Policy-Name : -- SSL-State : -- ----------------------------------------------------------
Run the display remote-backup-service command on DeviceB. The command output shows that the RBS service1 has been created.<DeviceB> display remote-backup-service service1
---------------------------------------------------------- Service-Index : 1 Service-Name : service1 TCP-State : Connected Peer-ip : 10.10.10.1 Source-ip : 10.10.10.2 TCP-Port : 10000 Track-BFD : -- SSL-Policy-Name : -- SSL-State : -- ----------------------------------------------------------
Configuration Files
DeviceA configuration file
# sysname DeviceA # vlan batch 100 # ip pool huawei1 server gateway 10.10.10.1 255.255.255.0 section 0 10.10.10.1 10.10.10.100 server identifier ip 10.10.10.100 remote-backup-profile service1 # remote-backup-service service1 peer 10.10.10.2 source 10.10.10.1 port 10000 # remote-backup-profile service1 service-type dhcp-server backup-id 1 remote-backup-service service1 peer-backup hot vrrp-id 1 interface Vlanif100 # interface Vlanif100 ip address 10.10.10.1 255.255.255.0 vrrp vrid 1 virtual-ip 10.10.10.100 vrrp vrid 1 priority 200 vrrp vrid 1 preempt-mode timer delay 600 # interface GigabitEthernet0/1/1 portswitch undo shutdown port link-type trunk port trunk allow-pass vlan 100 # return
DeviceB configuration file
# sysname DeviceB # vlan batch 100 # ip pool huawei1 server gateway 10.10.10.1 255.255.255.0 section 0 10.10.10.1 10.10.10.100 server identifier ip 10.10.10.100 remote-backup-profile service1 # remote-backup-service service1 peer 10.10.10.1 source 10.10.10.2 port 10000 # remote-backup-profile service1 service-type dhcp-server backup-id 1 remote-backup-service service1 peer-backup hot vrrp-id 1 interface Vlanif100 # interface Vlanif100 ip address 10.10.10.2 255.255.255.0 vrrp vrid 1 virtual-ip 10.10.10.100 # interface GigabitEthernet0/1/1 portswitch undo shutdown port link-type trunk port trunk allow-pass vlan 100 # return