Method and apparatus for ip address allocation

CN117812045BActive Publication Date: 2026-08-18INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311520708.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-15
Publication Date
2026-08-18
Estimated Expiration
2043-11-15

AI Technical Summary

Technical Problem

在有DHCP Relay中继的网络环境中,DHCP Server发送的ARP请求无法发送到DHCP Relay另一端的网域,且发起ICMP后也不一定能绕送到DHCP Relay另一端网域,所以DHCP Server在这情境下确认IP地址冲突的机制将会有缺陷

Benefits of technology

[0056] The IP address allocation method and apparatus provided in this application receive a DHCP Discover message sent by a DHCP client and forward the DHCP Discover message to a DHCP server. The DHCP Discover message is used to request the allocation of an IP address. The method and apparatus also receive a first DHCP Offer message from the DHCP server based on the DHCP Discover message. The first DHCP Offer message carries the allocated first IP address. Address conflict detection is performed based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result. If the first detection result indicates no address conflict, the first DHCP Offer message is forwarded to the DHCP client. The first DHCP Offer message is used to allocate the first IP address to the DHCP client. This application avoids the shortcomings of ARP requests and ICMP messages failing to reach the other end of the DHCP relay network, improving the accuracy of address conflict detection. It reduces the amount of DHCP messages sent between the DHCP client and the DHCP server, and between the DHCP client and the DHCP relay, and improves the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117812045B_ABST
    Figure CN117812045B_ABST
Patent Text Reader

Abstract

The application provides an IP address allocation method and device, the method is applied to a DHCP relay, and comprises the following steps: forwarding a DHCP Discover message sent by a DHCP client to a DHCP server; receiving a first DHCP Offer message fed back by the DHCP server; performing address conflict detection on a first IP address in the first DHCP Offer message and an ARP table of the DHCP relay to obtain a first detection result; and forwarding the first DHCP Offer message to the DHCP client in the case that the first detection result is that there is no address conflict. The application can improve the accuracy of address conflict detection, can reduce the amount of DHCP message transmission between the DHCP client and the DHCP server and between the DHCP client and the DHCP relay, can improve the efficiency of IP address configuration of the DHCP server, and can reduce network resource consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of IP configuration technology, and in particular to an IP address allocation method and apparatus. Background Technology

[0002] In a DHCP (Host Configuration Protocol) network environment, there are devices that configure static IPs (Internet Protocol) themselves. This environment also has a DHCP Server configured to assign IPs. DHCP Clients and DHCP Servers forward DHCP protocol messages through DHCP Relay.

[0003] In this environment, the DHCP server sends an ARP (Address Resolution Protocol) request for the assigned IP address to confirm its availability. However, in a network environment with a DHCP relay, the ARP request sent by the DHCP server may not reach the domain at the other end of the DHCP relay, and even after initiating an ICMP request, it may not be routed to the other end of the DHCP relay. Therefore, the DHCP server's mechanism for confirming IP address conflicts in this scenario is flawed. Thus, an effective solution is urgently needed to address these issues. Summary of the Invention

[0004] The purpose of this application is to provide an IP address allocation method and apparatus to address the technical problem of inaccurate address conflict detection.

[0005] This application provides an IP address allocation method for use in DHCP relay, including:

[0006] Receives a DHCP Discover message sent by a DHCP client and forwards the DHCP Discover message to the DHCP server. The DHCP Discover message is used to request the allocation of an IP address.

[0007] Receive a first DHCP Offer message from the DHCP server based on the DHCP Discover message, the first DHCP Offer message carrying an allocated first IP address;

[0008] An address conflict detection is performed between the first IP address and the ARP table of the DHCP relay to obtain a first detection result;

[0009] If the first detection result indicates that there is no address conflict, the first DHCP Offer message is forwarded to the DHCP client. The first DHCP Offer message is used to assign the first IP address to the DHCP client.

[0010] Optionally, the method further includes:

[0011] If the first detection result indicates an address conflict, a first DHCP Decline message is generated based on the first IP address.

[0012] The first DHCP Decline message is sent to the DHCP server, and the DHCP Decline message is used to notify the DHCP server that the first IP address is unavailable;

[0013] The DHCP Discover message is resent to the DHCP server.

[0014] Receive a second DHCP Offer message from the DHCP server based on the DHCP Discover message, the second DHCP Offer message carrying the allocated second IP address;

[0015] A second detection result is obtained by performing an address conflict detection between the second IP address and the ARP table of the DHCP relay.

[0016] If the second detection result indicates an address conflict, a second DHCP Decline message is generated based on the second IP address, and the second DHCP Decline message is sent to the DHCP server. The DHCPDiscover message is then resent to the DHCP server to obtain a new IP address.

[0017] If the second detection result indicates that there is no address conflict, the second DHCP Offer message is forwarded to the DHCP client. The second DHCP Offer message is used to assign the second IP address to the DHCP client.

[0018] Optionally, the step of performing address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result includes:

[0019] Match the first IP address with the ARP table of the DHCP relay;

[0020] If the first IP address exists in the ARP table, then the first detection result is determined to be an address conflict.

[0021] If the first IP address does not exist in the ARP table, then the first detection result is determined to be that there is no address conflict.

[0022] Optionally, the method further includes:

[0023] Receive the address confirmation information sent by the DHCP client, the address confirmation information containing the IP address used by the DHCP client; add the IP address used by the DHCP client to the ARP table;

[0024] And / or, if it is detected that a specified DHCP client has not used the assigned IP address for a long period of time, the IP address used by the specified DHCP client is deleted from the ARP table, wherein the specified DHCP client is any DHCP client of the DHCP relay service.

[0025] This application provides an IP address allocation method applied to a DHCP server, including:

[0026] Receive a DHCP Discover message forwarded by the target DHCP relay. The DHCP Discover message is sent by the DHCP client to the target DHCP relay and is used to request the allocation of an IP address.

[0027] Determine the third IP address to be assigned, and determine the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay;

[0028] An address conflict detection is performed between the third IP address and the ARP table of the target DHCP relay to obtain a third detection result;

[0029] If the third detection result indicates that there is no address conflict, a third DHCP Offer message is generated based on the third IP address and sent to the target DHCP relay so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client.

[0030] Optionally, the method further includes:

[0031] If the third detection result indicates an address conflict, a fourth IP address to be assigned is determined.

[0032] An address conflict detection is performed between the fourth IP address and the ARP table of the target DHCP relay to obtain the fourth detection result;

[0033] If the fourth detection result indicates an address conflict, the IP address will be re-determined.

[0034] If the fourth detection result indicates that there is no address conflict, a fourth DHCP Offer message is generated based on the fourth IP address and sent to the target DHCP relay so that the target DHCP relay forwards the fourth DHCP Offer message to the DHCP client. The fourth DHCP Offer message is used to allocate the fourth IP address to the DHCP client.

[0035] Optionally, if the third detection result indicates no address conflict, generating a third DHCP Offer message based on the third IP address includes:

[0036] If the third detection result indicates that there is no address conflict, a request message is generated based on the third IP address, and the request message is sent on the DHCP network.

[0037] If a response message is received in response to the request message, the IP address is reassigned;

[0038] If no response message is received for the request message, a third DHCPOffer message is generated based on the third IP address.

[0039] Optionally, the request message is an ARP request message or an ICMP echo message.

[0040] Optionally, the method further includes:

[0041] Based on a third-party server, receive ARP table reports from at least one DHCP relay;

[0042] Store the ARP table reported by the at least one DHCP relay.

[0043] This application also provides an IP address allocation device for use in DHCP relay, comprising:

[0044] The first receiving module is configured to receive DHCP Discover messages sent by DHCP clients and forward the DHCP Discover messages to the DHCP server. The DHCP Discover messages are used to request the allocation of IP addresses.

[0045] The second receiving module is configured to receive a first DHCP Offer message fed back by the DHCP server based on the DHCP Discover message, wherein the first DHCP Offer message carries an allocated first IP address;

[0046] The first detection module is configured to perform address conflict detection based on the first IP address and the ARP table of the DHCP relay, and obtain a first detection result;

[0047] The first sending module is configured to forward the first DHCP Offer message to the DHCP client if the first detection result indicates that there is no address conflict. The first DHCP Offer message is used to assign the first IP address to the DHCP client.

[0048] This application also provides an IP address allocation device for use in a DHCP server, comprising:

[0049] The third receiving module is configured to receive DHCP Discover messages forwarded by the target DHCP relay. The DHCP Discover message is sent by the DHCP client to the target DHCP relay and is used to request the allocation of an IP address.

[0050] The first determining module is configured to determine the third IP address to be assigned and to determine the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay.

[0051] The second detection module is configured to perform address conflict detection based on the third IP address and the ARP table of the target DHCP relay to obtain the third detection result;

[0052] The first generation module is configured to generate a third DHCP Offer message based on the third IP address if the third detection result indicates that there is no address conflict, and send the third DHCP Offer message to the target DHCP relay so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client.

[0053] This application also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of any of the above-described IP address allocation methods.

[0054] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the above-described IP address allocation methods.

[0055] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described IP address allocation methods.

[0056] The IP address allocation method and apparatus provided in this application receive a DHCP Discover message sent by a DHCP client and forward the DHCP Discover message to a DHCP server. The DHCP Discover message is used to request the allocation of an IP address. The method and apparatus also receive a first DHCP Offer message from the DHCP server based on the DHCP Discover message. The first DHCP Offer message carries the allocated first IP address. Address conflict detection is performed based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result. If the first detection result indicates no address conflict, the first DHCP Offer message is forwarded to the DHCP client. The first DHCP Offer message is used to allocate the first IP address to the DHCP client. This application avoids the shortcomings of ARP requests and ICMP messages failing to reach the other end of the DHCP relay network, improving the accuracy of address conflict detection. It reduces the amount of DHCP messages sent between the DHCP client and the DHCP server, and between the DHCP client and the DHCP relay, and improves the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption. Attached Figure Description

[0057] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0058] Figure 1 This is one of the flowcharts illustrating the IP address allocation method provided in this application;

[0059] Figure 2 This is the second flowchart illustrating the IP address allocation method provided in this application;

[0060] Figure 3This is the third flowchart illustrating the IP address allocation method provided in this application;

[0061] Figure 4 This is the fourth flowchart illustrating the IP address allocation method provided in this application;

[0062] Figure 5 This is one of the structural schematic diagrams of the IP address allocation device provided in this application;

[0063] Figure 6 This is the second schematic diagram of the IP address allocation device provided in this application;

[0064] Figure 7 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation

[0065] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0066] The terms "first," "second," etc., used in this application's specification are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, in the specification, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects have an "or" relationship.

[0067] First, let me explain the relevant content involved in this application.

[0068] DHCP (Dynamic Host Configuration Protocol) refers to the Dynamic Host Configuration Protocol.

[0069] IP (Internet Protocol) refers to the Internet Protocol.

[0070] DNS (Domain Name System) refers to the Domain Name System.

[0071] ARP (Address Resolution Protocol) refers to the address resolution protocol.

[0072] ICMP (Internet Control Message Protocol) is the Internet Control Message Protocol.

[0073] gRPC (Google Remote Procedure Call) refers to Google Remote Procedure Call.

[0074] Ping (Packet Internet Groper) refers to an internet packet explorer.

[0075] A MAC address (Media Access Control Address) is a address used to control media access; it is also known as a local area network address, Ethernet address, or physical address.

[0076] DHCP is a network protocol designed to automatically allocate and manage IP addresses and other network configuration information, enabling computers and devices to seamlessly connect to and communicate with the network. DHCP uses a Client-(Relay)-Server model, where the DHCP Server is responsible for allocating IP addresses and other configuration information, the DHCP Client sends a request to the DHCP Server when needed, and the DHCP Relay is a device located in a different subnet that acts as a relay between the DHCP Client and the DHCP Server.

[0077] The DHCP server is responsible for allocating IP addresses and other network configuration information. It maintains an IP address pool and assigns IP addresses to DHCP clients upon receiving a request. The DHCP server also provides configuration options such as subnet mask, default gateway, and DNS server address. It manages leases, ensuring IP addresses are valid for their lease terms, monitoring lease expiration, and handling lease renewals. To avoid address conflicts, the DHCP server typically has a conflict detection mechanism. Administrators can also configure the DHCP server to assign static IP addresses.

[0078] A DHCP client is a device on a network that needs to automatically obtain network configuration information. When connecting to the network, a DHCP client sends a DHCP request, requesting an IP address and other configuration information. The DHCP client accepts the IP address and configuration options assigned by the DHCP server and manages leases, including renewing leases or releasing IP addresses. Some DHCP clients can perform address conflict detection to ensure that the assigned IP address is not being used by other devices.

[0079] A DHCP relay is a device located on a different subnet that acts as a relay for DHCP requests. A DHCP relay receives DHCP requests from DHCP clients and forwards them to one or more DHCP servers. Once a DHCP server's response arrives, the DHCP relay forwards that response to the requesting DHCP client. A DHCP relay can also act as a relay agent, returning DHCP server responses to DHCP clients located on different subnets.

[0080] A DHCP Discover message is a message used by a DHCP client to locate a DHCP server. When a DHCP client makes a DHCP request, it broadcasts a DHCP Discover message throughout the local network because it does not know the location of the DHCP server. All DHCP servers that receive the DHCP Discover message will send a response message, allowing the DHCP client to determine the location of the DHCP server in the network.

[0081] A DHCP Offer message is a message used by a DHCP server in response to a DHCP Discover message. Upon receiving a DHCP Discover message, the DHCP server searches its configured address pool for a suitable IP address, adds the appropriate lease period and other configuration information (such as gateway and DNS server), constructs a DHCP Offer message, and sends it to the DHCP client, informing the user that the DHCP server can provide an IP address. However, the DHCP Offer message only tells the DHCP client the IP address it can provide; the DHCP client still needs to use ARP to check if the IP address is already taken.

[0082] DHCP Request Message: A DHCP client may receive many DHCP Offer messages, so it must choose one from them. Typically, it selects the DHCP Server corresponding to the first received DHCP Offer message as its target server and sends a broadcast DHCP Request message to that server to notify it of the assigned IP address. Additionally, after successfully obtaining an IP address, when the lease period reaches 50%, the DHCP client will send a unicast DHCP Request message to the DHCP server to extend the lease. If it does not receive an ACK message, when the lease period reaches 87.5%, it will again send a broadcast DHCP Request message to request lease extension.

[0083] DHCP ACK message: After receiving a DHCP Request message, the DHCP Server checks whether there is a corresponding lease record based on the user's MAC address carried in the DHCP Request message. If there is, it sends a DHCP ACK message to notify the user that the assigned IP address can be used.

[0084] DHCP NAK message: If the DHCP server receives a DHCP Request message and does not find a corresponding lease record, or is unable to allocate an address normally for some reason, it sends a DHCP NAK message to the DHCP client to notify the user that a suitable IP address cannot be allocated.

[0085] DHCP Release message: When a DHCP client no longer needs to use the assigned IP address (usually when the DHCP client is powered off or offline), it will proactively send a DHCP Release message to the DHCP server to inform the DHCP server that the user no longer needs to be assigned an IP address and to request the DHCP server to release the corresponding IP address.

[0086] DHCP Decline message: After receiving a DHCP NAK message from the DHCP server, the DHCP client detects an IP address conflict through address conflict detection or finds that the IP address assigned by the DHCP server is unusable for other reasons. In this case, the client will send a DHCP Decline message to the DHCP server to notify that the assigned IP address is unavailable and obtain a new IP address.

[0087] The DHCP server performs address conflict detection as follows: Before sending a DHCP Offer message, the DHCP server is obligated to ensure that the IP address is not already in use by another device on the network, thus preventing an IP address conflict. There are generally two methods for address conflict detection on the DHCP server:

[0088] First, the DHCP server sends an ARP request to the network for an opportunistic IP (an IP address to be assigned to a DHCP client). If there is no response, it means that the IP address is not in use, and of course, it does not want to get an ARP response. If a response is received, it means that the IP address has been used, and the DHCP server will not assign the IP address.

[0089] Secondly, the DHCP server will send an ICMP echo message to the IP address to check if the IP address is already in use (i.e., initiate a ping process). If no host responds, it means the IP address is not in use and can be allocated; otherwise, it cannot. If it is in use, it needs to be reallocated according to the IP address allocation order, and the IP address conflict detection process will be repeated.

[0090] The DHCP client's address conflict detection process is as follows: When the DHCP client receives a DHCP ACK message from the DHCP server, it does not immediately use the IP address assigned by the DHCP server. Instead, it sends an ARP request with the destination IP address as a final confirmation (i.e., gratuitous ARP). If no conflict is detected, it binds this IP address to itself. If a conflict is detected, it sends a DHCP Decline message to the DHCP server, filling in the conflicting IP address provided by the DHCP server in the Request IP Address (option 50) field. After sending, it waits for a period of time before re-applying for an IP address until a usable IP address is obtained.

[0091] Currently, when a DHCP server assigns an IP address, it first checks whether the assigned IP address conflicts with IP addresses in the domain. Typically, the DHCP server sends an ARP request for the assigned IP address to the network, or initiates ICMP (ping) to confirm whether any device responds to the IP address.

[0092] Alternatively, after receiving a DHCP ACK, the DHCP client indicates that it can use the IP address, but it will broadcast an ARP packet across the network again to check if the IP address is already in use. Only if no other host is using the IP address will the DHCP client actually use it. However, if the DHCP client finds that the IP address assigned to it by the DHCP server conflicts with an IP address in the domain, the DHCP client must not only send a DHCP Decline notification to the DHCP server to reject the IP address, but also initiate a DHCP Discover process to obtain a new IP address.

[0093] In a DHCP network environment, there are devices that can set static IPs themselves, and the environment is also configured with a DHCP server to assign IPs. DHCP clients and DHCP servers forward DHCP protocol messages through DHCP Relay.

[0094] In this environment, the DHCP server sends an ARP request for the assigned IP address or initiates ICMP (Ping) to confirm the availability of the assigned IP address. However, this method has drawbacks in networks with DHCP relays. Because in a DHCP relay network, the ARP request sent by the DHCP server cannot reach the domain at the other end of the DHCP relay, and even after initiating an ICMP request, it may not be routed to the other end of the DHCP relay. This means that the IP address assigned by the DHCP server has a high probability of conflicting with the static IP addresses configured on devices within the domain.

[0095] At this point, the only way to confirm the address conflict is through the DHCP Client's mechanism. It re-initiates an ARP packet broadcast to the network to reconfirm whether the IP address can be used. Specifically, after receiving a DHCP ACK, the DHCP Client uses an ARP packet broadcast to the network to detect if the IP address is already in use. However, if the DHCP Client finds that the IP address assigned by the DHCP Server conflicts with an IP address in the domain, the DHCP Client must not only send a DHCP Decline notification to the DHCP Server to reject the IP address, but also initiate a DHCP Discover process to reacquire an IP address. In environments with more static IP addresses, the probability of repeatedly performing these actions increases until a usable IP address is obtained. This results in repeated sending of DHCP messages between the DHCP Server and the DHCP Client, leading to low efficiency in obtaining IP addresses.

[0096] To address the aforementioned issues, this application provides an IP address allocation method and apparatus. The method involves receiving a DHCP Discover message from a DHCP client and forwarding it to a DHCP server. The DHCP Discover message is used to request IP address allocation. The method also includes receiving a first DHCP Offer message from the DHCP server based on the DHCP Discover message. The first DHCP Offer message carries an allocated first IP address. Address conflict detection is performed between the first IP address and the ARP table of the DHCP relay to obtain a first detection result. If the first detection result indicates no address conflict, the first DHCP Offer message is forwarded to the DHCP client. The first DHCP Offer message is used to allocate the first IP address to the DHCP client. This application avoids the shortcomings of ARP requests and ICMP messages failing to reach the other end of the DHCP Relay network, thus improving the accuracy of address conflict detection. It also reduces the amount of DHCP messages sent between the DHCP client and the DHCP server, and between the DHCP client and the DHCP Relay, and improves the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption. Furthermore, it receives a first DHCP Offer message from the DHCP server based on the DHCP Discover message, which carries the first IP address to be allocated. The application performs address conflict detection based on the first IP address and the ARP table of the DHCP Relay, obtaining a first detection result. If the first detection result indicates no address conflict, it forwards the first DHCP Offer message to the DHCP client, which is used to allocate the first IP address to the DHCP client.

[0097] The IP address allocation method and apparatus provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0098] Figure 1 This is one of the flowcharts illustrating the IP address allocation method provided in this application. For example... Figure 1 As shown in the figure, an IP address allocation method provided in this application embodiment is applied to DHCP relay. The method may include the following steps 101 and 104:

[0099] Step 101: Receive the DHCP Discover message sent by the DHCP client and forward the DHCP Discover message to the DHCP server. The DHCP Discover message is used to request the allocation of an IP address.

[0100] Specifically, a DHCP network environment includes DHCP clients, DHCP relays, and DHCP servers. DHCP clients and DHCP servers exchange information through DHCP relays.

[0101] In practical applications, DHCP clients broadcast messages after startup to locate DHCP servers: After startup, the DHCP client generates a DHCP Discover message based on its MAC address and hostname information, and broadcasts the DHCP Discover message. That is, the DHCP Discover message contains the DHCP client's MAC address and hostname information.

[0102] The MAC address and hostname information are used to identify the DHCP client, so that the DHCP relay and DHCP server can recognize and communicate with it when the DHCP client has not been assigned an IP address.

[0103] Accordingly, the DHCP relay connected to the DHCP client receives the DHCPDiscover message sent by the DHCP client and forwards the DHCP Discover message to the DHCP server so that the DHCP server can begin to assign an IP address to the DHCP client.

[0104] Step 102: Receive the first DHCP Offer message from the DHCP server based on the DHCP Discover message. The first DHCP Offer message carries the first allocated IP address.

[0105] Specifically, after receiving a DHCP Discover message, the DHCP server searches for a suitable first IP address in its configured address pool, adds the corresponding lease period and other configuration information to construct a first DHCP Offer message, and sends the first DHCP Offer message to the DHCP relay. That is, the DHCP relay receives the first DHCP Offer message from the DHCP server.

[0106] Step 103: Perform address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain the first detection result.

[0107] Specifically, after receiving the first DHCP Offer message, the DHCP relay initiates address conflict detection: it retrieves the first IP address assigned by the DHCP server from the "Your (Client) IP Address" field in the first DHCP Offer message, and performs address conflict detection on the first IP address according to the DHCP relay's ARP table to determine whether the first IP address is occupied by another device, i.e., whether an address conflict exists. The first detection result indicates whether an address conflict exists.

[0108] Step 104: If the first detection result indicates that there is no address conflict, forward the first DHCPOffer message to the DHCP client. The first DHCP Offer message is used to assign the first IP address to the DHCP client.

[0109] Specifically, if the first detection result indicates that there is no address conflict, it means that the first IP address is available. The DHCP relay then forwards the first DHCP Offer message to the DHCP client. Upon receiving the first DHCP Offer message, the DHCP client completes the subsequent DHCP IP address allocation process.

[0110] The IP address allocation method provided in this application involves receiving a DHCP Discover message sent by a DHCP client and forwarding the DHCP Discover message to a DHCP server, wherein the DHCP Discover message is used to request the allocation of an IP address; receiving a first DHCP Offer message from the DHCP server based on the DHCP Discover message, wherein the first DHCP Offer message carries the allocated first IP address; performing address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result; and forwarding the first DHCP Offer message to the DHCP client if the first detection result indicates that there is no address conflict, wherein the first DHCP Offer message is used to allocate the first IP address to the DHCP client. This application avoids the drawbacks of ARP requests and ICMP messages failing to reach the other end of the DHCP relay network, thus improving the accuracy of address conflict detection. It also reduces the amount of DHCP messages sent between the DHCP client and the DHCP server, and between the DHCP client and the DHCP relay, while improving the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption. Furthermore, it receives a first DHCP Offer message from the DHCP server based on the DHCP Discover message, which carries the first IP address to be allocated. The application performs address conflict detection based on the first IP address and the ARP table of the DHCP relay, obtaining a first detection result. If the first detection result indicates no address conflict, it forwards the first DHCP Offer message to the DHCP client, which is used to allocate the first IP address to the DHCP client.

[0111] In one or more optional embodiments of this application, the method further includes:

[0112] If the first detection result indicates an address conflict, a first DHCP Decline message is generated based on the first IP address.

[0113] The first DHCP Decline message is sent to the DHCP server, and the DHCP Decline message is used to notify the DHCP server that the first IP address is unavailable;

[0114] The DHCP Discover message is resent to the DHCP server.

[0115] Receive a second DHCP Offer message from the DHCP server based on the DHCP Discover message, the second DHCP Offer message carrying the allocated second IP address;

[0116] A second detection result is obtained by performing an address conflict detection between the second IP address and the ARP table of the DHCP relay.

[0117] If the second detection result indicates an address conflict, a second DHCP Decline message is generated based on the second IP address, and the second DHCP Decline message is sent to the DHCP server. The DHCPDiscover message is then resent to the DHCP server to obtain a new IP address.

[0118] If the second detection result indicates that there is no address conflict, the second DHCP Offer message is forwarded to the DHCP client. The second DHCP Offer message is used to assign the second IP address to the DHCP client.

[0119] Specifically, if the first detection result indicates an address conflict, it means that the first IP address is being used by another device. Further, the DHCP relay agent DHCP client generates a first DHCP Decline message and sends it to the DHCP server, informing the DHCP server that the first IP address has a conflict and rejecting the first IP address. Afterwards, the DHCP relay agent DHCP client resends the DHCP Discover message previously sent by the DHCP client to the DHCP server.

[0120] After receiving the DHCP Discover message again, the DHCP server will search for a suitable second IP address in its configured address pool, add the corresponding lease period and other configuration information to construct a second DHCP Offer message, and then send the second DHCP Offer message to the DHCP relay. That is, the DHCP relay receives the second DHCP Offer message from the DHCP server.

[0121] After receiving the second DHCP Offer message, the DHCP relay initiates address conflict detection: it retrieves the second IP address assigned by the DHCP server from the "Your (Client) IP Address" field in the second DHCP Offer message, performs address conflict detection on the second IP address according to the DHCP relay's ARP table, and obtains the second detection result.

[0122] If the second check result indicates no address conflict, it means the second IP address is available. The DHCP relay then forwards the second DHCP Offer message to the DHCP client. Upon receiving the second DHCP Offer message, the DHCP client completes the subsequent DHCP IP address allocation process.

[0123] If the second detection result indicates an address conflict, it means the second IP address is already in use by another device. Further, the DHCP relay agent DHCP client generates a second DHCP Decline message and sends it to the DHCP server, informing the server that the second IP address is conflicted and rejecting it. Afterwards, the DHCP relay agent DHCP client resends the DHCP Discover message previously sent by the DHCP client to the DHCP server to re-obtain an IP address, until a usable IP address is obtained.

[0124] For example, the DHCP relay determines whether the IP address assigned by the DHCP server can be used normally. If there is an IP address conflict, the DHCP relay will act as an agent for the DHCP client to obtain a new set of IP addresses from the DHCP server. After obtaining a usable IP address, the DHCP relay will forward a DHCP Offer message (packet) to the DHCP client to complete the subsequent DHCP IP configuration process.

[0125] In this way, it can ensure that there are no conflicts in the IP addresses configured for DHCP clients, reduce the amount of DHCP messages sent between DHCP clients and DHCP servers, as well as between DHCP clients and DHCP relays, improve the efficiency of DHCP servers in configuring IP addresses, and reduce network resource consumption.

[0126] In one or more optional embodiments of this application, the step of performing address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain the first detection result can be implemented as follows:

[0127] Match the first IP address with the ARP table of the DHCP relay;

[0128] If the first IP address exists in the ARP table, then the first detection result is determined to be an address conflict.

[0129] If the first IP address does not exist in the ARP table, then the first detection result is determined to be that there is no address conflict.

[0130] Specifically, after receiving a DHCP Offer message (the first DHCP Offer message, the second DHCP Offer message, or any subsequent DHCP Offer message) from the DHCP server, the DHCP relay parses the IP address carried in the DHCP Offer message and compares it with the DHCP relay's Local ARP table.

[0131] If the IP address exists in the ARP table, it means another device is already using that IP address, and the detection result (first detection result, second detection result, or any subsequent detection result) indicates an address conflict. If the IP address does not exist in the ARP table, the detection result indicates no address conflict. This avoids the defect of ARP requests failing to reach the other end of the DHCP relay network, improving the accuracy and reliability of IRP address allocation.

[0132] For example, after receiving the DHCP Offer message from the DHCP server, the DHCP relay parses the "Your (Client) IP Address" field in the DHCP Offer message, retrieves the IP address assigned by the DHCP server, and then compares the retrieved IP address with the Local ARP table.

[0133] If the IP address does not exist in the ARP table, the DHCP relay will forward the DHCP Offer message to the DHCP client so that the DHCP client can complete the subsequent DHCP IP address configuration process.

[0134] If the IP address exists in the ARP table, indicating that another device is already in use, the DHCP relay agent sends a DHCP Decline message to the DHCP server, informing the server that the assigned IP address conflicts and rejecting the IP address. The DHCP relay agent then sends a DHCP Discover message to the DHCP server to re-acquire an IP address. After obtaining a usable IP address, the DHCP relay agent forwards a DHCP Offer message to the DHCP client, enabling the client to complete the subsequent DHCP IP address configuration process.

[0135] In one or more optional embodiments of this application, the method further includes:

[0136] Receive the address confirmation information sent by the DHCP client, the address confirmation information containing the IP address used by the DHCP client; add the IP address used by the DHCP client to the ARP table;

[0137] And / or, if it is detected that a specified DHCP client has not used the assigned IP address for a long period of time, the IP address used by the specified DHCP client is deleted from the ARP table, wherein the specified DHCP client is any DHCP client of the DHCP relay service.

[0138] Specifically, DHCP relays also need to maintain and update the local ARP table.

[0139] Once a DHCP client obtains a usable IP address, it generates an address confirmation message containing the IP address it uses and sends it to the DHCP relay. The DHCP relay updates its ARP table based on the IP address used by the DHCP client so that it can be used for address conflict detection when other DHCP clients obtain IP addresses in the future.

[0140] When a DHCP relay detects that a specified DHCP client has not used its assigned IP address for an extended period, such as when the device is powered off or offline, it will delete the specified unused IP address from the ARP table. This will allow other DHCP clients to use the address address for conflict detection when obtaining an IP address.

[0141] Therefore, updating the ARP table can ensure the accuracy of address conflict detection.

[0142] It should be noted that after receiving the DHCP Offer message forwarded by the DHCP relay, the DHCP client does not need to perform address conflict detection again, since the DHCP relay has already performed address conflict detection. This reduces the resource consumption caused by repeated address conflict detection. However, to ensure the reliability of the IP address used by the DHCP client, the DHCP client can perform address conflict detection, that is, the DHCP client broadcasts an ARP message to the network to reconfirm whether the obtained IP address can be used.

[0143] The following is combined with Figure 2 The IP address allocation method applied to DHCP relay described above will be further explained. See [link / reference] Figure 2 , Figure 2 This is the second flowchart illustrating the IP address allocation method provided in this application, including:

[0144] Step 201: The DHCP relay receives the DHCP Offer message.

[0145] Step 202: The DHCP relay parses the DHCP Offer message and obtains the assigned IP address from the "Your IPAddress" field in the DHCP Offer message.

[0146] Step 203: The DHCP relay checks whether the assigned IP address exists in the ARP table.

[0147] If yes, proceed to step 204; otherwise, proceed to step 206.

[0148] Step 204: The DHCP relay sends a DHCP Decline message to the DHCP server.

[0149] Step 205: The DHCP relay sends a DHCP Discover message to the DHCP server.

[0150] Then, proceed to step 201.

[0151] Step 206: The DHCP relay forwards the DHCP Offer message to the DHCP client.

[0152] The IP address allocation method provided in this application, in a mixed environment with static and dynamic IP address configuration and DHCP relay, performs address conflict detection on the IP address dynamically assigned by the DHCP server in the DHCP relay. If an address conflict occurs, the DHCP relay acts as an intermediary between the DHCP client and the DHCP server to reacquire the IP address. This can significantly reduce the number of DHCP messages (such as broadcast and unicast messages) sent between the DHCP client and the DHCP server, as well as between the DHCP client and the DHCP relay, and effectively improve the efficiency of the DHCP server in configuring IP addresses, while minimizing network resource consumption.

[0153] Figure 3 This is the third flowchart illustrating the IP address allocation method provided in this application. For example... Figure 3 As shown in the figure, an IP address allocation method provided in this application embodiment is applied to a DHCP server. The method may include the following steps 301 and 304:

[0154] Step 301: Receive a DHCP Discover message forwarded by the target DHCP relay. The DHCP Discover message is sent by the DHCP client to the target DHCP relay and is used to request the allocation of an IP address.

[0155] Specifically, a DHCP network environment includes DHCP clients, DHCP relays, and DHCP servers. DHCP clients and DHCP servers exchange information through DHCP relays.

[0156] In practical applications, DHCP clients broadcast messages after startup to locate DHCP servers: After startup, the DHCP client generates a DHCP Discover message based on its MAC address and hostname information, and broadcasts the DHCP Discover message. That is, the DHCP Discover message contains the DHCP client's MAC address and hostname information.

[0157] The MAC address and hostname information are used to identify the DHCP client, so that the DHCP relay and DHCP server can recognize and communicate with it when the DHCP client has not been assigned an IP address.

[0158] Accordingly, the target DHCP relay connected to the DHCP client receives the DHCPDiscover message sent by the DHCP client and forwards the DHCP Discover message to the DHCP server so that the DHCP server can begin to assign an IP address to the DHCP client.

[0159] Step 302: Determine the third IP address to be assigned, and determine the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay.

[0160] Specifically, after receiving a DHCP Discover message, the DHCP server will search for a suitable third IP address in the configured address pool and obtain the ARP table of the target DHCP relay from the storage area.

[0161] Step 303: Perform address conflict detection based on the third IP address and the ARP table of the target DHCP relay to obtain the third detection result.

[0162] Specifically, after determining the third IP address and the ARP table of the target DHCP relay, address conflict detection is initiated. This involves checking the third IP address against the target DHCP relay's ARP table to determine if the third IP address is being used by another device, i.e., whether an address conflict exists. The detection result indicates whether an address conflict exists.

[0163] Step 304: If the third detection result indicates that there is no address conflict, a third DHCP Offer message is generated based on the third IP address, and the third DHCP Offer message is sent to the target DHCP relay so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client.

[0164] Specifically, if the third detection result indicates no address conflict, it means the third IP address is available. Furthermore, the DHCP server will add the corresponding lease period and other configuration information to the third IP address to construct a third DHCP Offer message, which will then be sent to the target DHCP relay. The target DHCP relay will then forward the third DHCP Offer message to the DHCP client. Upon receiving the third DHCP Offer message, the DHCP client will then complete the subsequent DHCP IP address allocation process.

[0165] For example, the DHCP relay uses third-party software to proactively report the ARP table to the DHCP server. The DHCP server can directly query the reported ARP table of the DHCP relay and directly confirm with the DHCP server whether the assigned IP address has been configured and used.

[0166] The IP address allocation method provided in this application involves receiving a DHCP Discover message forwarded by a target DHCP relay. The DHCP Discover message is sent by a DHCP client to the target DHCP relay and is used to request IP address allocation. The method then determines a third IP address to be allocated and retrieves the ARP table of the target DHCP relay from pre-stored ARP tables of each DHCP relay. It performs address conflict detection based on the third IP address and the target DHCP relay's ARP table to obtain a third detection result. If the third detection result indicates no address conflict, it generates a third DHCP Offer message based on the third IP address and sends the third DHCP Offer message to the target DHCP relay, causing the target DHCP relay to forward the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client. This application avoids the shortcomings of ARP requests and ICMP messages failing to be sent to the other end of the DHCP Relay domain, improving the accuracy of address conflict detection; it can reduce the amount of DHCP messages sent between the DHCP client and the DHCP server, as well as between the DHCP client and the DHCP relay, and improve the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption.

[0167] In one or more optional embodiments of this application, the method further includes:

[0168] If the third detection result indicates an address conflict, a fourth IP address to be assigned is determined.

[0169] An address conflict detection is performed between the fourth IP address and the ARP table of the target DHCP relay to obtain the fourth detection result;

[0170] If the fourth detection result indicates an address conflict, the IP address will be re-determined.

[0171] If the fourth detection result indicates that there is no address conflict, a fourth DHCP Offer message is generated based on the fourth IP address and sent to the target DHCP relay so that the target DHCP relay forwards the fourth DHCP Offer message to the DHCP client. The fourth DHCP Offer message is used to allocate the fourth IP address to the DHCP client.

[0172] Specifically, if the third detection result indicates an address conflict, it means that the third IP address is occupied by another device. Further, the DHCP server searches for a suitable fourth IP address in the address pool and performs an address conflict detection on the fourth IP address according to the target DHCP relay's ARP table, obtaining the fourth detection result.

[0173] If the fourth check result indicates no address conflict, the DHCP server will construct a fourth DHCP Offer message by adding the corresponding lease period and other configuration information to the fourth IP address, and send this message to the target DHCP relay. The target DHCP relay will then forward the fourth DHCP Offer message to the DHCP client. Upon receiving the fourth DHCP Offer message, the DHCP client will complete the subsequent DHCP IP address allocation process.

[0174] If the fourth check result indicates an address conflict, it means that the fourth IP address is being used by another device. The DHCP server then continues searching the address pool for an IP address until it obtains a usable one.

[0175] In this way, it can ensure that there are no conflicts in the IP addresses configured for DHCP clients, reduce the amount of DHCP messages sent between DHCP clients and DHCP servers, as well as between DHCP clients and DHCP relays, improve the efficiency of DHCP servers in configuring IP addresses, and reduce network resource consumption.

[0176] In one or more optional embodiments of this application, the step of generating a third DHCP Offer message based on the third IP address when the third detection result indicates that there is no address conflict may be implemented as follows:

[0177] If the third detection result indicates that there is no address conflict, a request message is generated based on the third IP address, and the request message is sent on the DHCP network.

[0178] If a response message is received in response to the request message, the IP address is reassigned;

[0179] If no response message is received for the request message, a third DHCPOffer message is generated based on the third IP address.

[0180] Specifically, the request message is an ARP request message and / or an ICMP echo message.

[0181] In practical applications, if the third check result indicates no address conflict, the DHCP server further initiates its original address conflict check. This involves the DHCP server sending an ARP request for the assigned third IP address, or initiating an ICMP (Ping) request to confirm the availability of the third IP address. If there is no response, it means the third IP address is not occupied, and a third DHCP Offer message can be generated based on this address. If there is a response, the DHCP server continues searching for an IP address in the address pool until a usable IP address is found.

[0182] Thus, address conflict detection based on the ARP table of the target DHCP relay solves the problem that ARP requests and / or ICMP cannot be routed to the other end of the DHCP relay network. Combined with the address conflict verification mechanism of ARP requests and / or ICMP, the integrity and reliability of address conflict detection are guaranteed.

[0183] For example, the DHCP relay actively reports the ARP table to the DHCP server through third-party software, and the DHCP server stores it: it stores the IP address of the DHCP relay and the corresponding ARP table of the DHCP relay for easy querying.

[0184] When a DHCP server needs to assign an IP address, it checks the DHCP Discover message. If the message is forwarded by a DHCP relay, it first obtains the IP address of the DHCP relay and checks whether the DHCP server's database contains the ARP table corresponding to the IP address of the DHCP relay. If it does, it queries the table to confirm whether the assigned IP address exists in the ARP table. If it does, it selects a new IP address to assign. If not, it performs an address conflict check on the assigned IP address according to the DHCP server's original address conflict checking mechanism.

[0185] In one or more optional embodiments of this application, the method further includes: if the ARP table of the target DHCP relay is not stored, generating a request message based on the third IP address and sending the request message on the DHCP network; if a response message for the request message is received, re-determining the IP address; if no response message for the request message is received, generating a third DHCP Offer message based on the third IP address.

[0186] In one or more optional embodiments of this application, the method further includes:

[0187] Based on a third-party server, receive ARP table reports from at least one DHCP relay;

[0188] Store the ARP table reported by the at least one DHCP relay.

[0189] Specifically, the third-party server can be third-party software, such as Ex, gRPC, etc.

[0190] In practical applications, for each DHCP relay, whenever an ARP table is created and / or updated, the DHCP relay will automatically upload the ARP table to the DHCP server via a third-party server. Correspondingly, the DHCP server stores the ARP table.

[0191] ARP table updates include two scenarios: adding IP addresses to the ARP table and deleting IP addresses from the ARP table.

[0192] In this way, receiving newly created or updated ARP tables ensures the accuracy of address conflict detection. Furthermore, using third-party software for reporting improves real-time performance.

[0193] It should be noted that after receiving the DHCP Offer message forwarded by the DHCP relay, the DHCP client does not need to perform address conflict detection again, since the DHCP relay has already performed address conflict detection. This reduces the resource consumption caused by repeated address conflict detection. However, to ensure the reliability of the IP address used by the DHCP client, the DHCP client can perform address conflict detection, that is, the DHCP client broadcasts an ARP message to the network to reconfirm whether the obtained IP address can be used.

[0194] It should be noted that the IP address allocation method provided in this application embodiment can be executed by an IP address allocation device or a control module within that IP address allocation device for executing the IP address allocation method. This application embodiment uses an IP address allocation device executing the IP address allocation method as an example to illustrate the IP address allocation device provided in this application embodiment.

[0195] The following is combined with Figure 4 The IP address allocation method applied to the DHCP server described above will be further explained. See [link / reference] Figure 4 , Figure 4 This is the fourth flowchart illustrating the IP address allocation method provided in this application, including:

[0196] Step 401: The DHCP server receives the ARP tables reported by each DHCP relay through third-party software, i.e., receives the ARP tables.

[0197] Step 402: The DHCP server receives the DHCP Discover message.

[0198] Step 403: The DHCP server assigns IP addresses.

[0199] Step 404: The DHCP server confirms whether the DHCP Discover message is forwarded by the DHCP relay.

[0200] If yes, proceed to step 405; otherwise, proceed to step 408.

[0201] Step 405: The DHCP server parses the DHCP Discover message to obtain the IP address of the DHCP relay.

[0202] Step 406: The DHCP server checks whether there is a target ARP entry corresponding to the DHCP relay based on the IP address of the DHCP relay.

[0203] If yes, proceed to step 407; otherwise, proceed to step 408.

[0204] Step 407: The DHCP server checks whether the assigned IP address exists in the target ARP entry.

[0205] If yes, proceed to step 403; otherwise, proceed to step 408.

[0206] Step 408: The DHCP server performs the original address conflict detection behavior.

[0207] Step 409: The DHCP server sends a DHCP Offer to the DHCP client. That is, the DHCP server sends a DHCP Offer to the DHCP relay, which then forwards it to the DHCP client.

[0208] The IP address allocation method provided in this application, in a mixed environment with static and dynamic IP address configuration and DHCP relay, allows the DHCP relay to proactively report its local ARP table to the DHCP server. Before the DHCP server assigns an IP address, it pre-checks whether there is an IP address conflict. This significantly reduces the number of DHCP messages (such as broadcast and unicast messages) sent between the DHCP client and the DHCP server, as well as between the DHCP client and the DHCP relay, and effectively improves the efficiency of the DHCP server in configuring IP addresses, while minimizing network resource consumption.

[0209] It should be noted that, in the embodiments of this application, the IP address allocation methods shown in the accompanying drawings are all illustrated by way of example with reference to one of the accompanying drawings in the embodiments of this application. In specific implementation, the IP address allocation methods shown in the accompanying drawings can also be implemented in conjunction with any other accompanying drawings shown in the above embodiments, which will not be elaborated here.

[0210] The IP address allocation device provided in this application is described below, and the IP address allocation method described below can be referred to in correspondence with the IP address allocation method described above.

[0211] Figure 5 This is one of the structural schematic diagrams of an IP address allocation device provided in the embodiments of this application, applied to DHCP relay, such as... Figure 5 As shown, it specifically includes:

[0212] The first receiving module 501 is configured to receive a DHCP Discover message sent by a DHCP client and forward the DHCP Discover message to the DHCP server. The DHCP Discover message is used to request the allocation of an IP address.

[0213] The second receiving module 502 is configured to receive a first DHCP Offer message fed back by the DHCP server based on the DHCP Discover message, wherein the first DHCP Offer message carries an allocated first IP address;

[0214] The first detection module 503 is configured to perform address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result;

[0215] The first sending module 504 is configured to forward the first DHCP Offer message to the DHCP client if the first detection result indicates that there is no address conflict. The first DHCP Offer message is used to assign the first IP address to the DHCP client.

[0216] The IP address allocation device provided in this application receives a DHCP Discover message sent by a DHCP client and forwards the DHCP Discover message to a DHCP server. The DHCP Discover message is used to request the allocation of an IP address. It also receives a first DHCP Offer message from the DHCP server based on the DHCP Discover message. The first DHCP Offer message carries an allocated first IP address. Furthermore, it performs address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result. If the first detection result indicates no address conflict, it forwards the first DHCP Offer message to the DHCP client. The first DHCP Offer message is used to allocate the first IP address to the DHCP client. This application avoids the drawbacks of ARP requests and ICMP messages failing to reach the other end of the DHCP relay network, thus improving the accuracy of address conflict detection. It also reduces the amount of DHCP messages sent between the DHCP client and the DHCP server, and between the DHCP client and the DHCP relay, while improving the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption. Furthermore, it receives a first DHCP Offer message from the DHCP server based on the DHCP Discover message, which carries the first IP address to be allocated. The application performs address conflict detection based on the first IP address and the ARP table of the DHCP relay, obtaining a first detection result. If the first detection result indicates no address conflict, it forwards the first DHCP Offer message to the DHCP client, which is used to allocate the first IP address to the DHCP client.

[0217] Optionally, the IP address allocation device further includes:

[0218] The second generation module is configured to generate a first DHCP Decline message based on the first IP address if the first detection result indicates an address conflict.

[0219] The second sending module is configured to send the first DHCP Decline message to the DHCP server, wherein the DHCP Decline message is used to notify the DHCP server that the first IP address is unavailable.

[0220] The first receiving module 501 is further configured to resend the DHCP Discover message to the DHCP server;

[0221] The second receiving module 502 is further configured to receive a second DHCP Offer message fed back by the DHCP server based on the DHCPDiscover message, wherein the second DHCP Offer message carries an allocated second IP address;

[0222] The first detection module 503 further performs address conflict detection based on the second IP address and the ARP table of the DHCP relay to obtain a second detection result;

[0223] The second generation module is further configured to, in the case that the second detection result indicates an address conflict, generate a second DHCP Decline message based on the second IP address, send the second DHCP Decline message to the DHCP server, and resend the DHCP Discover message to the DHCP server to reacquire an IP address;

[0224] The first sending module 504 is further configured to forward the second DHCP Offer message to the DHCP client if the second detection result indicates that there is no address conflict. The second DHCP Offer message is used to allocate the second IP address to the DHCP client.

[0225] Optionally, the first detection module 503 is specifically configured as follows:

[0226] Match the first IP address with the ARP table of the DHCP relay;

[0227] If the first IP address exists in the ARP table, then the first detection result is determined to be an address conflict.

[0228] If the first IP address does not exist in the ARP table, then the first detection result is determined to be that there is no address conflict.

[0229] Optionally, the device further includes:

[0230] The module is configured to receive address confirmation information sent by the DHCP client, the address confirmation information containing the IP address used by the DHCP client; and to add the IP address used by the DHCP client to the ARP table.

[0231] And / or,

[0232] The deletion module is configured to delete the IP address used by the specified DHCP client from the ARP table if it is detected that the specified DHCP client has not used the assigned IP address for a long time. The specified DHCP client is any DHCP client of the DHCP relay service.

[0233] Figure 6 This is a second schematic diagram of the structure of the IP address allocation device provided in the embodiments of this application, applied to a DHCP server, such as... Figure 6 As shown, it specifically includes:

[0234] The third receiving module 601 is configured to receive DHCP Discover messages forwarded by the target DHCP relay. The DHCP Discover messages are sent by the DHCP client to the target DHCP relay and are used to request the allocation of an IP address.

[0235] The first determining module 602 is configured to determine the third IP address to be assigned and to determine the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay.

[0236] The second detection module 603 is configured to perform address conflict detection based on the third IP address and the ARP table of the target DHCP relay to obtain a third detection result;

[0237] The first generation module 604 is configured to generate a third DHCP Offer message based on the third IP address if the third detection result indicates that there is no address conflict, and send the third DHCP Offer message to the target DHCP relay so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client.

[0238] The IP address allocation device provided in this application receives a DHCP Discover message forwarded by a target DHCP relay. The DHCP Discover message is sent by a DHCP client to the target DHCP relay and is used to request IP address allocation. It then determines a third IP address to be allocated and retrieves the ARP table of the target DHCP relay from pre-stored ARP tables of each DHCP relay. It performs address conflict detection based on the third IP address and the ARP table of the target DHCP relay to obtain a third detection result. If the third detection result indicates no address conflict, it generates a third DHCP Offer message based on the third IP address and sends the third DHCP Offer message to the target DHCP relay, so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client. This application avoids the shortcomings of ARP requests and ICMP messages failing to be sent to the other end of the DHCP Relay domain, improving the accuracy of address conflict detection; it can reduce the amount of DHCP messages sent between the DHCP client and the DHCP server, as well as between the DHCP client and the DHCP relay, and improve the efficiency of the DHCP server in configuring IP addresses, effectively reducing network resource consumption.

[0239] Optionally, the device further includes:

[0240] The second determining module is configured to determine a fourth IP address to be assigned if the third detection result indicates an address conflict.

[0241] The second detection module 603 is further configured to perform address conflict detection based on the fourth IP address and the ARP table of the target DHCP relay to obtain a fourth detection result;

[0242] The second determining module is further configured to re-determine the IP address if the fourth detection result indicates an address conflict.

[0243] The first generation module 604 is further configured to generate a fourth DHCP Offer message based on the fourth IP address when the fourth detection result indicates that there is no address conflict, and send the fourth DHCP Offer message to the target DHCP relay so that the target DHCP relay forwards the fourth DHCP Offer message to the DHCP client. The fourth DHCP Offer message is used to allocate the fourth IP address to the DHCP client.

[0244] Optionally, the first generation module 604 is specifically configured as follows:

[0245] If the third detection result indicates that there is no address conflict, a request message is generated based on the third IP address, and the request message is sent on the DHCP network.

[0246] If a response message is received in response to the request message, the IP address is reassigned;

[0247] If no response message is received for the request message, a third DHCPOffer message is generated based on the third IP address.

[0248] Optionally, the request message is an ARP request message or an ICMP echo message.

[0249] Optionally, the device further includes:

[0250] The storage module is configured to receive ARP tables reported by at least one DHCP relay based on a third-party server; and to store the ARP tables reported by the at least one DHCP relay.

[0251] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include: a processor 710, a communications interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communications interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 can call logical instructions in the memory 730 to execute an IP address allocation method applied to a DHCP relay. This method includes: receiving a DHCP Discover message sent by a DHCP client and forwarding the DHCP Discover message to a DHCP server, the DHCP Discover message being used to request IP address allocation; receiving a first DHCP Offer message from the DHCP server based on the DHCP Discover message, the first DHCP Offer message carrying an allocated first IP address; performing address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result; if the first detection result indicates no address conflict, forwarding the first DHCP Offer message to the DHCP client, the first DHCP Offer message being used to allocate the first IP address to the DHCP client.

[0252] Alternatively, an IP address allocation method can be implemented for a DHCP server, the method comprising: receiving a DHCP Discover message forwarded by a target DHCP relay, the DHCP Discover message being sent by a DHCP client to the target DHCP relay, the DHCP Discover message being used to request the allocation of an IP address; determining a third IP address to be allocated, and determining the ARP table of the target DHCP relay from pre-stored ARP tables of each DHCP relay; performing address conflict detection based on the third IP address and the ARP table of the target DHCP relay, obtaining a third detection result; if the third detection result indicates no address conflict, generating a third DHCP Offer message based on the third IP address, and sending the third DHCP Offer message to the target DHCP relay, so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client, the third DHCP Offer message being used to allocate the third IP address to the DHCP client.

[0253] Furthermore, the logical instructions in the aforementioned memory 730 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0254] On the other hand, this application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer is able to execute the IP address allocation method for DHCP relay provided by the above methods. The method includes: receiving a DHCP Discover message sent by a DHCP client and forwarding the DHCP Discover message to a DHCP server, wherein the DHCP Discover message is used to request the allocation of an IP address; receiving a first DHCP Offer message fed back by the DHCP server based on the DHCP Discover message, wherein the first DHCP Offer message carries an allocated first IP address; performing address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result; and forwarding the first DHCP Offer message to the DHCP client if the first detection result indicates that there is no address conflict, wherein the first DHCP Offer message is used to allocate the first IP address to the DHCP client.

[0255] Alternatively, the computer can execute the IP address allocation method for the DHCP server provided by the above methods, receiving a DHCP Discover message forwarded by the target DHCP relay. The DHCP Discover message is sent by the DHCP client to the target DHCP relay and is used to request the allocation of an IP address. The computer then determines a third IP address to be allocated and retrieves the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay. It performs address conflict detection based on the third IP address and the ARP table of the target DHCP relay to obtain a third detection result. If the third detection result indicates no address conflict, the computer generates a third DHCP Offer message based on the third IP address and sends the third DHCP Offer message to the target DHCP relay, so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client.

[0256] In another aspect, this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described methods for IP address allocation in DHCP relay. The method includes: receiving a DHCP Discover message sent by a DHCP client and forwarding the DHCP Discover message to a DHCP server, the DHCP Discover message being used to request IP address allocation; receiving a first DHCP Offer message from the DHCP server based on the DHCP Discover message, the first DHCP Offer message carrying an allocated first IP address; performing address conflict detection based on the first IP address and the ARP table of the DHCP relay to obtain a first detection result; and, if the first detection result indicates no address conflict, forwarding the first DHCP Offer message to the DHCP client, the first DHCP Offer message being used to allocate the first IP address to the DHCP client.

[0257] Alternatively, when executed by a processor, the computer program may implement the aforementioned methods for IP address allocation applied to a DHCP server, the method comprising: receiving a DHCP Discover message forwarded by a target DHCP relay, the DHCP Discover message being sent by a DHCP client to the target DHCP relay, the DHCP Discover message being used to request the allocation of an IP address; determining a third IP address to be allocated, and determining the ARP table of the target DHCP relay from pre-stored ARP tables of each DHCP relay; performing address conflict detection based on the third IP address and the ARP table of the target DHCP relay, obtaining a third detection result; if the third detection result indicates no address conflict, generating a third DHCP Offer message based on the third IP address, and sending the third DHCP Offer message to the target DHCP relay, so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client, the third DHCP Offer message being used to allocate the third IP address to the DHCP client.

[0258] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0259] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0260] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for allocating IP addresses, characterized in that, Applied to DHCP server, including: Receive a DHCP Discover message forwarded by the target DHCP relay. The DHCP Discover message is sent by the DHCP client to the target DHCP relay and is used to request the allocation of an IP address. Determine the third IP address to be assigned, and determine the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay; An address conflict detection is performed between the third IP address and the ARP table of the target DHCP relay to obtain a third detection result; If the third detection result indicates that there is no address conflict, a third DHCP Offer message is generated based on the third IP address and sent to the target DHCP relay so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client. Based on a third-party server, receive ARP table reports from at least one DHCP relay; Store the ARP table reported by the at least one DHCP relay.

2. The IP address allocation method according to claim 1, characterized in that, The method further includes: If the third detection result indicates an address conflict, a fourth IP address to be assigned is determined. An address conflict detection is performed between the fourth IP address and the ARP table of the target DHCP relay to obtain the fourth detection result; If the fourth detection result indicates an address conflict, the IP address will be re-determined. If the fourth detection result indicates that there is no address conflict, a fourth DHCP Offer message is generated based on the fourth IP address and sent to the target DHCP relay so that the target DHCP relay forwards the fourth DHCP Offer message to the DHCP client. The fourth DHCP Offer message is used to allocate the fourth IP address to the DHCP client.

3. The IP address allocation method according to claim 1 or 2, characterized in that, If the third detection result indicates no address conflict, the process of generating a third DHCP Offer message based on the third IP address includes: If the third detection result indicates that there is no address conflict, a request message is generated based on the third IP address, and the request message is sent on the DHCP network. If a response message is received in response to the request message, the IP address is reassigned; If no response message is received for the request message, a third DHCPOffer message is generated based on the third IP address.

4. The IP address allocation method according to claim 3, characterized in that, The request message is either an ARP request message or an ICMP echo message.

5. An IP address allocation device, characterized in that, Applied to DHCP server, including: The third receiving module is configured to receive DHCP Discover messages forwarded by the target DHCP relay. The DHCP Discover message is sent by the DHCP client to the target DHCP relay and is used to request the allocation of an IP address. The first determining module is configured to determine the third IP address to be assigned and to determine the ARP table of the target DHCP relay from the pre-stored ARP tables of each DHCP relay. The second detection module is configured to perform address conflict detection based on the third IP address and the ARP table of the target DHCP relay to obtain the third detection result; The first generation module is configured to, if the third detection result indicates no address conflict, generate a third DHCP Offer message based on the third IP address and send the third DHCP Offer message to the target DHCP relay, so that the target DHCP relay forwards the third DHCP Offer message to the DHCP client. The third DHCP Offer message is used to allocate the third IP address to the DHCP client. The module also receives ARP tables reported by at least one DHCP relay based on a third-party server and stores the ARP tables reported by the at least one DHCP relay.

6. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the steps of the IP address allocation method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the IP address allocation method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method, system and trunk equipment for assigning multiple server addresses

    CN101951417A