DHCP protocol analysis experiment

1. Experimental principle

1. DHCP (dynamic host configuration protocol)
DHCP (Dynamic Host Configuration Protocol, dynamic host configuration protocol) is a local area network network protocol, using the UDP protocol to work, mainly for two purposes: to automatically assign IP to internal networks or network service providers Address, to users or internal network administrators as a means of central management of all computers.
2. DHCP allocation method

  • automatic allocation

Once the DHCP client successfully leases the IP address from the DHCP server for the first time, it will always use this address.

  • Dynamic allocation

After DHCP leases the IP address from the HDCP server for the first time, it is not used permanently. As long as the lease expires, the client must release the IP address for use by other workstations. Of course, the client can renew the lease or lease other IP addresses in preference to other hosts.

  • Manual allocation

The IP address is specially designated by the DHCP server administrator.
3. The DHCP lease process is divided into four steps:
1. The client requests an IP
2. The server responds
3. The client selects an IP
4. The server confirms the lease
4. After the lease of the lease
IP address reaches 50%, the lease must be renewed. The client unicasts the DHCP Request request packet directly to the server.
5. The benefits of using DHCP
1. Reduce the workload of the administrator
2. Avoid the possibility of input errors
3. Avoid IP conflicts
4. Provide the utilization of IP addresses (the most important)
5. Convenient client configuration
6. DHCP reports Text type

Message type meaning
DHCP DISCOVER Client uses to find DHCP server
DHCP OFFER The DHCP server is used to respond to the DHCP DISCOVER message
DHCP REQUEST The client requests configuration confirmation or renews the lease
DHCP ACK The server's confirmation response to the REQUEST message
DHCP NAK The server's rejection response to the REQUEST message
DHCP RELEASE Used to notify the server when the client wants to release the address

7. Address pool classification
The address pool of the DHCP server is used to define the IP address range assigned to the host.

1. The interface address pool allocates IP addresses for hosts or terminals connected to the same network segment. You can execute the dhcp select interface command on the server interface to configure the DHCP server to use the DHCP server mode of the interface address pool to assign IP addresses to clients.

2. The global address pool assigns IP addresses to all terminals connected to the DHCP server. You can execute the dhcp select global command on the server interface to configure the DHCP server to use the DHCP server mode of the global address pool to assign IP addresses to clients.

3. The priority of the interface address pool is higher than that of the global address pool. After the global address pool is configured, if an address pool is configured on the interface, the client will obtain an IP address from the interface address pool. On X7 series switches, only interface address pools can be configured on VLANIF logical interfaces.

2. Experimental configuration

1. Experimental topology diagram
Insert picture description here
2. Experimental steps

  1. Configure the IPv4 address of each host as DHCP;
  2. Configure router R1 as a DHCP server;
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]undo info enable
Info: Information center is disabled.
[R1]int e0/0/0
[R1-Ethernet0/0/0]ip add 192.168.12.1 24
[R1-Ethernet0/0/0]q
[R1]int e0/0/1
[R1-Ethernet0/0/1]ip add 192.168.11.1 24
[R1-Ethernet0/0/1]q
[R1]dhcp enable
[R1]ip pool pool1
Info:It's successful to create an IP address pool.
[R1-ip-pool-pool1]network 192.168.11.0 mask 255.255.255.0
[R1-ip-pool-pool1]gateway-list 192.168.11.1
[R1-ip-pool-pool1]quit
[R1]ip pool pool2
Info:It's successful to create an IP address pool.
[R1-ip-pool-pool2]network 192.168.22.0 mask 255.255.255.0
[R1-ip-pool-pool2]gateway-list 192.168.22.1
[R1-ip-pool-pool2]quit
[R1]ip pool pool3
Info:It's successful to create an IP address pool.
[R1-ip-pool-pool3]network 192.168.33.0 mask 255.255.255.0
[R1-ip-pool-pool3]gateway-list 192.168.33.1
[R1-ip-pool-pool3]quit
[R1]int e0/0/0
[R1-Ethernet0/0/0]dhcp select global
[R1-Ethernet0/0/0]q
dhcp select global命令用来使能接口的DHCP服务器功能。
[R1]int e0/0/1
[R1-Ethernet0/0/1]dhcp select global
[R1-Ethernet0/0/1]q
[R1]ip pool pool1
[R1-ip-pool-pool1]dns-list 1.1.1.1
[R1-ip-pool-pool1]lease day 10
[R1-ip-pool-pool1]q
[R1]ip pool pool2
[R1-ip-pool-pool2]dns-list 1.1.1.1
[R1-ip-pool-pool2]lease day 10
[R1-ip-pool-pool2]q
[R1]ip pool pool3
[R1-ip-pool-pool3]dns-list 1.1.1.1
[R1-ip-pool-pool3]lease day 10
[R1-ip-pool-pool3]q
[R1]rip
[R1-rip-1]version 2
[R1-rip-1]network 192.168.11.0
[R1-rip-1]network 192.168.22.0
[R1-rip-1]network 192.168.33.0
[R1-rip-1]q
[R1]q
<R1>save

3. View the R1 address pool:
Insert picture description here
4. Configure R2 and R3;
R2 is configured as follows (the same is true for R3):

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]undo info enable
Info: Information center is disabled.
[R2]int e0/0/0
[R2-Ethernet0/0/0]ip add 192.168.12.2 24
[R2-Ethernet0/0/0]quit
[R2]int e0/0/1
[R2-Ethernet0/0/1]ip add 192.168.24.1 24
[R2-Ethernet0/0/1]quit
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.22.1 24
[R2-GigabitEthernet0/0/0]quit
[R2]rip
[R2-rip-1]version 2
[R2-rip-1]network 192.168.12.0
[R2-rip-1]network 192.168.24.0
[R2-rip-1]network 192.168.22.0
[R2-rip-1]q
[R2]int e0/0/0
[R2]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R2]int e0/0/0
[R2-Ethernet0/0/0]dhcp select relay
[R2-Ethernet0/0/0]dhcp relay server-ip 192.168.12.1
[R2-Ethernet0/0/0]q
[R2]int e0/0/1
[R2-Ethernet0/0/1]dhcp select relay
[R2-Ethernet0/0/1]dhcp relay server-ip 192.168.12.1
[R2-Ethernet0/0/1]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]dhcp select relay
[R2-GigabitEthernet0/0/0]dhcp relay server-ip 192.168.12.1
[R2-GigabitEthernet0/0/0]q
[R2]q
<R2>save
  1. Check whether each host is assigned an IP address of a different subnet;
    Insert picture description here
    Insert picture description here
    Insert picture description here
    each host is assigned an IP address, and the experiment configuration is successful.

Guess you like

Origin blog.csdn.net/weixin_44366125/article/details/105873667