Chapter 1 DHCP Overview
When configuring ARP,
go to these sections for information you are interested in:
l
Introduction to DHCP
l
DHCP Address Allocation
l
DHCP Message Format
l
DHCP Options
l
Protocols and Standards
The fast expansion and growing complexity of
networks result in scarce IP addresses assignable to hosts. Meanwhile, with the
wide application of wireless networks, the frequent movement of laptops across
networks requires that the IP addresses be changed accordingly. Therefore, related
configurations on hosts become more complex. Dynamic Host Configuration
Protocol (DHCP) was introduced to solve these problems.
DHCP is built on a client-server model, in
which the client sends a configuration request and then the server returns a
reply to send configuration parameters such as an IP address to the client.
A typical DHCP application, as shown in Figure 1-1, includes
a DHCP server and multiple clients (PCs and laptops).

Figure 1-1 A typical DHCP application
When residing in a
different subnet from the DHCP server, the DHCP client can get the IP address
and other configuration parameters from the server via a DHCP relay agent. For
information about the DHCP relay agent, refer to Introduction to DHCP Relay Agent.
DHCP supports three mechanisms for IP
address allocation.
l
Manual allocation: The network administrator assigns
an IP address to a client like a WWW server, and DHCP conveys the assigned
address to the client.
l
Automatic allocation: DHCP assigns a permanent
IP address to a client.
l
Dynamic allocation: DHCP assigns an IP address
to a client for a limited period of time, which is called a lease. Most clients
obtain their addresses in this way.
1.2.2 Dynamic IP Address Allocation Process

Figure
1-2 Dynamic IP address allocation process
As shown in the figure above, a DHCP client
obtains an IP address from a DHCP server via four steps:
1)
The client broadcasts a DHCP-DISCOVER message to
locate a DHCP server.
2)
A DHCP server offers configuration parameters such
as an IP address to the client in a DHCP-OFFER message. The sending mode of the
DHCP-OFFER is determined by the flag field in the DHCP-DISCOVER message. Refer
to DHCP Message Format
for related information.
3)
If several DHCP servers send offers to the
client, the client accepts the first received offer, and broadcasts it in a
DHCP-REQUEST message to formally request the IP address.
4)
All DHCP servers receive the DHCP-REQUEST
message, but only the server to which the client sent a formal request for the
offered IP address returns a DHCP-ACK message to the client, confirming that
the IP address has been allocated to the client, or returns a DHCP-NAK unicast message,
denying the IP address allocation.
l
After the client receives the DHCP-ACK message,
it will probe whether the IP address assigned by the server is in use by broadcasting
a gratuitous ARP packet. If the client receives no response within specified
time, the client can use this IP address. Otherwise, the client sends a
DHCP-DECLINE message to the server to request an IP address again.
l
If there are multiple DHCP servers, IP addresses
offered by other DHCP servers are assignable to other clients.
The IP address dynamically allocated by a
DHCP server to a client has a lease. After the lease duration elapses, the IP
address will be reclaimed by the DHCP server. If the client wants to use the IP
address again, it has to extend the lease duration.
After the half lease duration elapses, the
DHCP client will send the DHCP server a DHCP-REQUEST unicast message to extend
the lease duration. Upon availability of the IP address, the DHCP server returns
a DHCP-ACK unicast confirming that the client’s lease duration has been extended,
or a DHCP-NAK unicast denying the request.
If the client receives the DHCP-NAK
message, it will broadcast another DHCP-REQUEST message for lease extension
after 7/8 lease duration elapses. The DHCP server will handle the request as
above mentioned.
Figure 1-3 gives the DHCP
message format, which is based on the BOOTP message format and involves eight
types. These types of messages have the same format except that some fields
have different values. The numbers in parentheses indicate the size of each
field in bytes.

Figure 1-3 DHCP message format
l
op: Message type defined in option field. 1 =
REQUEST, 2 = REPLY
l
htype,hlen: Hardware address type and length of
a DHCP client.
l
hops: Number of relay agents a request message
traveled.
l
xid: Transaction ID, a random number chosen by
the client to identify an IP address allocation.
l
secs: Filled in by the client, the number of seconds
elapsed since the client began address acquisition or renewal process. Currently
this field is reserved and set to 0.
l
flags: The leftmost bit is defined as the
BROADCAST (B) flag. If this flag is set to 0, the DHCP server sent a reply back
by unicast; if this flag is set to 1, the DHCP server sent a reply back by
broadcast. The remaining bits of the flags field are reserved for future use.
l
ciaddr: Client IP address.
l
yiaddr: 'your' (client) IP address, assigned by
the server.
l
siaddr: Server IP address, from which the
clients obtained configuration parameters.
l
giaddr: The first relay agent IP address a
request message traveled.
l
chaddr: Client hardware address.
l
sname: The server host name, from which the
client obtained configuration parameters.
l
file: Bootfile name and routing information,
defined by the server to the client.
l
options: Optional parameters field that is
variable in length, which includes the message type, lease, DNS IP address,
WINS IP address and so forth.
The DHCP message adopts the same format as the
Bootstrap Protocol (BOOTP) message for compatibility, but differs from it in the
option field, which identifies new features for DHCP.
DHCP uses the option field in DHCP messages
to carry control information and network configuration parameters, implementing
dynamic address allocation and providing more network configuration information
for clients.
Figure 1-4 shows the DHCP option format.

Figure 1-4 DHCP option format
The common DHCP options are:
l
Option 6: DNS server option. It specifies the
DNS server IP address to be assigned to the client.
l
Option 51: IP address lease option.
l
Option 53: DHCP message type option. It identifies the type of the DHCP message.
l
Option 55: Parameter request list option. It is
used by a DHCP client to request specified configuration parameters. The option
contains values that correspond to the parameters requested by the client.
l
Option 66: TFTP server name option. It specifies
a TFTP server to be assigned to the client.
l
Option 67: Bootfile name option. It specifies
the bootfile name to be assigned to the client.
l
Option 150: TFTP server IP address option. It
specifies the TFTP server IP address to be assigned to the client.
For more information about DHCP options,
refer to RFC 2132.
Some options have no unified definitions in
RFC 2132. The formats of some self-defined options are introduced as follows.
Option 82 is
the relay agent option in the option field of the DHCP message. It records the
location information of the DHCP client. When a DHCP relay agent receives a
client’s request, it adds Option 82 to the request message and sends it
to the server.
The administrator can locate the DHCP
client to further implement security control and accounting. The Option 82
supporting server can also use such information to define individual assignment
policies of IP address and other parameters for the clients.
Option 82 involves at most 255 sub-options.
At least one sub-option must be defined. Now the DHCP relay agent supports two
sub-options: sub-option 1 (Circuit ID) and sub-option 2 (Remote ID).
Option 82 has no unified definition. Its
padding formats vary with vendors. Currently the device supports two padding
formats: normal and verbose.
1)
Normal padding format
The padding contents for sub-options in the
normal padding format are:
l
sub-option 1: Padded with the VLAN ID and number
of the port that received the client’s request. The following figure
gives its format. The value of the sub-option type is 1, and that of the
circuit ID type is 0.

Figure
1-5 Sub-option 1 in normal padding format
l
sub-option 2: Padded with the MAC address of the
interface that received the client’s request. The following figure gives
its format. The value of the sub-option type is 2, and that of the remote ID
type is 0.

Figure 1-6 Sub-option 2 in normal
padding format
2)
Verbose padding format:
The padding contents for sub-options in the
verbose padding format are:
l
sub-option 1: Padded with the user-specified
access node identifier (ID of the device that adds Option 82 in DHCP messages),
and type, number, and VLAN ID of the port that received the client’s
request. Its format is shown in the following figure.

Figure
1-7 Sub-option 1 in verbose padding format
In the above
figure, except that the VLAN ID field has a fixed length of 2 bytes, all the
other padding contents of sub-option 1 are length variable.
l
sub-option 2: Padded with the MAC address of the
interface that received the client’s request. It has the same format as
that in normal padding format, as shown in Figure 1-6.
Option 184 is a reserved option, and
parameters in the option can be defined as needed. The device supports Option
184 carrying the voice related parameters, so a DHCP client with voice functions
can get an IP address along with specified voice parameters from the DHCP
server.
Option 184 involves the following sub-options:
l
Sub-option 1: IP address of the primary network
calling processor, which is a server serving as the network calling control
source and providing program downloads.
l
Sub-option 2: IP address of the backup network
calling processor that DHCP clients will contact when the primary one is
unreachable.
l
Sub-option 3: Voice VLAN ID and the result
whether DHCP clients take this ID as the voice VLAN or not.
l
Sub-option 4: Failover route that specifies the
destination IP address and the called number (SIP users use such IP addresses
and numbers to communicate with each other) that a SIP user uses to reach
another SIP user when both the primary and backup calling processors are
unreachable.
You must define the
sub-option 1 to make other sub-options take effect.
l
RFC2131: Dynamic Host Configuration Protocol
l
RFC2132: DHCP Options and BOOTP Vendor
Extensions
l
RFC1542: Clarifications and Extensions for the
Bootstrap Protocol
l
RFC 3046: DHCP Relay Agent Information Option
Chapter 2 DHCP Server Configuration
When configuring the DHCP server, go to
these sections for information you are interested in:
l
Introduction
to DHCP Server
l
DHCP
Server Configuration Task List
l
Enabling
DHCP
l
Enabling
the DHCP Server on an Interface
l
Configuring
an Address Pool for the DHCP Server
l
Configuring
the DHCP Server Security Functions
l
Configuring
the Handling Mode for Option 82
l
Displaying
and Maintaining the DHCP Server
l
DHCP
Server Configuration Examples
l
Troubleshooting
DHCP Server Configuration
l
The DHCP server configuration is supported only
on VLAN interfaces and loopback interfaces. The secondary IP address pool configuration
is not supported on loopback interfaces.
l
DHCP Snooping must be disabled on the DHCP
server.
2.1 Introduction to DHCP Server
The DHCP server is well suited to the
network where:
l
It is hard to implement manual configuration and
centralized management.
l
The hosts are more than the assignable IP
addresses and it is impossible to assign a fixed IP address to each host. For
example, an ISP limits the number of hosts to access the Internet at a time, so
lots of hosts need to acquire IP addresses dynamically.
l
A few hosts need fixed IP addresses.
I. Address pool structure
In response
to a client’s request, the DHCP server selects an idle IP address from an
address pool and sends it together with other parameters such as lease and DNS
server address to the client.
The address
pool database is organized as a tree. The root of the tree is the address pool
for natural networks, branches are address pools for subnets, and leaves are addresses
statically bound to clients. For the same level address pools, a previously
configured pool has a higher selection priority than a new one.
At the very beginning, subnetworks inherit
network parameters and clients inherit subnetwork parameters. Therefore, common
parameters, for example a DNS server address, should be configured at the
highest (network or subnetwork) level of the tree.
After establishment of the inheritance
relationship, the new configuration at the higher level (father) of the tree
will be:
l
Inherited if the lower level (child) has no such
configuration, or
l
Overridden if the lower level (child) has such configuration.
The IP address
lease does not enjoy the inheritance attribute.
II. Principles for selecting an
address pool
The DHCP server observes the following
principles to select an address pool to assign IP addresses to clients:
1)
If there is an address pool where an IP address is
statically bound to the MAC address or ID of the client, the DHCP server will
select this address pool and assign the statically bound IP address to the client.
For the configuration of this address pool, refer to section Configuring manual address allocation.
2)
Otherwise, the DHCP server will select the
smallest address pool that contains the IP address of the receiving interface
(if the client and the server reside in the same network segment), or the
smallest address pool that contains the IP address specified in the giaddr
field of the client’s request (if a DHCP relay agent is in-between). If
no IP address is available in such address pool, the DHCP server will fail to
assign an address to the client because it cannot assign an IP address from the
father address pool to the client. For the configuration of such address pool,
refer to section Configuring
dynamic address allocation.
For example,
two address pools are configured on the DHCP server. The ranges of IP addresses
that can be dynamically assigned are 1.1.1.0/24 and 1.1.1.0/25 respectively. If
the IP address of the interface receiving DHCP requests is 1.1.1.1/25, the DHCP
server will select IP addresses for clients from the 1.1.1.0/25 address pool.
If no IP address is available in the 1.1.1.0/25 address pool, the DHCP server
will fail to assign addresses to clients. If the IP address of the interface
receiving DHCP requests is 1.1.1.130/25, the DHCP server will select IP
addresses for clients from the 1.1.1.0/24 address pool.
Keep the IP
addresses for dynamic allocation within the subnet where the interface of the
DHCP server resides to avoid wrong IP address allocation.
A DHCP server assigns an IP address to a
client according to the following sequence:
1)
The IP address manually bound to the
client’s MAC address or ID
2)
The IP address that was ever assigned to the
client
3)
The IP address designated by the Option 50 field
in a DHCP-DISCOVER message
4)
The first assignable IP address found in a
proper DHCP address pool
5)
The IP address that was a conflict or passed its
lease duration
If no IP address is assignable, the server
will not respond.
2.2 DHCP Server Configuration Task List
Complete the following tasks to configure
the DHCP server:
Enable DHCP before performing other
configurations.
Follow these steps to enable DHCP:
|
To do…
|
Use the command…
|
Remarks
|
|
Enter system view
|
system-view
|
—
|
|
Enable DHCP
|
dhcp enable
|
Required
Disabled by default.
|
2.4 Enabling the DHCP Server on an Interface
With the DHCP server enabled on an
interface, upon receiving a client’s request, the DHCP server will assign
an IP address from its address pool to the DHCP client.
Follow these steps to enable the DHCP
server on an interface:
|
To do…
|
Use the command…
|
Remarks
|
|
Enter system view
|
system-view
|
—
|
|
Enter interface view
|
interface interface-type
interface-number
|
—
|
|
Enable the DHCP server on an interface
|
dhcp select server global-pool [ subaddress ]
|
Optional
Enabled by default.
|
The subaddress
keyword is valid only when the server and client are on the same subnet. If a
DHCP relay agent exists in between, regardless of subaddress, the DHCP
server will select an IP address from the address pool of the subnet which
contains the primary IP address of the DHCP relay agent’s interface (connected
to the client).
When the DHCP
server and client are on the same subnet, the server will:
l
With subaddress specified, assign an IP
address from the address pool of the subnet which the secondary IP address of
the server’s interface connected to the client belongs to, or assign from
the first secondary IP address if several secondary IP addresses exist. If no
secondary IP address is configured for the interface, the server is unable to
assign an IP address to the client.
l
Without subaddress specified, assign an
IP address from the address pool of the subnet which the primary IP address of
the server’s interface (connected to the client) belongs to.
Complete the
following tasks to configure an address pool:
2.5.2 Creating a DHCP Address Pool
Follow these steps to create a DHCP address
pool:
|
To do…
|
Use the command…
|
Remarks
|
|
Enter system view
|
system-view
|
—
|
|
Create a DHCP address pool and enter its
view
|
dhcp server ip-pool pool-name
|
Required
No DHCP address pool is created by
default.
|
2.5.3 Configuring an Address Allocation Mode
Caution:
You can configure either the static binding or dynamic address
allocation for an address pool as needed.
It is required to specify an address range
for the dynamic address allocation. A static binding is a special address pool
containing only one IP address.
I. Configuring manual address allocation
Some DHCP clients such as a WWW server need
fixed IP addresses. You can create a static binding of a client’s MAC or
ID to IP address in the DHCP address pool.
When the client with the MAC address or ID requests
an IP address, the DHCP server will find the IP address from the binding for
the client.
A DHCP address pool now supports only one static
binding, which can be a MAC-to-IP or ID-to-IP binding.
Follow these steps to configure the static
binding in a DHCP address pool:
|
To do…
|
Use the command…
|
Remarks
|
|
Enter system view
|
system-view
|
—
|
|
Enter DHCP address pool view
|
dhcp server ip-pool pool-name
|
—
|
|
Bind IP addresses statically
|
static-bind ip-address ip-address [ mask-length | mask mask ]
|
Required
No IP addresses are statically bound by
default.
|
|
Bind MAC addresses or IDs statically
|
Specify the MAC address
|
static-bind mac-address mac-address
|
Required to configure either of the two
Neither is bound statically by default.
|
|
Specify the ID
|
static-bind client-identifier client-identifier
|
l
Use the static-bind ip-address command
together with static-bind mac-address or static-bind client-identifier
command to accomplish a static binding configuration.
l
In a DHCP address pool, if you execute the static-bind
mac-address command before the static-bind client-identifier
command, the latter will overwrite the former and vice versa.
l
If you use the static-bind ip-address,
static-bind mac-address, or static-bind client-identifier command
repeatedly in the DHCP address pool, the new configuration will overwrite the
previous one.
l
The IP address of the static binding cannot be an
interface address of the DHCP server. Otherwise, an IP address conflict may occur
and the bound client cannot obtain an IP address correctly.
l
The ID of the static binding must be identical
to the ID displayed by using the display dhcp client verbose command on
the client. Otherwise, the client cannot obtain an IP address.
II. Configuring dynamic address allocation
You need to specify one and only one
address range using a mask for the dynamic address allocation.
To avoid address conflicts, the DHCP server
excludes IP addresses used by the GW, FTP server and so forth from dynamic
allocation.
You can specify the lease duration for a DHCP
address pool different from others, and a DHCP address pool can only have the
same lease duration. A lease does not enjoy the inheritance attribute.
Follow these steps to configure the dynamic
address allocation:
|
To do…
|
Use the command…
|
Remarks
|
|
Enter system view
|
system-view
|
—
|
|
Enter DHCP address pool view
|
dhcp server ip-pool pool-name
|
—
|
|
Specify an IP address range
|
network network-address [ mask-length |
mask mask ]
|
Required
Not specified by default, meaning no
assignable address.
|
|
Specify the address lease duration
|
expired { day
day [ hour hour [ minute minute ] ] | unlimited
}
|
Optional
One day by default.
|
|
Return to system view
|
quit
|
—
|
|
Exclude IP
addresses from automatic allocation
|
dhcp
server forbidden-ip low-ip-address [ high-ip-address ]
|
Optional
Except IP
addresses of the DHCP server interfaces, all addresses in the DHCP address
pool are assignable by default.
|