01-03 DHCP Configuration
01-03 DHCP Configuration
3 DHCP Configuration
Definition
The Dynamic Host Configuration Protocol (DHCP) automates the assignment of
network parameters to network devices. Even in small networks, DHCP is useful
because it makes it easy to add new devices to the network.
DHCP is based on the Bootstrap Protocol (BOOTP), which runs in a static
environment where each client has a fixed network connection. For each client
using BOOTP, a network administrator must configure a BOOTP parameter file
that requires manual intervention to modify. DHCP improves on BOOTP by
dynamically allocating IP addresses from an address pool and reclaiming them
when they are no longer in use. You can also use DHCP to deliver configuration
parameters, such as a configuration file used for startup, to clients.
DHCP is defined in RFC 2131 and enables the automatic configuration of DHCP
clients. It removes the need to configure clients individually and consists of two
Benefits
DHCP offers the following benefits:
● Reduced client configurations and costs
Because DHCP is easy to configure, it minimizes operational costs associated
with device configurations, eases deployment by non-technical users, and
reduces device configuration and maintenance costs at remote sites.
● Centralized management
Because the DHCP server maintains configurations for several subnets, an
administrator only needs to update a single, central server when configuration
parameters change.
IP Network
DHCP Client
DHCP Client
● DHCP server
A DHCP server assigns IP addresses from specified address pools to DHCP
clients. It can also manage these clients and provide network parameters such
as the default gateway address, Domain Name System (DNS) server address,
and Windows Internet Name Service (WINS) server address. A DHCP server
can accept broadcasts from locally attached LAN segments or DHCP requests
forwarded by DHCP relay agents within the network.
● DHCP client
A client can use BOOTP or DHCP to obtain its IP address and other network
parameters from a DHCP server. To obtain an IP address, the client sends a
BOOTP or DHCP Request message. DHCP clients can be IP phones, PCs,
mobile devices, diskless workstations, or other networked devices, and can be
connected directly or through other networks using DHCP relay agents.
● DHCP relay agent
DHCP relay agent forwards DHCP messages between a DHCP server and
DHCP clients and helps the DHCP server to dynamically allocate network
parameters to the DHCP clients.
When a DHCP client broadcasts DHCP Discovery messages with the
destination IP address 255.255.255.255, only the DHCP server on the same
network segment as the DHCP client can receive the messages. If a DHCP
server is on a different network segment from the DHCP client, a DHCP relay
agent must be deployed to forward DHCP Discovery messages to the DHCP
server. The DHCP relay agent modifies the format of a DHCP Discovery or
Offer message to generate a new DHCP message and then forwards it.
A lease is defined as the time period for which a DHCP server allocates an IP
address to a client. The lease can be extended upon subsequent requests. If the
client no longer needs the IP address, it can release the address back to the server
before the lease expires. The server is then free to assign this address to a
different client if no other idle IP address is available.
The lease period configured for a DHCP server applies to all of the IP addresses
that a DHCP server dynamically assigns to its clients. A different DHCP server may
have a different lease term for its clients. A statically allocated IP address is not
subject to the lease terms.
A DHCP client does not wait for its lease to expire, because it may be assigned a
different IP address. Instead, when a DHCP client reaches the halfway point of its
lease period, it attempts to extend its lease so that it retains the same IP address.
Address Pools
An address pool is a set of all the IP addresses that a DHCP server has reserved for
dynamic client allocation. Along with each IP address, the server stores certain
network parameters, such as a default lease length for the IP address and other
configuration parameters (for example, a subnet mask and the address of the
default gateway) to be sent to the client when it is assigned that IP address.
Address pools are classified into interface address pools and global address pools.
A DHCP server selects address pools according to whether a DHCP relay agent is
deployed. When no relay agent is deployed, the server selects the address pool on
the same network segment as the IP address of the interface receiving DHCP
Request messages. When relay agents are deployed, the server selects the address
pool on the same network segment as the IP address specified in the giaddr field
of received DHCP Request messages.
DHCP Nak A DHCP server sends this message to reject a DHCP Request
message from a DHCP client. For example, a DHCP server will
send this message if it determines that there is no available IP
address after receiving a DHCP Request message.
DHCP A DHCP client sends this message to notify the DHCP server
Decline that the allocated IP address conflicts with another IP address.
The DHCP client then applies to the DHCP server for another IP
address.
Figure 3-2 shows the format of a DHCP message and Table 3-2 describes each of
the fields in the DHCP message. In the figure, the numbers in parentheses indicate
the size of each field in bytes.
sname (64)
file (128)
options
(variable)
htype 1 byte Hardware Type: indicates the type of hardware used for
the local network. The values of this field differ for
different hardware types. The most common value is 1,
which indicates Ethernet (10 Mb).
hops 1 byte Hops: indicates the number of DHCP relay agents through
which a DHCP message passes. This value is set to 0 by a
client and is incremented by 1 each time the message
passes through a DHCP relay agent. A DHCP message
passes through a maximum of 16 DHCP relay agents
when being transmitted between a server and a client.
That is, the number of hops between the server and client
cannot exceed 16. Otherwise, the DHCP message is
discarded.
flags 2 bytes Flags: indicates the Flags field. Only the leftmost bit in
this field is used, and the other bits are set to 0. The
leftmost bit specifies the mode a DHCP server uses to
transmit a DHCP Offer message.
The values are:
● 0: The DHCP server unicasts a DHCP Offer message.
● 1: The DHCP server broadcasts a DHCP Offer message.
file 128 Boot File: indicates the name of the startup configuration
bytes file to be obtained by a client. This field is filled in by a
DHCP server and delivered to the client when a DHCP
address is allocated to the client. The field is optional and
must be a character string that ends with 0.
options Variabl Options: indicates the DHCP Options field. This field is a
e maximum of 1200 bytes in length and contains the DHCP
message type and configuration parameters allocated by
a DHCP server to a client. The configuration parameters
include the gateway IP address, DNS server IP address,
and IP address lease.
For details about the Options field, see DHCP Options.
DHCP Options
DHCP Options are tagged data items that provide control information and
parameters to a DHCP client. The options are sent in a variable-length field at the
end of a DHCP message. This field consists of Type, Length, and Value, which are
shown in Figure 3-3 and described in Table 3-3.
0 7 15
Type Length Value
The values of the Options field range from 1 to 255. Some DHCP options are
predefined and others can be user defined. Table 3-4 lists some of the common
predefined DHCP options.
Depending on whether a DHCP relay agent is used, the way in which network
parameters are allocated to a new DHCP client differs.
Figure 3-5 Message exchange between a DHCP server and a new DHCP client
when no DHCP relay agent is deployed
When a DHCP client accesses a network for the first time, it does not know the IP
address of the DHCP server. To learn this information, the client broadcasts a
DHCP Discover message in which the destination IP address is 255.255.255.255 to
all devices (including the DHCP server or relay agent) on the network segment.
The DHCP Discover message includes the client's MAC address (chaddr field),
parameter request list (Option 55), and broadcast flag (flags field).
The DHCP server on the same network segment as the DHCP client receives the
DHCP Discover message, selects an available IP address from the address pool
that is on the same network segment as the IP address of the interface that
receives the DHCP Discover message, and then sends a DHCP Offer message
carrying the selected IP address to the DHCP client.
In most cases, an address pool specifies the lease of the IP addresses it contains. If
the DHCP Discover message contains an expected lease, the server compares the
expected lease with the specified lease and allocates an IP address with the
shorter of the two leases to the client.
The DHCP server selects an IP address for a client from the address pool in the
following sequence:
NOTE
1. IP address statically bound to the MAC address of the client on the DHCP
server
2. IP address specified in the Option 50 (requested IP address) in the DHCP
Discover message
3. IP addresses in Expired status in the address pool, that is, the allocated IP
addresses whose lease time expires
4. IP address in idle status that is found when the DHCP server searches IP
addresses in a random order in an address pool (In V200R008C30 and earlier
versions, the DHCP server searches IP addresses in a descending order.)
5. If no available IP address is found, the address pool automatically reclaims
the IP addresses in Expired and Conflict status. If an IP address is available
after the reclaim, the server allocates this IP address. Otherwise, the DHCP
client sends a DHCP Discover message again to request an IP address after
the timeout interval for the client to wait for a response from the server
expires.
You can specify certain IP addresses to exclude on the DHCP server. For example, if
you have statically allocated 192.168.1.100/24 to your DNS server, you can exclude
this IP address from the address pool on network segment 192.168.1.0/24 so that
it is not allocated through DHCP. This helps prevent IP address conflicts.
(as it is in use by another client), and then waits for the next DHCP Discover
message to start the IP address selection process again.
The IP address allocated during the offer stage may not be the final IP address
used by the client. This is because the IP address may be allocated to another
client if the DHCP server receives no response 16 seconds after the DHCP Offer
message is sent. The IP address for the client can be determined only after the
request and acknowledgment stages.
If multiple DHCP servers reply with a DHCP Offer message to the client, the client
accepts only the first DHCP Offer message it receives. The client then broadcasts a
DHCP Request message carrying the selected DHCP server identifier (Option 54)
and IP address (Option 50, with the IP address specified in the yiaddr field of the
accepted DHCP Offer message).
The DHCP Request message notifies all the DHCP servers of the IP address that
the DHCP client has selected. The unselected IP addresses offered by other DHCP
servers are then free to be allocated to other clients.
After receiving a DHCP Request message, the DHCP server sends to the client a
DHCP Ack message that contains the IP address specified in the Option 50 field of
the DHCP Request message.
To determine whether any other device is using this IP address, the DHCP client
broadcasts gratuitous ARP packets after receiving the DHCP Ack message. The
client can use this IP address if no response is received within the specified time.
However, if the DHCP client receives a response within the specified time, this IP
address is already in use. The client then sends a DHCP Decline message to the
DHCP server and applies for a new IP address. The server lists this IP address as a
conflicting IP address.
Occasionally, the DHCP server may not allocate the IP address specified in the
Option 50 field because, for example, an error occurs during negotiation or it
does not receive the DHCP Request message quickly enough. In this case, the
server replies with a DHCP Nak message to notify the client that the requested IP
address cannot be allocated. The client then sends a DHCP Discover message to
apply for a new IP address.
Figure 3-6 shows the message exchange process between a DHCP server and a
new DHCP client when a DHCP relay agent is deployed.
Figure 3-6 Message exchange between a DHCP server and a new DHCP client
when a DHCP relay agent is deployed
DHCP Relay
DHCP Client Agent DHCP Server
When a DHCP relay agent receives a DHCP Discover message, it performs the
following steps:
1. Check the value of the hops field. If this value exceeds 16, the relay agent
discards the message. Otherwise, the relay agent increases this value by 1 and
proceeds to the next step.
2. Check the value of the giaddr field. If this value is 0, the relay agent sets the
giaddr field to the IP address of the interface receiving the DHCP Discover
message. Otherwise, the relay agent does not change the field and proceeds
to the next step.
3. Change the destination IP address of the DHCP Discover message to the IP
address of the DHCP server or the next-hop DHCP relay agent, and change
the source IP address to the IP address of the interface connecting the DHCP
relay agent to the client. The relay agent then unicasts this message to the
DHCP server or the next-hop DHCP relay agent.
If there are multiple DHCP relay agents between the DHCP client and server, each
the DHCP relay agent processes the DHCP Discover message using the same
method.
After receiving a DHCP Discover message, the DHCP server selects an address pool
on the same network segment as that specified in the giaddr field and allocates
an IP address and other network parameters from the address pool. The DHCP
server then unicasts a DHCP Offer message to the DHCP relay agent specified in
the giaddr field.
When the DHCP relay agent receives a DHCP Offer message, it performs the
following steps:
1. Check the value of the giaddr field. If this value is the IP address of the
interface receiving the DHCP Offer message, the DHCP relay agent discards
the message. Otherwise, the relay agent proceeds to the next step.
2. Check the value of the flags field. If this value is 1, the DHCP relay agent
broadcasts a DHCP Offer message to the DHCP client. Otherwise, the DHCP
relay agent unicasts a DHCP Offer message.
The DHCP relay agent processes the DHCP Request message from the client in the
same manner as that described in Stage 3: The Request Stage.
The DHCP relay agent processes the DHCP Ack message from the server in the
same manner as that described in Stage 4: The Acknowledgment Stage.
NOTE
Not all clients can reuse IP addresses that have been allocated to them. The following uses a PC
as the DHCP client to describe how the DHCP client reuses an IP address.
Figure 3-7 Message exchange for IP address reuse between a DHCP client and a
server
The DHCP client broadcasts a DHCP Request message that contains the IP address
used previously by the client. The requested IP address is added in the Option 50
field.
After receiving the DHCP Request message, the DHCP server checks whether there
is a lease record based on the MAC address in the message. If there is a lease
record matching the MAC address, the DHCP server replies with a DHCP Ack
message to notify the client that it can use the requested IP address. Otherwise,
the server ignores the request and waits for a new DHCP Discover message from
the client.
Figure 3-8 shows how a DHCP client renews its IP address lease.
1. When the lease reaches 50% (T1) of its validity period, the DHCP client
unicasts a DHCP Request message to the DHCP server to request lease
renewal. If the server renews the lease (counted from 0), it sends a DHCP Ack
message to the client. If the server rejects the renewal request, it sends a
DHCP Nak message to the client, which must then send a DHCP Discover
message to apply for a new IP address.
2. If no response is received from the DHCP server when the lease reaches
87.5% (T2) of its validity period, the DHCP client broadcasts a DHCP Request
message to request lease renewal. Similar to T1, if the client receives a DHCP
Ack message, the server has renewed the lease; if the client receives a DHCP
Nak message, the client must send a DHCP Discover message to apply for a
new IP address.
3. If no response is received when the lease expires, the client stops using the IP
address and sends a DHCP Discover message to apply for a new IP address.
When a DHCP client no longer needs to use its allocated IP address and the lease
has not expired, the client sends a DHCP Release message to the DHCP server to
request IP address release. The server saves the configuration of this client and
records the IP address in the allocated IP address list. The IP address can then be
allocated to this client or other clients. To request a configuration update, a client
can send a DHCP Inform message to the server.
The renewal process is similar when a DHCP relay agent is used. Figure 3-9 shows
how a DHCP client renews its IP address lease when a DHCP relay agent is
deployed.
Figure 3-9 Renewing the IP address lease when a DHCP relay agent is deployed
DHCP Relay
DHCP Client Agent DHCP Server
Licensing Requirements
DHCP is a basic feature of the device and is not under license control.
Feature Limitations
Wireless interfaces cannot function as DHCP clients or BOOTP clients.
Planning IP Addresses
Plan the range of IP addresses that can be allocated and the mechanisms (such as
dynamic or static) used to allocate the IP addresses.
Plan the IP addresses that cannot be allocated from an address pool. For example,
in an enterprise, a DHCP server allocates IP addresses on the network segment
192.168.1.0/24 to employee PCs. On this network segment, 192.168.1.10 has been
used by a DNS server and must be excluded from the address pool to prevent IP
address conflicts.
Planning Leases
Plan an IP address lease for a DHCP client based on the expected time that the
client will be online. By default, the IP address lease is 1 day.
● In scenarios where clients often move and stay online for a short period of
time, for example, in cafes, airports, and hotels, plan a short-term lease to
ensure that IP addresses are released quickly after the clients go offline.
● In scenarios where clients seldom move and stay online for a long period of
time, for example, in office areas of an enterprise, plan a long-term lease to
prevent services from being affected by frequent lease or address renewals.
Context
Before enabling the DHCP server function, enable DHCP in the system view.
NOTE
● The dhcp enable command is the prerequisite for configuring DHCP-related functions,
including DHCP relay, DHCP snooping, and DHCP server. These functions take effect only
after the dhcp enable command is run. After the undo dhcp enable command is run, all
DHCP-related configurations of the device are deleted. After DHCP is enabled again using
the dhcp enable command, all DHCP-related configurations of the device are restored to the
default configurations.
● After DHCP is enabled, if STP is also enabled, address allocation may slow down. By default,
STP is enabled. To disable STP, run the undo stp enable command.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
Before a device can function as a DHCP server, you must enable DHCP. You can
then enable the DHCP server function to operate based on an interface address
pool or based on a global address pool.
NOTE
The DHCP server function based on an interface address pool and a global address pool can be
configured on MEth management interfaces (using the dhcp select interface and dhcp select
global commands, respectively) to enable access terminals to obtain IP addresses. The
interfaces do not support other DHCP server functions.
Procedure
● Enable the DHCP server function based on an interface address pool.
a. Enter the system view.
system-view
d. Enable the interface to use the interface address pool for providing the
DHCP server function.
dhcp select interface
By default, the DHCP server function using the interface address pool is
disabled on an interface
If the device functioning as the DHCP server provides the DHCP service
for clients connected to multiple interfaces, repeat this step to enable the
DHCP server function on all the interfaces.
● Enable the DHCP server function based on a global address pool.
a. Enter the system view.
system-view
NOTE
The device can select a global address pool based on the primary and secondary
IP addresses of an interface only in scenarios where the DHCP server and DHCP
clients are on the same network segment.
▪ If the DHCP client and server are located in the same network
segment, the DHCP server selects the address pool based on the
primary and secondary interface IP addresses. It preferentially
allocates IP addresses from the address pool for the primary IP
address. If IP addresses in this address pool are used up or this
address pool is not configured, the DHCP server allocates IP
addresses from the address pool for the secondary IP address.
By default, an interface does not use the global address pool to provide
the DHCP server function.
----End
Context
Automatically saving IP address allocation information allows the DHCP server to
re-allocate the same configurations (such as IP address and lease time) to clients
in the event that the server unexpectedly restarts.
NOTE
● After this function is enabled, the DHCP server stores lease information in lease.txt and
conflicting IP addresses in conflict.txt (both data files are saved to the DHCP folder). New
data files overwrite earlier data files.
The time displayed in the lease.txt and conflict.txt files is the UTC time rather than the
system time, and you do not need to pay attention to time zone information.
● To view information about the DHCP database, run the display dhcp server database
command.
Procedure
Step 1 Enter the system view.
system-view
Step 2 Enable the DHCP server to automatically save IP address allocation information.
dhcp server database enable
By default, the DHCP server does not automatically save IP address allocation
information.
Step 3 Specify the interval at which the DHCP server saves IP address allocation
information.
dhcp server database write-delay interval
----End
Context
IP address conflict detection uses ICMP to determine whether an IP address to be
allocated conflicts with other IP addresses that are already allocated to clients.
After this function is configured, a DHCP server sends an ICMP Echo Request
message in which the source address is the IP address of the DHCP server and the
destination address is the pre-allocated IP address for IP address conflict detection,
before sending a DHCP Offer message to a client.
● If the DHCP server does not receive any ICMP Echo Reply message within the
detection period (Number of detections x Maximum wait time for each
conflict detection), this IP address is not used by any client. The DHCP server
allocates the IP address to the client by sending a DHCP Offer message.
● If the DHCP server receives an ICMP Echo Reply message within the detection
period (Number of detections x Maximum wait time for each conflict
detection), this IP address is being used by a client. The DHCP server lists this
IP address as a conflicting IP address and waits for the next DHCP Discover
message to select another available IP address.
NOTE
If the detection time is too long, clients may fail to obtain IP addresses. You are advised to set
the detection time to less than 8 seconds.
Procedure
Step 1 Enter the system view.
system-view
Step 2 Specify the number of IP address conflict detections before IP address allocation.
dhcp server ping packet number
Step 3 Specify the maximum wait time for each conflict detection.
dhcp server ping timeout milliseconds
By default, the maximum wait time for each conflict detection is 500 milliseconds.
----End
Context
If you have BOOTP clients on your network and you want them to dynamically
obtain IP addresses through DHCP, configure the DHCP server to service these
clients.
Procedure
Step 1 Enter the system view.
system-view
Step 3 Enable the DHCP server to dynamically allocate IP addresses to BOOTP clients.
dhcp server bootp automatic
----End
Context
When a DHCP client goes online in two steps, the IP address requested by the
DHCP client is in the IP address pool, but no lease record of the DHCP client is
found in the address pool. For example, after obtaining an IP address from
another DHCP server, a wireless user roams to the current DHCP server and the
original IP address is in the address pool of the current DHCP server. Alternatively,
the address pool is reset and the original user needs to go online again. In this
case, when receiving a DHCP Request message from the DHCP client, the DHCP
server keeps silent and does not reply the DHCP client with a DHCP NAK message.
The DHCP client can apply for an IP address to go online again in four steps only
after the two steps for the client to go online time out. As a result, the DHCP
client is slow in obtaining an IP address. To force the DHCP server to reply with a
DHCP NAK message, you can run the dhcp server force response command, so
that the DHCP client can quickly enter the four-step process for going online and
apply for an IP address again.
Procedure
Step 1 Enter the system view.
system-view
Step 2 Force the DHCP server to reply with a DHCP Nak message.
dhcp server force response
By default, a DHCP server is not forced to reply with a DHCP Nak message.
----End
Context
To prevent an attacker from sending a large number of DHCP messages, you can
configure the DHCP rate limiting function on the device to limit the rate of DHCP
messages from clients. The device can send only a specified number of DHCP
messages in a certain period of time and discards excess DHCP messages.
You are advised to configure DHCP message rate limiting on user-side devices. If
the device functions as the DHCP server and directly connects to DHCP clients,
configure rate limiting on the device; if the device functions as the DHCP server
and connects to a DHCP relay agent or DHCP snooping device, configure rate
limiting on the DHCP relay agent or DHCP snooping device.
You can configure rate limiting in the system, VLAN, or interface view. The
configuration takes effect in the interface view, VLAN view, and system view in
descending order of priority.
Procedure
● Configure DHCP rate limiting in the system view.
a. Enter the system view.
system-view
By default, DHCP messages are sent to the DHCP stack at the rate of 100
pps. Excess packets in a specified period of time are discarded.
d. (Optional) Enable the trap function for rate limiting.
dhcp alarm dhcp-rate enable
By default, the alarm threshold for checking DHCP message rates is 100.
After the trap function for rate limiting is enabled, the device discards
packets whose rate exceeds the rate limit. When the number of discarded
packets exceeds the alarm threshold, the system generates an alarm.
By default, DHCP messages are sent to the DHCP stack at the rate of 100
pps. Excess packets in a specified period of time are discarded.
● Configure DHCP rate limiting in the interface view.
a. Enter the system view.
system-view
By default, DHCP messages are sent to the DHCP stack at the rate of 100
pps. Excess packets in a specified period of time are discarded.
e. (Optional) Enable the trap function for rate limiting.
dhcp alarm dhcp-rate enable
This function allows the system to generate an alarm when the number
of discarded DHCP messages on the interface reaches the threshold.
f. (Optional) Specify the alarm threshold for checking DHCP message rates.
dhcp alarm dhcp-rate threshold threshold
By default, the alarm threshold for checking DHCP message rates is 100.
After the trap function for rate limiting is enabled, the device discards
packets whose rate exceeds the rate limit. When the number of discarded
packets exceeds the alarm threshold, the system generates an alarm.
----End
Context
Create an interface address pool for IP address allocation to clients on the same
network segment as the DHCP server's interface, or create a global address pool
for IP address allocation to all clients connected to the DHCP server.
Procedure
● Create an interface address pool.
a. Enter the system view.
system-view
NOTE
The IP address segment of the interface is the interface address pool. The interface
address mask cannot be set to 31; otherwise, the interface address pool may fail to be
configured.
● Create a global address pool.
a. Enter the system view.
system-view
b. Create a global address pool and enter the global address pool view.
ip pool ip-pool-name
NOTE
When specifying the IP address range, ensure that IP addresses within the range are
on the same network segment as the interface IP address of the DHCP server or
DHCP relay agent to avoid incorrect IP address allocation.
When configuring an address pool, ensure that IP addresses on the network address
segment must be class A, B, or C IP addresses, and the mask cannot be set to 0, 1, 31,
or 32.
d. (Optional) Configure a VPN instance for the address pool.
vpn-instance vpn-instance-name
Context
This configuration allows you to determine the scope of IP addresses that a DHCP
server can allocate.
Procedure
● Configure a range in an interface address pool:
a. Enter the system view.
system-view
c. Specify the range of IP addresses that the DHCP server can allocate.
dhcp server ip-range start-ip-address end-ip-address
NOTE
Note the following points when specifying IP address segment of the global
address pool:
● If you run the network (IP address pool view) first, ensure that the address
segment specified in the section (IP address pool view) command is
included in the address range specified in the network (IP address pool
view) command.
● If you run the section (IP address pool view) first, ensure that the address
segment specified in the network (IP address pool view) command includes
the address range specified in the section (IP address pool view) command.
----End
Context
To prevent a DHCP server from allocating specific IP addresses, exclude these IP
addresses from the address pool.
NOTE
You do not need to exclude the gateway address configured using the gateway-list or dhcp
server gateway-list command from being automatically allocated. The device automatically
adds the gateway address into the list of IP addresses that cannot be automatically allocated.
You do not need to exclude the IP address of a server's interface connecting to a client from
being automatically allocated. The device automatically sets the interface IP address to the
Conflict status during address allocation.
Procedure
● Exclude IP addresses from an interface address pool.
a. Enter the system view.
system-view
----End
Context
A DHCP server leases IP addresses to clients. When the lease expires, the clients
must apply for new IP addresses. To ensure stability, certain clients require fixed IP
addresses. In this case, configure the DHCP server to allocate fixed IP addresses to
these clients. The MAC addresses of these clients are then bound to fixed IP
addresses. When such a client applies to the DHCP server for an IP address, the
DHCP server searches the binding entries for the MAC address of the client and
allocates the matched IP address to the client. DHCP static allocation prevents
manual configuration errors and facilitates unified management.
NOTE
● Ensure that the bound IP address is not configured as the IP address that cannot be
allocated and is not allocated by the DHCP server.
● You can run the display ip pool command to view the used IP addresses in the current
address pool and select an available IP address to be bound to the MAC address. To bind
used IP addresses to MAC addresses, run the reset ip pool command to reclaim used IP
addresses first. IP addresses that are used can also be statically bound to MAC addresses or
unbound from MAC addresses. When an IP address is statically bound to a MAC address,
ensure that the MAC address to be bound is the same as the MAC address of the user who
actually uses the IP address.
● After an IP address is bound to a MAC address, the IP address does not expire; the binding
between the IP and MAC addresses cannot be deleted when the IP address is in use. After an
IP address is bound to a MAC address, the IP address does not expire. After an automatically
allocated IP address is statically bound to a MAC address, the lease time of the IP address
becomes unlimited. After the static binding between the IP address and the MAC address is
deleted, the lease time of the IP address becomes the same as that configured in the address
pool.
The binding of IP addresses and MAC addresses is used in DHCP static allocation,
IP source guard, and static ARP. Table 3-6 lists different usage scenarios and
implementations of these functions.
Table 3-6 Differences between DHCP static allocation, IPSG, and static ARP
Function Scenario Implementation
Procedure
● Configure a fixed IP address in an interface address pool.
a. Enter the system view.
system-view
----End
Context
The default lease time in an address pool is 1 day. An administrator can change an
address lease time based on network requirements. IP addresses in the same
address pool use the same lease time, and different address pools can have
different address leases specified. After the lease of an address pool is changed,
newly allocated IP addresses use the new lease. The IP addresses that have been
allocated before the lease is changed still use the old lease before the old lease is
updated and use the new lease after the old lease is updated.
NOTE
The BOOTP client does not support the configuration of an address lease time.
The IP addresses statically allocated to clients are always valid, without being limited by
address lease time.
Procedure
● Configure a lease time based on an interface address pool.
a. Enter the system view.
system-view
Context
When a DHCP server allocates IP addresses to clients, IP address conflict may
occur because IP addresses of some hosts have been manually configured. In this
case, the DHCP server considers these IP addresses as conflicting IP addresses, and
allocates available IP addresses from the conflicting IP addresses to clients only
after available IP addresses in the address pool are used up. To reclaim conflicting
IP addresses promptly, the administrator can enable automatic reclaim and specify
the reclaim interval.
Procedure
● Interface address pool:
a. Run system-view
The system view is displayed.
b. Enter the interface or sub-interface view.
interface interface-type interface-number [.subinterface-number ]
c. Run dhcp server conflict auto-recycle interval day day [ hour hour
[ minute minute ] ]
Automatic reclaim of conflicting IP addresses in the interface address
pool is enabled and the interval for the automatic reclaim is configured.
By default, automatic reclaim of conflicting IP addresses in the interface
address pool is disabled.
● Global address pool:
a. Run system-view
The system view is displayed.
b. Run ip pool ip-pool-name
The global address pool view is displayed.
----End
Context
To receive notifications about IP address exhaustion, configure the DHCP to
generate alarms for IP address exhaustion.
Procedure
● Configure the alarm function in an interface address pool.
a. Enter the system view.
system-view
----End
Context
Configuring the DHCP server to log IP address allocation provides you with records
that may facilitate maintenance and diagnostics.
NOTE
● With this logging function enabled, if a large number of DHCP clients request IP
addresses from the DHCP server, the server frequently records logs. The server
performance may therefore be affected.
● IP address allocation logs are recorded in the AM module. To view log information, the
information center must be enabled. In addition, default settings for log output vary
depending on various factors including the log level and output direction. For details,
see Information Center Configuration.
For example, the level of logs indicating that an IP address is successfully allocated, an
IP address is successfully renewed, and an IP address is successfully released is
informational, and these logs are not recorded in the log buffer by default. You can run
the info-center source AM channel 4 log level informational command to change the
level of the logs to be recorded in the log buffer. You can then run the display
logbuffer command to check the preceding logs.
Procedure
● Configure the logging function in an interface address pool.
a. Enter the system view.
system-view
b. Enter the interface or sub-interface view.
interface interface-type interface-number [.subinterface-number ]
c. Enable the DHCP server to record IP address allocation logs.
dhcp server logging [ allocation-fail | allocation-success | release | renew-fail | renew-
success | detect-conflict | recycle-conflict ] *
Context
If a gateway address for clients is configured on the DHCP server, clients obtain
the gateway address from the DHCP server and automatically generate a default
route to the gateway address. Then the clients can access the hosts on other
network segments. If the DHCP server is configured with Option 121 to allocate
classless static routes to clients, the clients generate routes based on only the
static routes and does not generate a default route to the gateway address. To
load balance traffic and improve network reliability, configure multiple gateway
addresses. A maximum of eight gateway addresses can be configured for each
address pool.
In the scenario where both VRRP and DHCP are configured, if a VRRP group
functions as the DHCP server, configure the gateway address of clients as the
virtual IP address of the VRRP group.
If the DHCP server and clients are on the same network segment and the DHCP
server functions as the gateway of clients, you do not need to configure a gateway
address for clients.
Procedure
● Configure a gateway address in the interface address pool view.
a. Enter the system view.
system-view
b. Create a DHCP Option template and enter the DHCP Option template
view.
dhcp option template template-name
----End
Context
DHCP can be used to deliver configuration files to clients that require them for
startup. You can save the configuration files on the DHCP server or specify the IP
address of a dedicated file server. When a configuration file exists on a dedicated
file server, the DHCP server needs to specify the IP address of the file server for
clients. You can also specify an IP address for the file server by configuring user-
defined options for clients.
NOTE
If the startup configuration file is saved on a file server, the route between the DHCP client and
file server must be reachable.
Procedure
● Configure a configuration file based on an interface address pool.
a. Enter the system view.
system-view
b. Create a DHCP Option template and enter the DHCP Option template
view.
dhcp option template template-name
By default, the name of the startup configuration file for DHCP clients is
not configured.
d. Specify the name of the server that hosts the configuration file.
sname sname
By default, the name of the server from which a DHCP client obtains the
startup configuration file is not configured.
e. (Optional) Specify the name of the server that hosts the configuration
file.
next-server ip-address
By default, the server IP address is not configured for the client after the
client automatically obtains the IP address.
If you need to configure other items in the DHCP Option template view,
complete them first before performing the following steps.
f. (Optional) Return to the system view.
quit
----End
Context
A DHCP server can allocate user-defined options to clients using the following
methods:
● Based on the options in DHCP Discovery messages
Configure the options using the dhcp server option (based on an interface
address pool) or option (based on a global address pool) command. The
DHCP server provides options only if clients request them.
● By forcibly appending the Options field
Configure the options using the dhcp server force insert option (based on an
interface address pool) or force insert option (based on a global address
pool) command. The DHCP server inserts the Options field in a DHCP Reply
message, regardless of whether clients request the options.
Procedure
● Configure user-defined options for clients based on an interface address pool.
a. Enter the system view.
system-view
d. (Optional) Force the DHCP server to insert an Option field into DHCP
Reply messages.
dhcp server force insert option code &<1-254>
By default, the DHCP server does not forcibly insert an Option field to
DHCP Reply messages.
NOTE
Not all options can be configured using the preceding command. The
following table lists the options and their commands.
iv. (Optional) Force the DHCP server to insert an Option field into DHCP
Reply messages.
force insert option code &<1-254>
By default, the DHCP server does not forcibly insert an Option field
to DHCP Reply messages.
v. Configure DHCP options.
option code [ sub-option sub-code ] { ascii ascii-string | hex hex-string | cipher cipher-
string | ip-address ip-address &<1-8> }
By default, no option is configured.
NOTE
Not all options can be configured using the preceding command. The
following table lists the options and their commands.
ii. Create a DHCP Option template and enter the DHCP Option
template view.
dhcp option template template-name
By default, the DHCP server does not forcibly insert an Option field
to DHCP Reply messages.
iv. Configure DHCP options.
option code [ sub-option sub-code ] { ascii ascii-string | hex hex-string | cipher cipher-
string | ip-address ip-address &<1-8> }
By default, no option is configured.
NOTE
----End
Context
If DHCP clients on your network use DNS and you want them to receive DNS
configurations through DHCP, configure the DHCP server to provide DNS
configurations.
The DNS server IP address, DNS domain name suffix, and NetBIOS server IP
address in the address pool can be statistically specified or automatically obtained.
The NetBIOS node type can only be statically specified. If the address pool
contains the configurations that are statistically specified and automatically
obtained, the statistically specified configuration takes precedence.
Procedure
● Based on an interface address pool
a. Enter the system view.
system-view
By default, the DHCP server does not allocate the automatically obtained
DNS configurations to DHCP clients.
d. Configure the DHCP server to allocate the statically specified DNS
configurations to DHCP clients.
By default, the DHCP server does not allocate the automatically obtained
DNS configurations to DHCP clients.
d. Configure the DHCP server to allocate the statically specified DNS
configurations to DHCP clients.
b. Create a DHCP Option template and enter the DHCP Option template
view.
dhcp option template template-name
----End
Context
If DHCP clients on your network use NetBIOS and you want them to receive
NetBIOS configurations through DHCP, configure the DHCP server to provide
NetBIOS configurations.
The DNS server IP address, DNS domain name suffix, and NetBIOS server IP
address in the address pool can be statistically specified or automatically obtained.
The NetBIOS node type can only be statically specified. If the address pool
contains the configurations that are statistically specified and automatically
obtained, the statistically specified configuration takes precedence.
If the configuration is to be automatically obtained, the device as the DHCP server
also needs to function as the DHCP client (the DHCP client function is configured
on the interface connected to the remote DHCP server). The device obtains the
DNS server IP address, DNS domain name suffix, and NetBIOS server IP address
from the remote DHCP server, and then uses the import function of the address
pool to allocate the information to the downlink client. For example, the DHCP
server of a company needs to obtain the uniform DNS server IP address, DNS
domain name suffix, and NetBIOS server IP address from the carrier, and allocate
the information to the downlink client. In this case, the configuration can be
automatically obtained.
Procedure
● Based on an interface address pool
a. Enter the system view.
system-view
By default, the DHCP server does not allocate the automatically obtained
NetBIOS server IP address to DHCP clients.
d. Configure the DHCP server to allocate the statically specified NetBIOS
configurations to DHCP clients.
By default, the DHCP server does not allocate the automatically obtained
NetBIOS server IP address to DHCP clients.
d. Configure the DHCP server to allocate the statically specified NetBIOS
configurations to DHCP clients.
b. Create a DHCP Option template and enter the DHCP Option template
view.
dhcp option template template-name
----End
Context
When you configure a SIP server IP address in an address pool, the DHCP server
specifies the SIP server IP address when allocating IP addresses to DHCP clients.
Procedure
● Configure a SIP server address in an interface address pool.
a. Enter the system view.
system-view
b. Create a DHCP Option template and enter the DHCP Option template
view.
dhcp option template template-name
----End
Context
As shown in Figure 3-10 and Figure 3-11, the router functions as the backup
DHCP server. You can associate the IP address pool on the router with NQA test
instances to check the DHCP server status (including the link and DHCP server
function). This can improve network reliability. When the DHCP server is working
properly, the IP address pool on the router is locked, and PC1 and PC2 obtain IP
addresses through the DHCP server. When NQA detects that the DHCP server is
faulty, the IP address pool on the router is unlocked and assigns an IP address to
PC3 that is newly online. When NQA detects that the DHCP server fault is
rectified, the IP address pool on the router is locked again, and PC4 that is newly
online obtains an IP address through the DHCP server.
This function is configured only for a global address pool.
NOTE
When the DHCP server is faulty, PC3 obtains an IP address from the router; when the DHCP
server is recovered, the DHCP function is switched back to the DHCP server. At this time, if the
IP address lease of PC3 has expired, the lease renewal will fail. After PC3 goes offline
temporarily, it re-obtains an IP address from the DHCP server. In addition, the two IP addresses
obtained by PC3 are different because the IP address pools on the DHCP server and router have
different address ranges.
Figure 3-10 Associating the IP address pool with NQA (router and client locating
in the same network segment)
Figure 3-11 Associating the IP address pool with NQA (router and client locating
in different network segments)
Router
Router DHCP server Router
Backup DHCP (from backup to Backup DHCP
server master) server
Procedure
Step 1 Configure and start NQA test instances.
An IP address pool can be associated with NQA test instances of the DHCP and
ICMP types. NQA test instances of the DHCP type are used to test whether the
DHCP server function is normal; those of the ICMP type are used to test whether
routes to the DHCP server are reachable. When the device uses NQA test instances
of the ICMP type, it cannot detect the status of the DHCP server function.
Therefore, the device cannot detect the situation in which the route is reachable
but the DHCP server function is unavailable, and users cannot go online.
b. Create an NQA test instance and enter the test instance view.
nqa test-instance admin-name test-name
By default, no NQA test instance is configured.
c. Set the NQA test instance type to DHCP.
test-type dhcp
By default, no test type is configured for an NQA test instance.
d. Specify the source interface to send DHCP messages.
source-interface interface-type interface-number
By default, no source interface is configured for an NQA test instance.
e. Set the automatic test interval for the NQA test instance.
frequency interval
By default, no automatic test interval is set. The system performs the test
only once.
f. Start the NQA test instance.
start
An NQA test instance can be started immediately, at a specified time, or
after a specified delay.
NOTE
Before using the test instance of the DHCP type, ensure that the DHCP server provides
the address pool for the network segment of the source interface (specified running
the source-interface interface-type interface-number command). You can use the
source interface to simulate a DHCP client to send a DHCP request, and determine the
DHCP server status depending on whether an IP address can be obtained.
● Configure and start an NQA test instance of the ICMP type.
a. Enter the system view.
system-view
b. Create an NQA test instance and enter the test instance view.
nqa test-instance admin-name test-name
By default, no NQA test instance is configured.
c. Set the test type to ICMP.
test-type icmp
By default, no test type is configured for an NQA test instance.
d. Configure the destination address.
destination-address ipv4 ipv4-address
By default, no test destination address is configured.
e. Set the automatic test interval for the NQA test instance.
frequency interval
By default, no automatic test interval is set. The system performs the test
only once.
f. Start the NQA test instance.
start
NOTE
● To persistently detect the DHCP server status, you need to perform periodical test for
NQA test instances. Therefore, run the frequency interval command to set the
automatic test interval for NQA test instances.
● This section only mentions basic configuration parameters of the DHCP and ICMP NQA
test instances. For details on how to configure other parameters, see Configuring DHCP
Test and Configuring ICMP Test in the Huawei AR Series V200R010 Configuration Guide-
Network Management and Monitoring.
Step 3 Configure the IP addresses that are not automatically allocated in the address
pool.
excluded-ip-address start-ip-address [ end-ip-address ]
NOTE
The IP addresses assigned by the backup DHCP server cannot overlap with those assigned
by the DHCP server, which prevents repeated assignment of an IP address. Therefore, you
need to run the excluded-ip-address start-ip-address [ end-ip-address ] command to
exclude the IP addresses that are repeated with those of the remote DHCP service.
Step 4 Associate the IP address pool the NQA test instance. The device determines
whether to lock the address pool according to the test result of the NQA test
instance.
lock track nqa admin-name test-name
NOTE
When the NQA test instance type is not DHCP and ICMP, the association between the IP address
pool and NQA do not take effect. In this case, the IP address pool is locked.
----End
Procedure
● Check IP address allocation information in address pools using the following
commands:
– Interface address pool:
display ip pool [ interface interface-pool-name [ start-ip-address [ end-
ip-address ] | all | conflict | expired | used ] ]
– Global address pool:
display ip pool [ name ip-pool-name [ start-ip-address [ end-ip-
address ] | all | conflict | expired | used [ user-type { dhcp | pppoe | l2tp
| ipsec | ssl-vpn | ppp } ] ] ]
● Run the display dhcp server database command to view the path for storing
the DHCP database.
● Run the display dhcp option template [ name template-name ] command
to view the configuration of a DHCP Option template.
● Run the display ip pool import all command to view the DNS and NetBIOS
configurations that the address pool automatically obtains and allocates to
the DHCP clients.
● Run the display dhcp server configuration command to check configurations
about the DHCP server.
----End
Context
Before enabling the DHCP relay function, enable DHCP in the system view.
NOTE
● The dhcp enable command is the prerequisite for configuring DHCP-related functions,
including DHCP relay, DHCP snooping, and DHCP server. These functions take effect only
after the dhcp enable command is run. After the undo dhcp enable command is run, all
DHCP-related configurations of the device are deleted. After DHCP is enabled again using
the dhcp enable command, all DHCP-related configurations of the device are restored to the
default configurations.
● After DHCP is enabled, if STP is also enabled, address allocation may slow down. By default,
STP is enabled. To disable STP, run the undo stp enable command.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
Enable the DHCP relay function on an interface so that the interface functions as
a DHCP relay agent.
Procedure
Step 1 Enter the system view.
system-view
NOTE
● The DHCP relay function is configured on the user-side gateway interface typically. The
IP address of the gateway interface must be on the same network segment as the
address pool configured on the DHCP server; otherwise, DHCP clients cannot obtain IP
addresses.
NOTE
When enabling the DHCP relay function on a sub-interface, run the arp broadcast enable
command on the sub-interface to enable ARP broadcast on the VLAN tag termination sub-
interface. By default, ARP broadcast is enabled on a VLAN tag termination sub-interface.
If DHCP relay is enabled in a super-VLAN, DHCP snooping cannot be enabled in this super-
VLAN.
----End
Context
You must specify the IP address of the DHCP server so that the DHCP relay agent
can forward DHCP messages between the server and clients. Two methods are
available for you to specify the DHCP server IP address: in the interface view and
in the DHCP server group view. The former method is recommended if you
configure the DHCP relay function on individual interfaces connected to DHCP
servers that have different IP addresses. The latter method is recommended if you
configure the DHCP relay function on multiple interfaces that connect to one
DHCP server.
NOTE
A maximum of 16 DHCP relay agents are allowed between a DHCP server and a DHCP client. If
there are more than 16 DHCP relay agents, DHCP messages are discarded.
Procedure
● Specify the DHCP server IP address in the interface view.
a. Enter the system view.
system-view
b. (Optional) Configure the DHCP server polling function on the DHCP relay
agent.
ip relay address cycle
NOTE
If the DHCP relay agent connects to a special client whose TTL value of DHCP
Discovery messages is 1, and if there are routing devices between the DHCP relay
agent and DHCP server, run the dhcp set ttl ttl-value command to specify a fixed
TTL value (16 is recommended) for DHCP Discovery messages after they are
forwarded by the DHCP relay agent at Layer 3.
d. Enter the interface or sub-interface view.
interface interface-type interface-number [.subinterface-number ]
e. Specify the IP address of a DHCP server.
dhcp relay server-ip ip-address
NOTE
If the DHCP relay agent connects to a special client whose TTL value of DHCP
Discovery messages is 1, and if there are routing devices between the DHCP relay
agent and DHCP server, run the dhcp set ttl ttl-value command to specify a fixed
TTL value (16 is recommended) for DHCP Discovery messages after they are
forwarded by the DHCP relay agent at Layer 3.
d. Create a DHCP server group and enter its view.
dhcp server group group-name
Skip this step if the interface connecting the DHCP relay agent to clients
functions as the gateway.
The gateway address specified in this step must be the same as the
egress gateway address of clients specified on the DHCP server. If the
device functions as the DHCP server, refer to 3.5.3.8.9 (Optional)
Configuring a Gateway Address for Clients for details about how to
specify the egress gateway address for clients.
g. (Optional) Bind the DHCP server group to a VPN instance.
vpn-instance vpn-instance-name
----End
Context
To enable a DHCP relay agent to accept, process, and forward DHCP messages
that carry Option 82 information, you must configure the DHCP relay agent to
trust and process this option.
You are advised to perform the configuration on a user-side device. If the DHCP
relay agent connects to a DHCP snooping-enabled device, configure the strategies
for processing Option 82 information on the DHCP snooping device. When a
device functions as the DHCP snooping device, for details on how to perform the
configuration, see Inserting the Option 82 Field in a DHCP Message in the Huawei
AR Series V200R010 Configuration Guide - Security.
NOTE
If the device functions as the first-hop DHCP relay agent, it can process Option 82 information.
If the device functions as the second-hop or subsequent DHCP relay agent, it cannot process
Option 82 information.
Procedure
Step 1 Enter the system view.
system-view
● Configure the DHCP relay agent to insert the Option 82 field to DHCP
messages in an interface view. This configuration takes effect on DHCP
messages received on the specified interface.
a. Enter the interface view or sub-interface view.
interface interface-type interface-number [.subinterface-number ]
b. Enable the DHCP relay agent to insert the Option 82 field to received
DHCP messages.
dhcp option82 { insert | rebuild } enable
NOTICE
● All Option82 fields configured in the system view or in the same interface view
share a length of 1-255 bytes. If their total length exceeds 255 bytes, some
Option82 information will be lost.
● There is no limit on the number of Option 82 fields configured on the device.
However, a large number of Option 82 fields will occupy a lot of memory and
prolong the device processing time. To ensure device performance, you are
advised to configure Option 82 fields based on the service requirements and
device memory size.
dhcp option82 [ vlan vlan-id ] [ ce-vlan ce-vlan-id ] [ circuit-id | remote-id ] format { default |
common | extend | user-defined text }
----End
Context
You can configure rate limiting of DHCP messages on the device to prevent DHCP
message attacks. After rate limiting is configured, the device is allowed to process
only a specified number of DHCP messages within a certain period and discards
extra packets.
Rate limiting is configured for the DHCP messages sent by the clients, so you are
advised to configure the rate limiting function on the device close to the user side.
If the device functions as the DHCP relay and is connected to a DHCP snooping-
enabled device, you are advised to configure the rate limiting function on the
DHCP snooping-enabled device.
You can configure the rate limiting function in the system view, VLAN view, or
interface view. The configuration in the interface view takes precedence over those
in the VLAN view and global view; the configuration in the VLAN view takes
precedence over that in the system view.
Procedure
● Configure DHCP rate limiting in the system view.
a. Enter the system view.
system-view
By default, DHCP messages are sent to the DHCP stack at the rate of 100
pps. Excess packets in a specified period of time are discarded.
d. (Optional) Enable the trap function for rate limiting.
By default, the alarm threshold for checking DHCP message rates is 100.
After the trap function for rate limiting is enabled, the device discards
packets whose rate exceeds the rate limit. When the number of discarded
packets exceeds the alarm threshold, the system generates an alarm.
By default, DHCP messages are sent to the DHCP stack at the rate of 100
pps. Excess packets in a specified period of time are discarded.
● Configure DHCP rate limiting in the interface view.
a. Enter the system view.
system-view
By default, DHCP messages are sent to the DHCP stack at the rate of 100
pps. Excess packets in a specified period of time are discarded.
e. (Optional) Enable the trap function for rate limiting.
dhcp alarm dhcp-rate enable
f. (Optional) Specify the alarm threshold for checking DHCP message rates.
dhcp alarm dhcp-rate threshold threshold
By default, the alarm threshold for checking DHCP message rates is 100.
After the trap function for rate limiting is enabled, the device discards
packets whose rate exceeds the rate limit. When the number of discarded
packets exceeds the alarm threshold, the system generates an alarm.
----End
Procedure
● Run the display dhcp relay { all | interface interface-type interface-number }
command to view information about the DHCP server or DHCP server group
on the interface functioning as a DHCP relay agent.
● Run the display dhcp server group [ group-name ] command to view the
configuration of the DHCP server group.
----End
Context
Before a device can function as a DHCP client, you must enable the DHCP client
function.
After an interface is enabled with the DHCP client function, the interface can
obtain network parameters including the IP address from the DHCP server. If the
allocated IP address and IP addresses of other interfaces are on the same network
segment, the interface does not use this IP address and does not re-apply for an IP
address. To allow the interface to re-apply for an IP address, run the shutdown
and then the undo shutdown commands on the interface. Alternatively, run the
undo ip address dhcp-alloc and then the ip address dhcp-alloc command on the
interface.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
Configuring attributes allows you to specify certain parameters for the DHCP
client. You can configure the Option 60 field in either the system view or the
interface view. The configuration in the interface view has a higher priority and
overrides the configuration in the system view.
Procedure
Step 1 Enter the system view.
system-view
Step 2 Configure the DHCP client to send DHCP Discover messages that carry the Option
60 field.
dhcp client class-id class-id
Step 6 Configure the DHCP client to send DHCP Discover messages that carry the Option
60 field.
dhcp client class-id class-id
----End
Context
To enable a DHCP client to determine the lease length, configure an expected
lease on the DHCP client. If the expected lease is longer than the global lease, the
global lease takes effect.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
To enable a DHCP client to detect the status of the gateway, enable the gateway
detection function. A DHCP client enabled with the gateway detection function
sends an ARP Request packet to detect the gateway status after obtaining an IP
address. If the DHCP client receives no ARP Reply packet within the detection
period, it considers the gateway address incorrect or the gateway device faulty,
and then re-applies for an IP address.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
To allow a DHCP client to communicate with other network devices, you need to
configure a route in which the next hop address is the gateway address of the
client. If the gateway address of the client is dynamically obtained from the DHCP
server and the route is statically configured on the client, the static route must be
manually modified when the gateway address changes. After the DHCP client is
configured to dynamically obtain routing entries through DHCP, the next hop
address in the static route is automatically updated when the gateway address
changes, lowering maintenance costs.
A DHCP server can allocate routing entries to DHCP clients. On a device
functioning as the DHCP client, you can set the priorities of routing entries
allocated by the DHCP server so that the DHCP client can dynamically update its
routing table.
Procedure
Step 1 Enter the system view.
system-view
Step 2 Configure the DHCP client to obtain routing entries through DHCP.
ip route ip-address { mask | mask-length } interface-type interface-number dhcp [ preference-value ]
By default, a DHCP client does not obtain routing entries through DHCP.
Step 3 Enter the interface view or sub-interface view.
interface interface-type interface-number [.subinterface-number ]
Step 4 Set the priority of routing entries allocated by the DHCP server to DHCP clients.
dhcp client default-route preference preference-value
The default priority of routing entries allocated by the DHCP server to DHCP
clients is 60.
----End
Context
The Option 55 field in DHCP Request messages is used to set the request option
list. DHCP clients use this option to specify network configuration parameters that
need to be obtained from the DHCP server. By default, the Option 55 field carries
request options 3, 6, 15, 28, 33, 44, 121, and 184 by default. You can run the dhcp
client request option-list exclude command to set a list of default options that
are excluded from the Option 55 field or run the dhcp client request option-list
command to set a list of other options that the Option 55 field carries besides the
default options based on network requirements. The other options include option
4, 7, 17, 42, 43, 66, 67, 120, and 129.
Procedure
Step 1 Enter the system view.
system-view
Step 3 Configure a list of default request options that are excluded from the Option 55
field in DHCP Request messages.
dhcp client request option-list exclude option-code &<1-8>
By default, the Option 55 field in DHCP Request messages carries request options
3, 6, 15, 28, 33, 44, 121, and 184 by default.
Step 4 Configure a list of request options that the Option 55 field in DHCP Request
messages carries besides the default options.
dhcp client request option-list option-code &<1-9>
By default, the Option 55 field in DHCP Request messages carries request options
3, 6, 15, 28, 33, 44, 121, and 184 by default.
----End
3.5.5.7 (Optional) Configuring the DHCP Client to Deliver Static ARP Entries
Context
When a router functions as a DHCP client and an LTE modem functions as a DHCP
server, the DHCP client delivers a static ARP entry after it receives a DHCP ACK
packet from the DHCP server.
Procedure
Step 1 Run system-view
By default, an interface of a DHCP client does not deliver a static ARP entry after
it receives a DHCP ACK packet from the DHCP server.
----End
Procedure
● On an interface enabled with the DHCP client function, run the display this
command to view the configuration of the DHCP client.
● Run the display dhcp client command to view the status of the DHCP client.
----End
Context
Before a device can function as a BOOTP client, you must enable the BOOTP client
function.
After an interface is enabled with the BOOTP client function, the interface can
obtain network parameters including the IP address from the DHCP server. If the
allocated IP address and IP addresses of other interfaces are on the same network
segment, the interface does not use the allocated IP address and does not re-
apply for an IP address. To allow the interface to re-apply for an IP address, run
the shutdown and then the undo shutdown commands on the interface.
Alternatively, run the undo ip address bootp-alloc and then the ip address
bootp-alloc commands on the interface.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
Configuring attributes allows you to specify certain parameters for the BOOTP
client.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
To enable a BOOTP client to detect the status of the gateway, enable the gateway
detection function. A BOOTP client enabled with the gateway detection function
sends an ARP Request packet to detect the gateway status after obtaining an IP
address. If the BOOTP client receives no ARP Reply packet within the detection
period, it considers the gateway address incorrect or the gateway device faulty,
and then re-applies for an IP address.
Procedure
Step 1 Enter the system view.
system-view
----End
Context
To allow a BOOTP client to communicate with other network devices, you need to
configure a route in which the next hop address is the gateway address of the
client. If the gateway address of the client is dynamically obtained from the DHCP
server and the route is statically configured on the client, the static route must be
manually modified when the gateway address changes. After the BOOTP client is
configured to dynamically obtain routing entries through DHCP, the next hop
address in the static route is automatically updated when the gateway address
changes, lowering maintenance costs.
A DHCP server can allocate routing entries to BOOTP clients. On a device
functioning as the BOOTP client, you can set the priorities of routing entries
allocated by the DHCP server so that the BOOTP client can dynamically update its
routing table.
Procedure
Step 1 Enter the system view.
system-view
Step 2 Configure the BOOTP client to obtain routing entries through DHCP.
ip route ip-address { mask | mask-length } interface-type interface-number dhcp [ preference-value ]
By default, a BOOTP client does not obtain routing entries through DHCP.
Step 3 Enter the interface view or sub-interface view.
interface interface-type interface-number [.subinterface-number ]
Step 4 Set the priority of routing entries allocated by the DHCP server to BOOTP clients.
dhcp client default-route preference preference-value
The default priority of routing entries allocated by the DHCP server to BOOTP
clients is 60.
----End
Procedure
● On an interface enabled with the DHCP client function, run the display this
command to view the configuration of the DHCP client.
● Run the display dhcp client command to view the status of the DHCP client.
----End
Context
Statistics about received and sent DHCP messages provide useful information for
fault locating during routine maintenance.
Procedure
● Run the display dhcp server statistics command to check statistics about
DHCP messages sent and received on a DHCP server.
● Run the display dhcp relay statistics command to check statistics about
DHCP messages sent and received on a DHCP relay agent.
Context
Before collecting statistics about DHCP messages during routine maintenance,
clear the existing statistics.
NOTICE
DHCP statistics cannot be restored after they are cleared. Exercise caution when
performing this operation.
Procedure
● Run the reset dhcp server statistics command to clear statistics about DHCP
messages sent and received on a DHCP server.
● Run the reset dhcp relay statistics command to clear statistics about DHCP
messages sent and received on a DHCP relay agent.
● Run the reset dhcp client statistics [ interface interface-type interface-
number ] command to clear statistics about DHCP messages sent and
received on a DHCP client.
● Run the reset dhcp statistics command to clear statistics about DHCP
messages sent and received on a device.
----End
Context
To force a DHCP server to re-allocate IP addresses to clients or to set IP addresses
in an address pool to idle (idle IP addresses will be preferentially allocated), reset
an address pool.
Procedure
● Run the following commands to reset address pools on the device.
– Interface address pool:
reset ip pool interface interface-name { start-ip-address [ end-ip-
address ] | all | conflict | expired | used }
Context
When a DHCP server is migrated, address pools on the DHCP server need to be
transferred to a DHCP server on the live network. To prevent impacting clients
that have obtained IP address from the to-be-migrated DHCP server, lock the
address pools on the DHCP server. After the migration, new users apply for IP
addresses from the new address pool.
Procedure
Step 1 Run the system-view command to enter the system view.
Step 2 Run the ip pool ip-pool-name command to enter the global address pool view.
Step 3 Run the lock command to lock the address pool.
By default, address pools on a device are not locked.
----End
The PC (Client_1) of the enterprise manager needs to use the fixed IP address
10.1.1.100/24 based on service requirements.
DNS Server
10.1.1.2/24
IP Network
Eth2/0/0 Eth2/0/1
VLANIF10 VLANIF11
10.1.1.1/24 10.1.2.1/24
Router
DHCP Server
LSW_1 LSW_2
Configuration Roadmap
The configuration roadmap is as follows:
Configure the DHCP server function on the router to dynamically assign IP
addresses and the DNS server address to the terminals on the two network
segments of the enterprise. The PCs on 10.1.1.0/24 are fixed office terminals for
employees with the IP address lease of 30 days, and DHCP Client_1 is assigned
with the fixed IP address (10.1.1.100/24) in DHCP static mode. The network
segment 10.1.2.0/24 is used for employees on business trips to temporarily access
the network, with the IP address lease of 2 days.
NOTE
Configure the interface link type and VLANs on the Layer 2 switches LSW_1 and LSW_2 to
implement Layer 2 communication.
Procedure
Step 1 Enable DHCP.
<Huawei> system-view
[Huawei] sysname Router
[Router] dhcp enable
Mask : 255.255.255.0
VPN instance : --
Logging : Disable
Conflicted address recycle interval: 1 Days 0 Hours 0 Minutes
Address Statistic: Total :253 Used :1
Idle :251 Expired :0
Conflict :0 Disable :1
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
10.1.1.1 10.1.1.254 253 1 251(0) 0 1
-------------------------------------------------------------------------------
[Router] display ip pool interface vlanif11
Pool-name : Vlanif11
Pool-No :1
Lease : 2 Days 0 Hours 0 Minutes
Domain-name : huawei.com
DNS-server0 : 10.1.1.2
NBNS-server0 :-
Netbios-type :-
Position : Interface Status : Unlocked
Gateway-0 : 10.1.2.1
Network : 10.1.2.0
Mask : 255.255.255.0
VPN instance : --
Logging : Disable
Conflicted address recycle interval: 1 Days 0 Hours 0 Minutes
Address Statistic: Total :253 Used :1
Idle :251 Expired :0
Conflict :0 Disable :1
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
10.1.2.1 10.1.2.254 253 1 252(0) 0 0
-------------------------------------------------------------------------------
----End
Configuration Files
Router configuration file
#
sysname Router
#
vlan batch 10 to 11
#
dhcp enable
#
interface Vlanif10
ip address 10.1.1.1 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 10.1.1.2
dhcp server static-bind ip-address 10.1.1.100 mac-address 286e-d488-b684
dhcp server lease day 30 hour 0 minute 0
dhcp server dns-list 10.1.1.2
dhcp server domain-name huawei.com
#
interface Vlanif11
ip address 10.1.2.1 255.255.255.0
dhcp select interface
dhcp server lease day 2 hour 0 minute 0
dhcp server dns-list 10.1.1.2
dhcp server domain-name huawei.com
#
interface Ethernet2/0/0
port link-type access
port default vlan 10
#
interface Ethernet2/0/1
port link-type access
port default vlan 11
#
return
Networking Requirements
As shown in Figure 3-13, the router functions as the enterprise egress gateway.
The IP phone and PCs are devices in an office area. To uniformly manage devices
and reduce manual configuration costs, the administrator needs to configure hosts
to dynamically obtain IP addresses through DHCP. The PCs are the fixed terminal
in the duty room. It should always be online and use domain names to access
network devices. Besides obtaining an IP address dynamically, the PCs require an
unlimited IP address lease and obtain information about the DNS server. The IP
phone uses a fixed IP address 10.1.1.4/24 and its MAC address is dcd2-fc96-e4c0.
Besides obtaining an IP address, the IP phone needs to dynamically obtain the
startup configuration file. The startup configuration file named configuration.ini
is saved on the FTP file server. There are reachable routes between the IP phone
and the FTP file server. The gateway address of the PCs and IP phone is
10.1.1.1/24.
Switch GE1/0/0
10.1.1.1/24
Router
IP Phone DHCP Server
10.1.1.4/24
PC PC PC FTP Server
10.1.1.3/24
Configuration Roadmap
1. Create a DHCP Option template on the router. In the DHCP Option template
view, configure the startup configuration file for the static client IP phone, and
configure an IP address for the network server that provides the startup
configuration file.
2. Create a global address pool on the router. In the global address pool view,
configure the IP address lease and information about the DNS server for the
dynamic client PCs. Bind an IP address to the MAC address of the static client
IP phone and bind a DHCP Option template. In this way, the DHCP server can
allocate different network parameters to dynamic and static clients.
Procedure
Step 1 Configure an IP address for the interface.
<Huawei> system-view
[Huawei] sysname Router
[Router] interface gigabitethernet 1/0/0
[Router-GigabitEthernet1/0/0] ip address 10.1.1.1 24
[Router-GigabitEthernet1/0/0] quit
Step 3 Create a DHCP Option template. In the DHCP Option template view, configure the
startup configuration file for the static client IP phone, and configure an IP address
for the network server that provides the startup configuration file.
[Router] dhcp option template template1
[Router-dhcp-option-template-template1] gateway-list 10.1.1.1
[Router-dhcp-option-template-template1] bootfile configuration.ini
[Router-dhcp-option-template-template1] next-server 10.1.1.3
[Router-dhcp-option-template-template1] quit
Step 4 Create an IP address pool. In the IP address pool view, configure the gateway
address, IP address lease, and IP address of the DNS server for the PCs. Allocate a
fixed IP address to the IP phone and configure the startup configuration file.
[Router] ip pool pool1
[Router-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.0
[Router-ip-pool-pool1] dns-list 10.1.1.2
[Router-ip-pool-pool1] gateway-list 10.1.1.1
[Router-ip-pool-pool1] excluded-ip-address 10.1.1.2 10.1.1.3
[Router-ip-pool-pool1] lease unlimited
[Router-ip-pool-pool1] static-bind ip-address 10.1.1.4 mac-address dcd2-fc96-e4c0 option-template
template1
[Router-ip-pool-pool1] quit
DNS-server0 : 10.1.1.2
NBNS-server0 :-
Netbios-type :-
Position : Local Status : Unlocked
Gateway-0 : 10.1.1.1
Network : 10.1.1.0
Mask : 255.255.255.0
VPN instance : --
Logging : Disable
Conflicted address recycle interval: 1 Days 0 Hours 0 Minutes
Address Statistic: Total :253 Used :4
Idle :247 Expired :0
Conflict :0 Disable :2
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
192.168.1.1 192.168.1.254 253 4 247(0) 0 2
-------------------------------------------------------------------------------
# Run the display dhcp option template name template1 command on the
router to check the DHCP Option template configuration.
[Router] display dhcp option template name template1
-------------------------------------------------------------------------------
Template-Name : template1
Template-No :0
Next-server : 10.1.1.3
Domain-name :-
DNS-server0 :-
NBNS-server0 :-
Netbios-type :-
Gateway-0 : 10.1.1.1
Bootfile : configuration.ini
----End
Configuration Files
Router configuration file
#
sysname Router
#
dhcp enable
#
dhcp option template template1
gateway-list 10.1.1.1
next-server 10.1.1.3
bootfile configuration.ini
#
ip pool pool1
gateway-list 10.1.1.1
network 10.1.1.0 mask 255.255.255.0
excluded-ip-address 10.1.1.2 10.1.1.3
static-bind ip-address 10.1.1.4 mac-address dcd2-fc96-e4c0 option-template
template1
lease unlimited
dns-list 10.1.1.2
#
interface GigabitEthernet1/0/0
ip address 10.1.1.1 255.255.255.0
dhcp select global
#
return
Eth0/0/1 Eth0/0/3
Eth0/0/2 Eth0/0/4
VLAN2 VLAN3
VLAN4
VLANIF4:10.1.1.12/24
DeptA:VLAN 2 DeptB:VLAN 3
Configuration Roadmap
1. Configure sub-VLANs on the Router to implement Layer 2 isolation between
users in different sub-VLANs. The sub-VLANs are on the same network
segment, which reduces the amount of required IP address resources.
2. Configure proxy ARP on the VLANIF interface of the super-VLAN to implement
Layer 3 communication among sub-VLANs.
3. Configure a DHCP server in the super-VLAN to dynamically allocate IP
addresses to terminals in departments A and B.
Procedure
Step 1 Create VLAN 2, and add Eth0/0/1 and Eth0/0/2 to VLAN 2. Create VLAN 3, and
add Eth0/0/3 and Eth0/0/4 to VLAN 3.
<Huawei> system-view
[Huawei] sysname Router
[Router] vlan batch 2 to 4
[Router] interface Ethernet 0/0/1
[Router-Ethernet0/0/1] port link-type access
[Router-Ethernet0/0/1] port default vlan 2
[Router-Ethernet0/0/1] quit
Step 4 Configure a DHCP server based on the interface address pool on VLANIF 4 to
dynamically allocate IP addresses to terminals in sub-VLANs.
[Router] dhcp enable
[Router] interface vlanif 4
[Router-Vlanif4] dhcp select interface
[Router-Vlanif4] quit
# After the configuration is complete, run the display ip pool interface vlanif4
command on the Router to view IP address allocation in the address pool. The
Used field displays the number of used IP addresses in an address pool.
[Router] display ip pool interface vlanif4
Pool-name : Vlanif4
Pool-No :0
Lease : 1 Days 0 Hours 0 Minutes
Domain-name : huawei.com
DNS-server0 : 10.1.1.2
NBNS-server0 :-
Netbios-type :-
Position : Interface Status : Unlocked
Gateway-0 : 10.1.1.12
Network : 10.1.2.0
Mask : 255.255.255.0
VPN instance : --
Logging : Disable
Conflicted address recycle interval: --
Address Statistic: Total :253 Used :4
Idle :249 Expired :0
Conflict :0 Disable :0
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
----End
Configuration Files
Router configuration file
#
sysname Router
#
vlan batch 2 to 4
#
dhcp enable
#
vlan 4
aggregate-vlan
access-vlan 2 to 3
#
interface Vlanif4
ip address 10.1.1.12 255.255.255.0
arp-proxy inter-sub-vlan-proxy enable
dhcp select interface
#
interface Ethernet0/0/1
port link-type access
port default vlan 2
#
interface Ethernet0/0/2
port link-type access
port default vlan 2
#
interface Ethernet0/0/3
port link-type access
port default vlan 3
#
interface Ethernet0/0/4
port link-type access
port default vlan 3
#
return
RouterB
DHCP Server Eth2/0/0
VLANIF200 10.10.20.2/24
Eth2/0/0
VLANIF200 10.10.20.1/24
RouterA
DHCP Relay
Eth2/0/1
VLANIF100 10.20.20.1/24
LSW
Configuration Roadmap
The configuration roadmap is as follows:
1. Configure the DHCP relay function on the aggregation device RouterA (user
gateway) so that the device functions as the DHCP relay to forward the DHCP
messages between the terminals and DHCP server.
2. On the core device RouterB, configure the DHCP server based on the global
address pool so that the DHCP server allocates the IP addresses from the
global address pool to the terminals.
NOTE
Procedure
Step 1 Configure the DHCP relay function on RouterA.
# Add interfaces to VLANs.
<Huawei> system-view
[Huawei] sysname RouterA
Step 3 Configure the DHCP server function based on the global IP address pool on
RouterB.
# Enable DHCP.
<Huawei> system-view
[Huawei] sysname RouterB
[RouterB] dhcp enable
# Create an address pool and set the attributes of the address pool.
[RouterB] ip pool pool1
[RouterB-ip-pool-pool1] network 10.20.20.0 mask 24
[RouterB-ip-pool-pool1] gateway-list 10.20.20.1
[RouterB-ip-pool-pool1] option121 ip-address 10.10.20.0 24 10.20.20.1
[RouterB-ip-pool-pool1] quit
# Run the display dhcp relay interface vlanif 100 command on RouterA to view
the DHCP relay configuration.
[RouterA] display dhcp relay interface vlanif 100
DHCP relay agent running information of interface Vlanif100 :
Server IP address [00] : 10.10.20.2
Gateway address in use : 10.20.20.1
# Run the display ip pool name pool1 command on RouterB to view the
allocation of the address pool. The Used field indicates the number of allocated IP
addresses.
[RouterB] display ip pool name pool1
Pool-name : pool1
Pool-No :0
Lease : 1 Days 0 Hours 0 Minutes
Domain-name :-
Option-code : 121
Option-subcode : --
Option-type : hex
Option-value : 180A0A140A141401
DNS-server0 :-
NBNS-server0 :-
Netbios-type :-
Position : Local Status : Unlocked
Gateway-0 : 10.20.20.1
Network : 10.20.20.0
Mask : 255.255.255.0
VPN instance : --
Logging : Disable
Conflicted address recycle interval: -
Address Statistic: Total :253 Used :1
Idle :252 Expired :0
Conflict :0 Disable :0
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
10.20.20.1 10.20.20.254 253 1 252(0) 0 0
-------------------------------------------------------------------------------
----End
Configuration Files
● RouterA configuration file
#
sysname RouterA
#
vlan batch 100 200
#
dhcp enable
#
interface Vlanif100
ip address 10.20.20.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.10.20.2
#
interface Vlanif200
ip address 10.10.20.1 255.255.255.0
#
interface Ethernet2/0/0
port link-type trunk
port trunk allow-pass vlan 200
#
interface Ethernet2/0/1
port link-type access
port default vlan 100
#
ip route-static 0.0.0.0 0.0.0.0 10.10.20.2
#
return
#
sysname RouterB
#
vlan batch 200
#
dhcp enable
#
ip pool pool1
gateway-list 10.20.20.1
network 10.20.20.0 mask 255.255.255.0
option121 ip-address 10.10.20.0 24 10.20.20.1
#
interface Vlanif200
ip address 10.10.20.2 255.255.255.0
dhcp select global
#
interface Ethernet2/0/0
port link-type trunk
port trunk allow-pass vlan 200
#
ip route-static 0.0.0.0 0.0.0.0 10.10.20.1
#
return
Figure 3-16 Networking diagram for configuring a device as the DHCP relay agent
10.1.1.0/24
DHCP Client
Branch
1:vpna
GE0/0/1
CE_1
DHCP Relay Agent Loopback0
GE0/0/2 10.20.20.9/32 MCE
GE2/0/0 DHCP Server
Loopback0 GE3/0/0 GE2/0/0 GE1/0/0
10.10.10.9/32 GE0/0/1
GE1/0/0 PE_1 PE_2
GE0/0/2
CE_2
DHCP Relay Agent GE0/0/1
Branch
2:vpnb
DHCP Client
10.1.1.0/24
Configuration Roadmap
1. Configure OSPF between PE_1 and PE_2 to implement interworking between
them and configure MP-IBGP to exchange VPN routing information.
2. Configure basic MPLS capabilities and MPLS LDP on PE_1 and PE_2 to set up
LDP LSPs.
3. Create VPN instances vpna and vpnb on the MCE, PE_1, and PE_2 to isolate
services.
4. Set up EBGP peer relationships between PE_1 and its connected CEs, and
import BGP routes to the VPN routing table of PE1.
5. Configure the MCE as the DHCP server to allocate IP addresses from the
global address pool to terminals in branch 1 and branch 2.
6. Configure the DHCP relay function on CE_1 and CE_2 to forward DHCP
messages between the DHCP server and terminals so that the terminals can
apply to the DHCP server for IP addresses.
7. Configure the terminals to dynamically obtain IP addresses from the DHCP
server.
Procedure
Step 1 Configure IP addresses for interfaces.
# Configure PE_1.
<Huawei> system-view
[Huawei] sysname PE_1
[PE_1] interface loopback 0
[PE_1-LoopBack0] ip address 10.10.10.9 32
[PE_1-LoopBack0] quit
[PE_1] interface gigabitethernet 3/0/0
[PE_1-GigabitEthernet3/0/0] ip address 10.1.3.1 24
[PE_1-GigabitEthernet3/0/0] quit
# Configure PE_2.
<Huawei> system-view
[Huawei] sysname PE_2
[PE_2] interface loopback 0
[PE_2-LoopBack0] ip address 10.20.20.9 32
[PE_2-LoopBack0] quit
[PE_2] interface gigabitethernet 2/0/0
[PE_2-GigabitEthernet2/0/0] ip address 10.1.3.2 24
[PE_2-GigabitEthernet2/0/0] quit
# Configure PE_1.
[PE_1] ospf 1
[PE_1-ospf-1] area 0
[PE_1-ospf-1-area-0.0.0.0] network 10.10.10.9 0.0.0.0
[PE_1-ospf-1-area-0.0.0.0] network 10.1.3.0 0.0.0.255
[PE_1-ospf-1-area-0.0.0.0] quit
[PE_1-ospf-1] quit
# Configure PE_2.
[PE_2] ospf 1
[PE_2-ospf-1] area 0
[PE_2-ospf-1-area-0.0.0.0] network 10.20.20.9 0.0.0.0
[PE_2-ospf-1-area-0.0.0.0] network 10.1.3.0 0.0.0.255
[PE_2-ospf-1-area-0.0.0.0] quit
[PE_2-ospf-1] quit
# After the configuration is complete, PE_1 and PE_2 set up the OSPF neighbor
relationship. Run the display ip routing-table command on PE_1 and PE_2 to
view the routes to each other.
Step 3 Configure basic MPLS capabilities and MPLS LDP on PE_1 and PE_2 to set up LDP
LSPs.
# Configure PE_1.
[PE_1] mpls lsr-id 10.10.10.9
[PE_1] mpls
[PE_1-mpls] quit
[PE_1] mpls ldp
[PE_1-mpls-ldp] quit
[PE_1] interface gigabitethernet 3/0/0
[PE_1-GigabitEthernet3/0/0] mpls
[PE_1-GigabitEthernet3/0/0] mpls ldp
[PE_1-GigabitEthernet3/0/0] quit
# Configure PE_2.
[PE_2] mpls lsr-id 10.20.20.9
[PE_2] mpls
[PE_2-mpls] quit
[PE_2] mpls ldp
[PE_2-mpls-ldp] quit
[PE_2] interface gigabitethernet 2/0/0
[PE_2-GigabitEthernet2/0/0] mpls
[PE_2-GigabitEthernet2/0/0] mpls ldp
[PE_2-GigabitEthernet2/0/0] quit
# After the configuration is complete, PE_1 and PE_2 set up LDP sessions. Run the
display mpls ldp session command on PE_1 and PE_2. The command output
shows that the Status field is Operational. Run the display mpls ldp lsp
command. Information about the established LDP LSPs is displayed.
Step 4 Configure VPN instances on the MCE, PE_1, and PE_2.
# Configure PE_1.
[PE_1] ip vpn-instance vpna
[PE_1-vpn-instance-vpna] ipv4-family
[PE_1-vpn-instance-vpna-af-ipv4] route-distinguisher 100:1
[PE_1-vpn-instance-vpna-af-ipv4] vpn-target 111:1 both
[PE_1-vpn-instance-vpna-af-ipv4] quit
[PE_1-vpn-instance-vpna] quit
[PE_1] ip vpn-instance vpnb
[PE_1-vpn-instance-vpnb] ipv4-family
[PE_1-vpn-instance-vpnb-af-ipv4] route-distinguisher 100:2
[PE_1-vpn-instance-vpnb-af-ipv4] vpn-target 222:2 both
[PE_1-vpn-instance-vpnb-af-ipv4] quit
[PE_1-vpn-instance-vpnb] quit
[PE_1] interface gigabitethernet 2/0/0
[PE_1-GigabitEthernet2/0/0] ip binding vpn-instance vpna
[PE_1-GigabitEthernet2/0/0] ip address 10.1.2.2 24
[PE_1-GigabitEthernet2/0/0] quit
[PE_1] interface gigabitethernet 1/0/0
[PE_1-GigabitEthernet1/0/0] ip binding vpn-instance vpnb
[PE_1-GigabitEthernet1/0/0] ip address 10.1.2.2 24
[PE_1-GigabitEthernet1/0/0] quit
# Configure PE_2.
[PE_2] ip vpn-instance vpna
[PE_2-vpn-instance-vpna] ipv4-family
[PE_2-vpn-instance-vpna-af-ipv4] route-distinguisher 200:1
[PE_2-vpn-instance-vpna-af-ipv4] vpn-target 111:1 both
[PE_2-vpn-instance-vpna-af-ipv4] quit
[PE_2-vpn-instance-vpna] quit
[PE_2] ip vpn-instance vpnb
[PE_2-vpn-instance-vpnb] ipv4-family
[PE_2-vpn-instance-vpnb-af-ipv4] route-distinguisher 200:2
[PE_2-vpn-instance-vpnb-af-ipv4] vpn-target 222:2 both
[PE_2-vpn-instance-vpnb-af-ipv4] quit
[PE_2-vpn-instance-vpnb] quit
[PE_2] interface gigabitethernet 1/0/0.1
[PE_2-GigabitEthernet1/0/0.1] dot1q termination vid 10
[PE_2-GigabitEthernet1/0/0.1] ip binding vpn-instance vpna
[PE_2-GigabitEthernet1/0/0.1] ip address 10.1.4.2 24
[PE_2-GigabitEthernet1/0/0.1] arp broadcast enable
[PE_2-GigabitEthernet1/0/0.1] quit
[PE_2] interface gigabitethernet 1/0/0.2
[PE_2-GigabitEthernet1/0/0.2] dot1q termination vid 20
[PE_2-GigabitEthernet1/0/0.2] ip binding vpn-instance vpnb
[PE_2-GigabitEthernet1/0/0.2] ip address 10.1.5.2 24
[PE_2-GigabitEthernet1/0/0.2] arp broadcast enable
[PE_2-GigabitEthernet1/0/0.2] quit
Step 5 Set up the MP-IBGP peer relationship between PE_1 and PE_2.
# Configure PE_1.
[PE_1] bgp 100
[PE_1-bgp] peer 10.20.20.9 as-number 100
[PE_1-bgp] peer 10.20.20.9 connect-interface loopback 0
[PE_1-bgp] ipv4-family vpnv4
[PE_1-bgp-af-vpnv4] peer 10.20.20.9 enable
[PE_1-bgp-af-vpnv4] quit
[PE_1-bgp] ipv4-family vpn-instance vpna
[PE_1-bgp-vpna] import-route direct
[PE_1-bgp-vpna] quit
[PE_1-bgp] ipv4-family vpn-instance vpnb
[PE_1-bgp-vpnb] import-route direct
[PE_1-bgp-vpnb] quit
[PE_1-bgp] quit
# Configure PE_2.
# After the configuration is complete, run the display bgp peer command on
PE_1 and PE_2. The command output shows that the MP-IBGP peer relationship
has been set up between PEs and the relationship is in Established state.
Step 6 Configure EBGP peer relationships between CE_1 and PE_1 and between CE_2 and
PE_1.
# Configure the egress gateway CE1 of branch 1.
[CE_1] bgp 65410
[CE_1-bgp] peer 10.1.2.2 as-number 100
[CE_1-bgp] ipv4-family unicast
[CE_1-bgp-af-ipv4] undo synchronization
[CE_1-bgp-af-ipv4] import-route direct
[CE_1-bgp-af-ipv4] quit
[CE_1-bgp] quit
# Configure PE_1.
[PE_1] bgp 100
[PE_1-bgp] ipv4-family vpn-instance vpna
[PE_1-bgp-vpna] peer 10.1.2.1 as-number 65410
[PE_1-bgp-vpna] import-route direct
[PE_1-bgp-vpna] quit
[PE_1-bgp] ipv4-family vpn-instance vpnb
[PE_1-bgp-vpnb] peer 10.1.2.1 as-number 65411
[PE_1-bgp-vpnb] import-route direct
[PE_1-bgp-vpnb] quit
[PE_1-bgp] quit
NOTE
To configure OSPF multi-instance between the MCE and PE2, perform the following tasks on
PE_2:
● In the OSPF view, import BGP routes and advertise VPN routes of PE_1 to the MCE.
● In the BGP view, import routes of the OSPF processes and advertise the VPN routes of the
MCE to PE_1.
[PE_2] ospf 100 vpn-instance vpna
[PE_2-ospf-100] import-route bgp
[PE_2-ospf-100] area 0
[PE_2-ospf-100-area-0.0.0.0] network 10.1.4.0 0.0.0.255
[PE_2-ospf-100-area-0.0.0.0] quit
[PE_2-ospf-100] quit
[PE_2] ospf 200 vpn-instance vpnb
[PE_2-ospf-200] import-route bgp
[PE_2-ospf-200] area 0
[PE_2-ospf-200-area-0.0.0.0] network 10.1.5.0 0.0.0.255
[PE_2-ospf-200-area-0.0.0.0] quit
[PE_2-ospf-200] quit
[PE_2] bgp 100
[PE_2-bgp] ipv4-family vpn-instance vpna
[PE_2-bgp-vpna] import-route ospf 100
[PE_2-bgp-vpna] quit
[PE_2-bgp] ipv4-family vpn-instance vpnb
[PE_2-bgp-vpnb] import-route ospf 200
[PE_2-bgp-vpnb] quit
[PE_2-bgp] quit
NOTE
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
10.1.1.1 10.1.1.254 253 0 252(0) 0 0
-------------------------------------------------------------------------------
----End
Configuration Files
● PE_1 configuration file
#
sysname PE_1
#
ip vpn-instance vpna
ipv4-family
route-distinguisher 100:1
vpn-target 111:1 export-extcommunity
vpn-target 111:1 import-extcommunity
#
ip vpn-instance vpnb
ipv4-family
route-distinguisher 100:2
vpn-target 222:2 export-extcommunity
vpn-target 222:2 import-extcommunity
#
mpls lsr-id 10.10.10.9
mpls
#
mpls ldp
#
interface GigabitEthernet3/0/0
ip address 10.1.3.1 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet1/0/0
ip binding vpn-instance vpnb
ip address 10.1.2.2 255.255.255.0
#
interface GigabitEthernet2/0/0
ip binding vpn-instance vpna
ip address 10.1.2.2 255.255.255.0
#
interface LoopBack0
ip address 10.10.10.9 255.255.255.255
#
bgp 100
peer 10.20.20.9 as-number 100
peer 10.20.20.9 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 10.20.20.9 enable
#
ipv4-family vpnv4
policy vpn-target
peer 10.20.20.9 enable
#
ipv4-family vpn-instance vpna
import-route direct
peer 10.1.2.1 as-number 65410
#
ipv4-family vpn-instance vpnb
import-route direct
peer 10.1.2.1 as-number 65411
#
ospf 1
area 0.0.0.0
network 10.1.3.0 0.0.0.255
network 10.10.10.9 0.0.0.0
#
return
● PE_2 configuration file
#
sysname PE_2
#
ip vpn-instance vpna
ipv4-family
route-distinguisher 200:1
vpn-target 111:1 export-extcommunity
vpn-target 111:1 import-extcommunity
#
ip vpn-instance vpnb
ipv4-family
route-distinguisher 200:2
vpn-target 222:2 export-extcommunity
vpn-target 222:2 import-extcommunity
#
#
interface GigabitEthernet0/0/2
ip address 10.1.2.1 255.255.255.0
#
bgp 65410
peer 10.1.2.2 as-number 100
#
ipv4-family unicast
undo synchronization
import-route direct
peer 10.1.2.2 enable
#
return
● CE_2 configuration file
#
sysname CE_2
#
dhcp enable
#
interface GigabitEthernet0/0/1
ip address 10.1.1.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 10.1.5.1
#
interface GigabitEthernet0/0/2
ip address 10.1.2.1 255.255.255.0
#
bgp 65411
peer 10.1.2.2 as-number 100
#
ipv4-family unicast
undo synchronization
import-route direct
peer 10.1.2.2 enable
#
return
● MCE configuration file
#
sysname MCE
#
dhcp enable
#
ip vpn-instance vpna
ipv4-family
route-distinguisher 200:1
vpn-target 111:1 export-extcommunity
vpn-target 111:1 import-extcommunity
#
ip vpn-instance vpnb
ipv4-family
route-distinguisher 200:2
vpn-target 222:2 export-extcommunity
vpn-target 222:2 import-extcommunity
#
ip pool pool1
vpn-instance vpna
gateway-list 10.1.1.1
network 10.1.1.0 mask 255.255.255.0
#
ip pool pool2
vpn-instance vpnb
gateway-list 10.1.1.1
network 10.1.1.0 mask 255.255.255.0
#
interface GigabitEthernet0/0/1.1
dot1q termination vid 10
ip binding vpn-instance vpna
ip address 10.1.4.1 255.255.255.0
GE0/0/2 GE0/0/1
192.168.1.1/24 DHCP Client
DHCP Server
PC
Configuration Roadmap
1. Enable the DHCP client function on GE0/0/1 so that the router can
dynamically obtain IP addresses, DNS and NetBIOS server configurations from
the DHCP server.
2. Enable the DHCP server function on GE0/0/2 to use the interface address pool
for address allocation. Enable the function of automatically obtaining DNS
Before the configuration, ensure that the devices on the network can communicate with each
other.
In this example, the carrier's DHCP server will deliver the configurations to the router. The
configurations include the DNS server address 10.1.2.1, domain name suffix huawei, and
NetBIOS server address 10.1.3.1. Configure the carrier's DHCP server before configuring the
router.
Procedure
Step 1 Configure the DHCP client function on GE0/0/1.
<Huawei> system-view
[Huawei] sysname Router
[Router] interface gigabitethernet 0/0/1
[Router-GigabitEthernet0/0/1] ip address dhcp-alloc
[Router-GigabitEthernet0/0/1] quit
Step 2 Enable the DHCP server function on GE0/0/2 to use the interface address pool for
address allocation, and enable the function of automatically obtaining DNS and
NetBIOS server configurations.
1. Enable DHCP.
[Router] dhcp enable
2. Configure GE0/0/2 to work in interface address pool mode.
[Router] interface gigabitethernet 0/0/2
[Router-GigabitEthernet0/0/2] ip address 192.168.1.1 24
[Router-GigabitEthernet0/0/2] dhcp select interface
3. Enable the function of automatically obtaining DNS and NetBIOS server
configurations on GE0/0/2.
[Router-GigabitEthernet0/0/2] dhcp server import all
[Router-GigabitEthernet0/0/2] quit
# Run the display ip pool import all command to view the DNS and NetBIOS
server configurations dynamically obtained by the router.
[Router] display ip pool import all
-----------------------------------------------------------------------------
----End
Configuration Files
Router configuration file
#
sysname Router
#
dhcp enable
#
interface GigabitEthernet0/0/1
ip address dhcp-alloc
#
interface GigabitEthernet0/0/2
ip address 192.168.1.1 255.255.255.0
dhcp select interface
dhcp server import all
#
return
Networking Requirements
As shown in Figure 3-18, RouterA functions as the BOOTP client to dynamically
obtain information including the IP address, DNS server address, and gateway
address from the DHCP server (RouterB).
GE0/0/1
RouterA
BOOTP Client
Configuration Roadmap
The configuration roadmap is as follows:
Procedure
Step 1 Configure the BOOTP client function on RouterA.
Step 2 Create a global address pool on RouterB and set corresponding attributes.
# Enable DHCP.
<Huawei> system-view
[Huawei] sysname RouterB
[RouterB] dhcp enable
[RouterB] dhcp server bootp
[RouterB] dhcp server bootp automatic
# On interface GE0/0/1, run the display this command to view the BOOTP client
configuration.
[RouterA] interface gigabitethernet 0/0/1
[RouterA-GigabitEthernet0/0/1] display this
#
interface GigabitEthernet0/0/1
ip address bootp-alloc
#
return
[RouterA-GigabitEthernet0/0/1] quit
# After GE0/0/1 obtains an IP address, run the display dhcp client command on
RouterA to view the status of the BOOTP client on GE0/0/1.
[RouterA] display dhcp client
BOOTP client lease information on interface GigabitEthernet0/0/1 :
Current machine state : Bound
Internet address assigned via : BOOTP
Physical address : 5489-98f7-310f
IP address : 192.168.1.254
Subnet mask : 255.255.255.0
Gateway ip address : 192.168.1.1
Lease obtained at : 2015-02-10 16:03:43
DNS : 192.168.2.2
# Run the display ip pool name pool1 command on RouterB to view the address
pool configuration. The Used field displays the number of used IP addresses in an
address pool.
[RouterB] display ip pool name pool1
Pool-name : pool1
Pool-No :5
Lease : 1 Days 0 Hours 0 Minutes
Domain-name :-
DNS-server0 : 192.168.2.2
NBNS-server0 :-
Netbios-type :-
Position : Local Status : Unlocked
Gateway-0 : 192.168.1.1
Network : 192.168.1.0
Mask : 255.255.255.0
VPN instance : --
Logging : Disable
Conflicted address recycle interval: --
Address Statistic: Total :253 Used :1
Idle :252 Expired :0
Conflict :0 Disable :0
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
192.168.1.1 192.168.1.254 253 1 252(0) 0 0
-------------------------------------------------------------------------------
----End
Configuration Files
● RouterA configuration file
#
sysname RouterA
#
interface GigabitEthernet0/0/1
ip address bootp-alloc
#
return
Then, on the client, release the IP address and apply for a new
one.
● Change the host's manually configured IP address.
NOTE
IP address conflict detection can be configured on the DHCP server to
prevent conflicts. For details, see 3.5.3.4 (Optional) Configuring IP
Address Conflict Detection.
Verification Check whether DHCP is enabled. Enter the user view and run:
display current-configuration | include dhcp enable
Then, on the client, release the IP address and apply for a new
one.
● Change the host's manually configured IP address.
NOTE
IP address conflict detection can be configured on the DHCP server to
prevent conflicts. For details, see 3.5.3.4 (Optional) Configuring IP
Address Conflict Detection.
Verification Check statistics about packets sent to the DHCP server's CPU and
determine the MAC address at the source of the attack. Run:
display cpu-defend statistics
Solution Add the MAC address at the source of the attack to the blacklist.
For details, see "Configuring CPU Attack Defense" in Huawei AR
Series V200R010 Configuration Guide - Security - Local Attack
Defense Configuration.
The DHCP client does The DHCP client can Run the gateway-list ip-
not obtain the egress obtain an IP address address &<1-8>
gateway address. through the DHCP relay command in the global
agent, but cannot access address pool view of the
the Internet or ping the DHCP server to configure
DHCP server. The the egress gateway
phenomenon indicates address for DHCP clients.
that the DHCP relay
agent and DHCP server
work properly. The
possible cause is that the
DHCP client does not
obtain the egress
gateway address. Run
the display ip pool
command to check
whether the egress
gateway address for
DHCP clients is
configured in the address
pool. If the Gateway-0
field in the command
output displays -, the
egress gateway address
for DHCP clients is not
configured in the address
pool.
When receiving DHCP packets from a DHCP client or DHCP server, a DHCP
snooping-enabled Fit AP records DHCP/6/SNP_RCV_MSG logs. You need to
configure the Fit AP to send logs to the log host before viewing the DHCP/6/
SNP_RCV_MSG logs on the log host. Ensure that the Fit AP and log host are
routable to each other.
3.8.3 When Both the DHCP Server and Relay Functions Are
Enabled on an Interface, Which Function Is Processed
Preferentially?
When both the DHCP server function and the DHCP relay function are enabled on
an interface, the DHCP server function is processed preferentially. The local DHCP
server that is on the same network segment as the interface's IP address is used
preferentially to allocate IP addresses. If the local DHCP server cannot allocate IP
addresses, a remote DHCP server allocates IP addresses through the DHCP relay
agent.
You can run the display ip pool name ip-pool-name ip-address command to
check the IP address status in a global address pool, and run the display ip pool
interface interface-name ip-address command to check the IP address status in
an interface address pool.
NOTE
When the interface address pool is queried, no space can exist between the interface type and
interface ID, for example, vlanif10 (with no space between vlanif and 10).
When configuring static binding for IP addresses in different status, note the
following points:
1. An IP address in idle or expired status can be statically bound.
2. To statically bind an IP address in conflict status, run the reset ip pool
command in the user view to reclaim the IP address first.
3. For an IP address in used status:
– In versions earlier than V200R010C00, run the reset ip pool command in
the user view to reclaim the IP address before static binding.
– In V200R010C00 and later versions, static binding can be directly
configured for IP addresses in used status. However, during static binding
configuration, you must ensure that the MAC address to be bound is the
same as that of the user who actually uses the IP address.
4. Before configuring static binding for IP addresses in Disable status, namely, IP
addresses that have been excluded using the excluded-ip-address command
in the global address pool or the dhcp server excluded-ip-address command
in the interface view, you need to cancel IP address exclusion using the undo
excluded-ip-address command in the global address pool or the undo dhcp
server excluded-ip-address command in the interface view.
5. If a statically bound user is online when static binding is canceled, namely, the
IP address is in Static-bind used status:
– In versions earlier than V200R010C00, run the reset ip pool command in
the user view to reclaim the IP address before canceling the static
binding. After this command is run, the IP address is in idle status.
– In V200R010C00 and later versions, you can directly cancel the static
binding and the IP address becomes the used status.
NOTE
If the client cannot detect that the reset ip pool command has been run on the DHCP server,
the client continues using the IP address.
3.8.5 How Can I Import the DNS Server IP Address That the
Device Obtains from the Upstream Network into an Address
Pool?
The device can obtain the DNS server IP address from the remote DHCP server or
PPPoE server after the DHCP client or PPPoE client function is enabled on the
interface connecting the device and the upstream carrier network. In addition, the
device, functioning as the user gateway and DHCP server on the LAN, needs to
allocate IP addresses to users on the LAN. Users on the LAN must be capable of
using the DNS server to parse domain names. In V200R008C00 and later versions,
you can perform the following configurations to import the DNS server IP address
that the device obtains from the upstream carrier network into an address pool
and allocate the IP address to users on the LAN.
● For an interface address pool, run the dhcp server dns-list unnumbered
interface interface-type interface-number command in the corresponding
interface view.
● For a global address pool, run the dns-list unnumbered interface interface-
type interface-number command in the global address pool view.
NOTE
The interface specified by interface interface-type interface-number connects the device and
the upstream carrier network and the DHCP client or PPPoE client function is configured on the
interface. Specifically, the type of the interface on which the PPPoE client function is configured
must be dialer.