DHCP and relay

DHCP (Dynamic Host Configuration Protocol) application layer protocol

*It is a network protocol of a local area network, using UDP protocol to work (transport layer). Main functions:
1. Automatically assign IP addresses to internal networks or network service providers.
2. To users or internal network managers as a central management method for all computers
. The benefits are:
reduce workload; avoid the possibility of input errors; avoid IP address conflict; when changing the IP address segment, there is no need to reconfigure each user's IP address; improve the utilization of IP addresses; and facilitate client configuration.

*The typical application mode of DHCP is as follows:
set up a dedicated DHCP server in the network, responsible for centrally assigning various network address parameters (mainly including IP address, subnet mask, broadcast address, default gateway address, DNS server address); Other hosts act as DHCP clients and configure the network card to automatically obtain an address, then they can communicate with the DHCP server to complete the automatic configuration process.

*The DHCP protocol uses UDP as the transmission protocol. The host sends a request message to port 67 of the DHCP server, and the DHCP server responds with a response message to port 68 of the client.
The working principle of DHCP IP address automatic acquisition:
Step 1: The client searches for the server in the network.
The client sends a DHCP Discover message by broadcasting to find the server.
Step 2: The server responds to the client with services.
The server sends a DHCP offer message unicast to provide network information such as an IP address to the client, and selects an unallocated address from the IP address pool to assign to the client.
Insert picture description here
The third step: the client sends a service request to the server.
If multiple DECP servers send a DHCP-offer message to the client, the client only accepts the first received DRCP-offer message and extracts the T2 address, and then the client sends a DHCP Request message to the server by broadcasting. The client chooses to use the IP address locally.
Step 4: The server provides services to the client.
The server sends a DHCP Ack message through unicast to inform the client that the IP address is legal and usable, and adds the lease term information of the IP address in the option field.
* Re-login the
DHCP client every time it re-login to the network, no need to send DHCP again Discover information, but directly send the DACPRequesti request information containing the previously allocated [P address.
*Renew the lease
When the lease of the IP address leased by the DHCP server to the client reaches 50%, the lease needs to be renewed. The client directly sends a DHCPRequest packet to the server that provides the lease, requesting to update the existing address lease.
*The DHCP server of Huawei system will allocate IP from the IP pool in descending order.

There are two configuration methods for dhcp

Interface mode

The interface address pool can dynamically allocate IP addresses. The range is the network segment where the IP address of the interface is located, and it only takes effect on this interface. When the DHRCP server receives the request message from the DAcP client, the DHCP server will use the interface address The network segment assigns addresses to clients.
[R1] dhcp enable
system mode to enable DHCP function
[R1]interface GigabitEthernet0/0/0
[R1-GigabitEthernet0/0/0] dhcp select interface
based on interface configuration DHCP
[R1-GigabitEthernet0/0/0]dhcp server lease day 7
configuration DHCP servser lease based on the interface (default lease is 1 day)
[R1-GigabitEthernet0/0/0] dhcp server excluded-ip-address 192.168.10.200 192.168.10.210
Configure the IP address range in the interface address pool that does not participate in automatic allocation From 192.168.10.200 to 192.168.10.210
[R1-GigabitEthernet0/0/0] dhcp server dns-list 8.8.8.8##Automatically assign DNS server addresses to the client

Global mode

In the global mode, multiple global address pools are set, and there is a corresponding relationship between the defined address pool network segment and the port IP that are the same network segment, that is, multiple different network segment pools correspond to their respective ports, and finally realize different network segment clients Obtain the corresponding address automatically.

[R1]dhcp enable
system mode to enable DHCP function
[R1] ip pool 1
create an address pool name
[R1-ip-pool-1]gateway-list 192.168.20.1
set the export gateway address of the DHCP client
[R1-ip-pool-1 ] network 192.168.20.0 mask 255.255.255.0
Configure the DHCP assignable address network segment, the mask can also be expressed as 24
[R1-ip-pool-1]dns-list 114.114.114.114
Configure DHCP to assign DNS address
[R1-ip-pool- 1] excluded-ip-address 192.168.20.250 192.168.20.254
configuration reserved address
[R1-ip-pool-1] static-bind ip-address 192.168.20.9 mac-address 5489-98C6-OCEE
binding IP 192.168.20.9
fixed Assigned to the machine with MAC 28d2-4469-5a55, the IP in the pool is required
[R1-ip-pool-huawei1]lease day 10###Lease day 10 days
[R1]int g0/0/0
[R1-GigabitEthernet0/0 /0]dhcp select global
configure DHCP to global global mode, interface is interface mode
[Huawei]display ip pool
View IP address pool information

DHCP relay

In a large network, there may be multiple network segments. The DHCP client obtains the P address after obtaining a response from the DHCP server through a network broadcast message. But broadcast messages cannot cross network segments. Therefore, if the DHCP client and server are in different network segments, can the client apply for a TP address from the server? This requires the use of a DHCP relay agent. The DHCP relay agent is actually a software technology. The equipment (routers, switches, servers) installed in the DHCP relay agent is called the DHCP relay agent server, which is not responsible for the communication between the DHCP client and server between the network segments. task.
Working principle:
When the DHCP client starts and initializes the DHCP, it broadcasts a configuration request message on the local network. If there is a DHCP server in the local network, you can directly perform DHCP configuration without a DHCP relay.
·If the local network does not have a DHCP server, the network device connected to the network with DHCP relay function will process the broadcast message appropriately and forward it to the designated DHCP server on other networks.
●The DHCP server performs the corresponding configuration according to the information provided by the client, and sends the configuration information to the client through the DRCP relay to complete the dynamic configuration of the client.
Configure the DHCP relay server:
[R1]dhcp enable
[R1]interface GigabitEthernet0/0/1 to
connect to the client interface
[R1-GigabitEthernet0/0/1] ip add 192.168.1.1 24
[R1-GigabitEthernet0/0/1] dhcp select relay
Turn on the DHCP relay function
[R1-GigabitEthernet0/0/1] dhcp relay server-ip 12.0.0.1
Point to the DHCP server address 12.0.0.1 to request the DHCP service
[Rl]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1 ##If the DHCP relay server and the DHCP server cross the network segment, you must configure static or dynamic routing
[R1] interface GigabitEthernet0/0/0
[R1-GigabitEthernet0/0/0] ip add 12.0.0.2 24
Configure the DHCP server:
[R2]dhcp enable
[R2]interface GigabitEthernet0/0/0 is
connected to the DHCP relay interface
[R2- GigabitEthernet0/0/0] ip add 12.0.0.124
[R2-GigabitEthernet0/0/0] dhcp select global
configures the interface in global mode to request DHCP service
[R2] ip pool 1
[R2-ip-pool-1] gateway-list .192.168.1.1
[R2-ip-pool-1]network 192.168.1.0 mask 255.255.255.0
[R2-ip-pool-1]dns-list 114.114.114.114
[R1-ip-pool-1]lease day 3
#3 days
[ Huawei]ip route-static 192.168.1.0 255.255.255.0 12.0.0.2
Remember to configure static/default routing or dynamic routing

There are two representative transport layer protocols in TCP/IP-TCP and UDP

Insert picture description here
*TCP provides connection-oriented reliable services to the upper layer, and UDP provides connectionless and unreliable services to the upper layer.
*Although UDP is not as accurate as TCP transmission, it can also make a difference in many places with high real-time requirements.
*Requires high data accuracy, the speed can be relatively slow, you can choose TCP

Guess you like

Origin blog.csdn.net/hotshortgg/article/details/112165029