Welcome to our Online Store!

What is DHCP, what DHPC can do

2018-02-11 09:32:51

Boys and girls, little editor to report to everyone. I recently heard a lot of complaints about the static configuration of IP addresses in the rivers and lakes:

When manually configuring IP addresses in large scale network, in order to avoid duplication of IP addresses, we need to plan the IP addresses of each terminal in advance, resulting in heavy workload and error prone.

When the terminal position is often changed (such as the portable computer for business traveler), each change needs to be manually reset the IP address, annoying and annoying.

Some special diskless workstations, unable to manually configure the IP address, how to intercommunicate with the network?

Do not hurry, small editor to recruit for your partners. The solution so easy! With the dynamic host configuration protocol DHCP (Dynamic Host Configuration Protocol), the above problems can be solved. Buddies don't have to worry about the wrong hand, the trouble and effort.

DHCP can dynamically allocate IP addresses for the host, and it is a widely used technology at present. For example, the office, the fixed PC in the Internet cafe, the cafe, the airport, and other places providing WIFI access to the Internet, all of these use DHCP.

This period from a small editor to popularize how DHCP is how to dynamically allocate IP addresses.

1. role cognition

In the world of DHCP, there are three characters:

DHCP server: the device that is responsible for assigning the IP address. Here is an example of a S switch.

DHCP client: a terminal or device that wants to get a IP address. Such as the PC in the following figure.

DHCP: when the DHCP relay server and DHCP client in the same network, this figure will appear Austria, its role in detail in the next content.


As an example above 2., how does the DHCP server dynamically allocate the IP address for PC?

Suppose PC is the office host of an office, and Switch is the gateway to the export of PC. By configuring the DHCP server function on the Switch, you can automatically allocate the address of the network segment for PC.

The process for PC1 to automatically apply for a IP address is such a drop:

The a.PC1 broadcast requests a DHCP server that can provide a IP address.

After receiving the request, b.Switch checks to see if it has any IP address available. It needs to configure the address pool and the IP address range that can be provided on the DHCP server in advance. If there is, respond to the IP address that PC1 can provide and the time you can use (usually called a lease).

From the lease term, it can be seen that the relationship between the DHCP client and the DHCP server is like the relationship between the debtor and the credit party. The DHCP server is equivalent to the IP address being loaned to the DHCP client. After the lease period is over, the IP address needs to be recovered again.

When C. PC1 receives messages from the Switch response, it is known that the IP address and lease can be used and message confirmation will be sent to the Switch.

D. Switch receives a confirmation message from PC1, and then feedback the agreed opinion to the PC1. In this way, PC1 can use Switch to assign to his IP address.

In general, the process of assigning an address to DHCP is called a four handshake.

Little partners will see if this process is going to be doubtful: the two handshake directly, the client sends the request, and the server responds to me. It's not very good. Why do I need four steps to shake hands?

When PC1 requests the IP address, because he does not know who is the DHCP server, it needs to broadcast the request in the same segment. It is assumed that there are multiple DHCP servers in the network and respond when the PC1 broadcast request is received. Then, PC1 may receive multiple DHCP servers at the same time in the B phase. PC1 only receives messages from the first response of the DHCP server and sends a broadcast message in the C phase to confirm with the selected DHCP server. The reason for broadcasting in the C phase is to tell the other DHCP servers that he has selected the IP address and the DHCP server. In this way, other DHCP servers can also assign IP addresses to other clients.

Speaking of this, do you have a basic understanding of DHCP? Here's an experiment to look at the specific configuration. In order to see the actual situation of the message, we take two Switch examples, as follows:


# SwitchA configuration:

<Quidway> System-View

[Quidway] sysname SwitchA

[SwitchA] DHCP enable / / global enable DHCP service

[SwitchA] VLAN 1000

[SwitchA-vlan1000] quit

[SwitchA] interface Ethernet 8/0/2

[SwitchA-Ethernet8/0/2] port link-type hybrid

[SwitchA- Ethernet8/0/2] port hybrid PVID VLAN 1000

[SwitchA- Ethernet8/0/2] port hybrid untagged VLAN 1000

[SwitchA- Ethernet8/0/2] quit

[SwitchA] interface vlanif 1000

[SwitchA-Vlanif1000] IP address 24

[SwitchA-Vlanif1000] quit

[SwitchA] interface vlanif 1000

[SwitchA-Vlanif1000] DHCP select interface

[SwitchA-Vlanif1000] quit

# SwitchB configuration:

<HUAWEI> System-View

[HUAWEI] sysname SwitchB

[SwitchB] VLAN 1000

[SwitchB-vlan1000] quit

[SwitchB] interface gigabitethernet 8/0/2

[SwitchB-GigabitEthernet8/0/2] port link-type hybrid

[SwitchB-GigabitEthernet8/0/2] port hybrid PVID VLAN 1000

[SwitchB-GigabitEthernet8/0/2] port hybrid untagged VLAN 1000

[SwitchB-GigabitEthernet8/0/2] quit

[SwitchB] interface vlanif 1000

[SwitchB-Vlanif1000] IP address dhcp-alloc / / DHCP client interface enable

# configuration is completed, display DHCP client command in SwitchB, through the "IP address" to see the client access to the IP address of


# in SwitchA executing the command isplay ip pool interface vlanif10 used, can see the IP address of the server has been allocated.


If the attentive partners have found that the principle of IP address allocation is from large to small, that is, the priority of assigning IP addresses is large.

In addition, executing commands display DHCP client statistics and display DHCP server statistics on client and server respectively, you can view the situation of sending and receiving DHCP messages in the process of application address.

On the client (SwitchB):


On the server (SwitchA):


Remember the A, B, C, D four phase of the address described above? In combination with the above, the common four types of DHCP message types are introduced.

In the DHCP Discover:a phase, the DHCP client sends the request message to the DHCP server.

In the DHCP Offer:b phase, the DHCP server sends the response message to the DHCP client.

In the DHCP Request:c phase, the DHCP client sends the request message to the DHCP server.

In the DHCP Ack:d phase, the DHCP server sends a confirmation message to the DHCP client.

To understand the message meaning, in the routine maintenance process, you can use these messages to locate the fault. Suppose that the "Dhcp Discover" on the upper server (SwitchA) shows a non 0, while the number of Dhcp Offer shows 0, indicating that the DHCP server has not responded to the message to the client, so we need to check whether there is a problem in the configuration on the server.

The above example is to use the S switch device as the DHCP client. So, how do you configure the DHCP client on PC?

Take the PC operating system as an example of Windows 7.

1. right click on the desktop "network", click "properties" and enter the network and shared center window.

2. click local connection and enter the local connection state window.

3. click properties to enter the local connection property window.


4., select "Internet protocol version 4 (TCP/IPv4)", click "properties", enter the "Internet protocol version 4 (TCP/IPv4) property" window, select "automatically get IP address", click "OK".


Finally, we summarize the contents of this issue. First, we introduce the four step handshake of address auto assignment through DHCP, and then show the configuration process of S switch as DHCP server through an example.

When you configure the DHCP server, have you noticed the DHCP select interface command configured on the interface carefully, which means that the DHCP server is based on the configuration of the interface address pool. In addition, there is another way to implement the S switch, which is based on the configuration of the global address pool.

Address: Room110,No.389 Jinwan Road,Shanghai,China

Email: daisy.dai@ccitel.com
service time: 7x24 hour