A dynamic IP address allocation method and apparatus
By combining DHCP and Zeroconf protocols for IP address allocation and using TLV format address conflict detection messages, the server pressure problem when network nodes are added or fail is solved, achieving efficient IP address allocation and conflict detection, and improving network stability and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR SUZHOU INTELLIGENT TECH CO LTD
- Filing Date
- 2023-12-26
- Publication Date
- 2026-07-03
AI Technical Summary
In existing technologies, when network nodes increase or fail, the IP address allocation puts excessive pressure on the server, posing a risk to the normal operation of the server. Furthermore, traditional IP address conflict detection methods cannot transmit conflict information in a timely manner, affecting the stability of network communication.
The method of IP address allocation adopts a combination of Dynamic Host Configuration Protocol (DHCP) and Zeroconf Network Protocol. It determines the type of network node based on its membership and allocates IP addresses through the corresponding protocols. It also uses TLV format address conflict detection messages for timely conflict detection and handling.
It effectively relieves the pressure on the DHCP server, improves the stability and reliability of network communication, promptly detects and resolves IP address conflicts, and avoids network connection interruptions and communication failures.
Smart Images

Figure CN117793057B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of mobile communication technology, and in particular to a method and apparatus for dynamic IP address allocation. Background Technology
[0002] An Internet Protocol (IP) address is an identifier for network devices in an IP network, used for forwarding IP packets within the network. In an IP network, the allocation of IP addresses must be able to uniquely identify each network node.
[0003] The common method for allocating IP addresses to devices in a network in existing technologies generally involves using the same configuration protocol to allocate IP addresses to network nodes located within the same network, such as through a server uniformly allocating IP addresses to network nodes. This method is relatively suitable when there are few network nodes. However, as business expands, more and more network nodes join the network. New network nodes or faulty network nodes all need to request IP address allocation, which increases the load on the server and poses a potential threat to its normal operation. Summary of the Invention
[0004] The purpose of this application is to provide a dynamic IP address allocation method and apparatus for allocating IP addresses in a network using two different protocols, thereby reducing the load on the server used for IP address allocation.
[0005] This application provides a dynamic IP address allocation method for a network, wherein the network nodes include a first network node and a second network node, the first network node allocates IP addresses through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node allocates IP addresses through a Zero Conf (Zero Configuration Protocol) service.
[0006] The method includes:
[0007] In the case of adding a new network node, the new network node is determined to be either the first network node or the second network node based on its membership status.
[0008] If the newly added network node is the first network node, a request is sent to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server can assign an IP address to the newly added network node.
[0009] If the newly added network node is the second network node, an IP address will be automatically assigned to the newly added network node through the Zeroconf service.
[0010] Optionally, if it fails to assign an IP address to the new network node via the DHCP server, the method further includes: re-identifying the new network node as a second network node, and assigning an IP address to the new network node via the Zeroconf service;
[0011] If the allocation of an IP address to the newly added network node via the Zeroconf service fails, the method further includes: re-identifying the newly added network node as the first network node, and sending a request to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node, so that the DHCP server allocates an IP address to the newly added network node.
[0012] Optionally, if the process ends after assigning an IP address to the new network node via a DHCP server or via the Zeroconf service, the method further includes:
[0013] Initiate IP address conflict detection to check if there is a first or second network node with a conflicting IP address in the current network.
[0014] If a network node with an address conflict is identified as the first network node, a new IP address will be reassigned to the first network node with the address conflict via the DHCP server.
[0015] If a network node with an address conflict is identified as the second network node, a new IP address will be automatically reassigned to the second network node with the address conflict via the Zeroconf service.
[0016] Optionally, IP address conflict detection is initiated to detect whether there is a first or second network node with a conflicting IP address in the current network, including:
[0017] For each current first network node, a first address conflict detection message is generated and sent to the adjacent first network nodes, and a first address conflict detection message sent by the adjacent first network nodes is received. The first address conflict detection message includes: a type field, a length field, and a value field, wherein the value field includes an IP address field.
[0018] The received first address conflict detection message is parsed to obtain the IP address field;
[0019] The IP address of the adjacent first network node is compared with the IP address of the current first network node. If they are different, it is determined that there is no IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node; if they are the same, it is determined that there is an IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node.
[0020] For each current second network node, a second address conflict detection message is generated and sent to other second network nodes, and second address conflict detection messages sent by other second network nodes are received. The second address conflict detection message includes: IP address;
[0021] The received second address conflict detection message is parsed to obtain the IP address field;
[0022] The IP addresses of other second network nodes are compared with the IP address of the current second network node. If they are different, it is determined that there is no IP address conflict between the other second network node corresponding to the IP address and the current second network node; if they are the same, it is determined that there is an IP address conflict between the other second network node corresponding to the IP address and the current second network node.
[0023] Optionally, if a network node experiencing an address conflict is designated as the first network node, a new IP address is reassigned to the first network node via a DHCP server, specifically including:
[0024] The first network node that experiences an address conflict sends an IP address conflict message to the DHCP server, which then changes the status of the conflicting IP address of the first network node from available to unavailable based on the IP address conflict message, and reassigns a new IP address to the first network node.
[0025] Optionally, if a network node with an address conflict is designated as the second network node, a new IP address is automatically reassigned to the second network node with the address conflict via the Zeroconf service, specifically including:
[0026] Restart the Zeroconf service on the second network node with the address conflict and renegotiate and allocate a new IP address.
[0027] This application also provides a dynamic IP address allocation device for a network, wherein the network nodes include a first network node and a second network node, the first network node allocates IP addresses through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node allocates IP addresses through a Zero-Configuration Network Protocol (Zeroconf).
[0028] The device includes:
[0029] The determination module is used to determine whether a newly added network node is a first network node or a second network node based on the membership status of the newly added network node in the case of the addition.
[0030] The first address allocation module is used to send a request to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node if the newly added network node is the first network node, so that the DHCP server can allocate an IP address to the newly added network node.
[0031] The second address allocation module is used to automatically allocate an IP address to the newly added network node through the Zeroconf service if the newly added network node is the second network node.
[0032] Optionally, the device further includes:
[0033] The reallocation module is used to, if it fails to assign an IP address to a new network node via a DHCP server, re-determine the new network node as a second network node and assign an IP address to the new network node via the Zeroconf service.
[0034] If the allocation of an IP address to the newly added network node fails through the Zeroconf service, the newly added network node is re-determined as the first network node, and a request is sent to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server can allocate an IP address to the newly added network node.
[0035] 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 dynamic IP address allocation methods described above.
[0036] 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 dynamic IP address allocation methods.
[0037] 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 dynamic IP address allocation methods.
[0038] The dynamic IP address allocation method and apparatus provided in this application allocate IP addresses by using two protocol services in the network. In the event of a new network node, the method determines whether the new network node is a first network node or a second network node. If the new network node is the first network node, it sends a request to the Dynamic Host Configuration Protocol (DHCP) server so that the DHCP server can allocate an IP address to the new network node. If the new network node is the second network node, it automatically allocates an IP address to the new network node through the Zeroconf service. This achieves IP address allocation for different network nodes while reducing the load on the DHCP server. Attached Figure Description
[0039] 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.
[0040] Figure 1 This is a schematic diagram of the network structure provided in this application;
[0041] Figure 2 This is one of the flowcharts illustrating the dynamic IP address allocation method provided in this application;
[0042] Figure 3 This is the second flowchart illustrating the dynamic IP address allocation method provided in this application;
[0043] Figure 4 This is the third flowchart illustrating the dynamic IP address allocation method provided in this application;
[0044] Figure 5 This is one of the schematic diagrams provided in this application for detecting IP address conflicts of the first network node;
[0045] Figure 6 This is the second schematic diagram provided in this application for detecting IP address conflicts of the first network node;
[0046] Figure 7 This is the fourth flowchart illustrating the dynamic IP address allocation method provided in this application;
[0047] Figure 8 This is one of the schematic diagrams provided in this application for detecting IP address conflicts of the second network node;
[0048] Figure 9 This is the second schematic diagram provided in this application for detecting IP address conflicts of the second network node;
[0049] Figure 10 This is a schematic diagram of the structure of the dynamic IP address allocation device provided in this application;
[0050] Figure 11 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0051] 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.
[0052] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of 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 and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0053] Furthermore, existing IP address conflict detection technologies involve network devices broadcasting ARP request packets with their own IP address as the source IP address to the local area network. Upon receiving network packets, the data type of the packet is identified, and the source IP address of the ARP packet is determined and compared with the local IP address to detect the existence of an IP address conflict. This method can effectively prevent connection interruptions caused by IP address conflicts between network devices and servers, improving the usability and security of network devices. However, the ARP method has a problem: when an IP address conflict occurs, other devices besides the network device experiencing the conflict cannot be notified of the conflict in a timely manner, preventing self-healing and thus affecting normal network communication.
[0054] In a local area network (LAN), when a network device's IP address conflicts with other devices (including servers, routers, and regular computers), it can lead to network connection interruptions and communication failures. Therefore, traditional IP address conflict detection methods have limitations; they cannot promptly transmit IP address conflict information to other devices besides the one experiencing the conflict.
[0055] The method in this application not only implements IP address allocation by introducing two different protocols in the same network, but also allows network nodes to detect IP address conflicts, thereby achieving comprehensive and timely IP address conflict detection, improving the stability and reliability of network communication, and effectively preventing network connection interruptions and communication failures caused by IP address conflicts.
[0056] The dynamic IP address allocation method provided in this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.
[0057] First, the network used in the embodiments of this application will be illustrated. See [link to documentation]. Figure 1 The network comprises multiple network nodes, including a first network node and a second network node. The first network node assigns IP addresses using a Dynamic Host Configuration Protocol (DHCP) server, while the second network node assigns IP addresses using a Zeroconf service.
[0058] Dynamic Host Configuration Protocol (DHCP) is a standard protocol that allows servers to dynamically assign IP addresses and configuration information to clients.
[0059] The DHCP protocol supports a client / server (C / S) architecture, which mainly consists of two parts:
[0060] 1. DHCP client: This is a network node, usually a PC, printer or other terminal device on the network. It uses IP information, including IP address and DNS, assigned by the DHCP server.
[0061] 2. DHCP Server: All IP network configuration information is centrally managed by the DHCP server, which also processes DHCP requests from network nodes.
[0062] The DHCP service uses UDP as the transport protocol. The client sends a request to port 67 of the DHCP server, and the server returns a response to the client on port 68.
[0063] Zeroconf (Zero Configuration Networking) is a network configuration protocol designed to enable network devices to automatically discover and connect to other devices on the network without any configuration, and to provide basic network services such as IP address allocation and name resolution. Using Zeroconf's automatic IP address allocation function, zero-configuration networking technology allows devices to automatically configure and discover services within a local area network (LAN) without central configuration. When a new network node joins the network, it randomly generates an IP address for the new device and broadcasts a multicast message to the network, requesting other devices to acknowledge its presence. Other devices also broadcast similar messages, thus creating a device list and informing each other of their IP addresses. In this way, dynamic IP address allocation can be achieved without a DHCP server.
[0064] like Figure 2 As shown in the embodiment of this application, a dynamic IP address allocation method is provided, which may include the following steps 201 to 203:
[0065] 201. In the case of adding a new network node, the new network node shall be determined as either the first network node or the second network node based on its membership status.
[0066] Specifically, when adding a new network node, it is necessary to first determine whether the new network node belongs to the first or second network node. This can be done based on the network node's membership status.
[0067] For example, in one approach, the network is divided into a first subnet and a second subnet. The first subnet uses a DHCP server to assign IP addresses, while the second subnet uses the Zeroconf network protocol. When a new network node is added, it is determined whether the new network node belongs to the first subnet or the second subnet, and thus whether it is classified as a first or second network node.
[0068] In another approach, the network can be divided according to its purpose, such as into a customer network and an employee network. The employee network is typically an internal LAN, and IP addresses can be assigned using the Zeroconf service; the customer network is typically a wide area network, and IP addresses can be assigned using a DHCP server. First, determine whether the newly added network node corresponds to a customer ID or an employee ID, and then determine whether to classify the new network node as the first or second network node.
[0069] 202. If the newly added network node is the first network node, a request is sent to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server assigns an IP address to the newly added network node.
[0070] Specifically, the DHCP server stores the IP addresses of all first-level network nodes. When the DHCP server receives a request to add a network node, it sends a response to the new network node based on the request and the stored IP addresses, which includes the assigned IP address.
[0071] 203. If the newly added network node is the second network node, an IP address will be automatically assigned to the newly added network node through the Zeroconf service.
[0072] Specifically, when a new network node joins the network, the Zeroconf service randomly generates an IP address for the new network device and broadcasts a multicast message to the second network, requesting responses from other device nodes. These responses contain the IP addresses of the other device nodes. In this way, each second network node knows the IP addresses of other network nodes as well as its own IP address, thus avoiding IP address allocation conflicts.
[0073] The dynamic IP address allocation method provided in this application uses two protocol services for IP address allocation in the network. This allows for the determination of whether a new network node is a first or second network node when a new network node is added. If the new network node is the first network node, it sends a request to the Dynamic Host Configuration Protocol (DHCP) server so that the DHCP server can allocate an IP address to the new network node. If the new network node is the second network node, it automatically allocates an IP address to the new network node through the Zeroconf service. This achieves IP address allocation for different network nodes while reducing the load on the DHCP server.
[0074] Optionally, during the IP address allocation process, IP address allocation may fail due to network fluctuations, device failures, or other human error. In the event of a first allocation failure, a second allocation attempt can be made. If allocation still fails after a set time limit, it is determined that the allocation of an IP address to the new network node via a DHCP server or Zeroconf service has failed. Therefore, the method described in this application can be used to switch the new network node to another network, thus changing the IP address allocation method. Specifically:
[0075] If assigning an IP address to the new network node via the DHCP server fails, the method further includes: re-identifying the new network node as a second network node, and assigning an IP address to the new network node via the Zeroconf service;
[0076] If the allocation of an IP address to the newly added network node via the Zeroconf service fails, the method further includes: re-identifying the newly added network node as the first network node, and sending a request to the DHCP server through the newly added network node so that the DHCP server allocates an IP address to the newly added network node.
[0077] The method described in this application allows for the continued allocation of IP addresses to new network nodes using a different IP address allocation protocol even if one IP address allocation protocol encounters a problem, thereby improving network reliability.
[0078] Optionally, IP address conflict detection is performed after the IP address allocation for the new network node via DHCP server or Zeroconf service has ended. Generally, IP address conflicts do not occur when IP address allocation is performed via DHCP server or Zeroconf service. However, in certain special circumstances, IP address conflicts may occur, such as due to human intervention or when a network node is damaged and replaced with a new one.
[0079] See Figure 3 The method further includes:
[0080] 301. Start IP address conflict detection to detect whether there is a first or second network node with an IP address conflict in the current network.
[0081] Since the first network node allocates IP addresses via the DHCP protocol and the second network node allocates IP addresses via the Zeroconf protocol, IP address conflict detection can be performed on the first and second network nodes respectively using their respective protocols.
[0082] In addition, it is also necessary to detect potential IP address conflicts between the first and second network nodes. One specific implementation method involves setting up middleware between the first and second networks. This middleware transmits the IP address table of each first network node (stored by a DHCP server) to each second network node, or the middleware sends the IP addresses of each second network node (maintained by the second network nodes) to the DHCP server, thus enabling IP address conflict detection between the first and second network nodes.
[0083] 302. If a network node with an address conflict is identified as the first network node, a new IP address shall be reassigned to the first network node with the address conflict via a DHCP server.
[0084] Specifically, in step 302, the current first network node that has an address conflict sends an IP address conflict message carrying the conflicting IP address to the DHCP server, so that the DHCP server changes the conflicting IP address of the current first network node from an available state to an unavailable state according to the IP address conflict message, and reassigns a new IP address to the current first network node.
[0085] For example, if a DHCP server detects that two first network nodes both have the IP address 192.168.100.10, the DHCP server will send response messages to these two first network nodes respectively to change the IP addresses of all three first network nodes to 192.168.100.11 and 192.168.100.12. On the DHCP server side, the original IP addresses of the two first network nodes will be set to unavailable, while the changed IP addresses will be set to available.
[0086] After the IP addresses of the rows are reassigned, the IP address conflict detection in step 301 is repeated until there are no more IP address conflicts.
[0087] 303. If a network node with an address conflict is identified as the second network node, a new IP address will be automatically reassigned to the second network node with the address conflict via the Zeroconf service.
[0088] Specifically, in step 303, the Zeroconf service is restarted on the second network node with the address conflict, and a new IP address is renegotiated and allocated. The reassigned IP addresses can all be different from the previous ones, or one can be the same and the other different. For example, if the IP addresses of the two conflicting second network nodes are both 192.168.0.5, then after negotiation, one second network node's IP address will be 192.168.0.6, and the other second network node's IP address will be 192.168.0.7; alternatively, one second network node's IP address can remain 192.168.0.5, and the other second network node's IP address can be 192.168.0.6.
[0089] After the IP addresses of the rows are reassigned, the IP address conflict detection in step 301 is repeated until there are no more IP address conflicts.
[0090] Steps 301 to 303 can accurately detect and prevent IP address conflicts, promptly identify situations where other devices share the same IP address, and avoid network connection interruptions and communication failures caused by IP address conflicts.
[0091] Further, see Figure 4 For each current first network node, step 301 includes:
[0092] 401. Generate a first address conflict detection message and send it to the adjacent first network node, and receive the first address conflict detection message sent by the adjacent first network node.
[0093] The first address conflict detection message includes a type field T, a length field L, and a value field V, wherein the value field V includes an IP address field.
[0094] TLV (Type-Length-Value) is a commonly used data encoding format for representing and transmitting structured data in computer networks and communication protocols to provide flexibility and scalability.
[0095] TLV consists of three parts:
[0096] 1. Type: Specifies the type or identifier of the data. It is usually represented by a fixed-size integer or identifier, used to identify the meaning and format of the data.
[0097] 2. Length: Specifies the length of the data portion. It represents the number of bytes or elements in the Value field, and can be a fixed length or a variable length.
[0098] 3. Value: The actual data content. It is structured data parsed according to the format defined by Type and Length.
[0099] TLV is designed to provide a flexible and scalable way to transmit data. It can adapt to different types and lengths of data and can be easily expanded and expanded to include new data types. Due to its versatility and flexibility, TLV is widely used in many network protocols and applications.
[0100] In practical applications, TLV is frequently used for metadata transmission, configuration information representation, parameter passing, and protocol extensions. It provides a universal data encoding and decoding mechanism, enabling different network nodes to understand and process TLV formatted data.
[0101] 402. Parse the received first address conflict detection message to obtain the IP address field.
[0102] 403. Compare the IP address of the adjacent first network node with the IP address of the current first network node. If they are different, proceed to step 404. If they are the same, proceed to step 405.
[0103] 404. Determine that there is no IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node.
[0104] 405. Determine that there is an IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node.
[0105] Steps 401 to 405 can be used to detect whether there is an IP address conflict in the current network.
[0106] The technical solution of this invention, through the TLV field based on LLDP, can accurately detect and prevent IP address conflicts. It can promptly identify situations where network nodes have the same IP address, avoiding network connection interruptions and communication failures caused by IP address conflicts.
[0107] See Figure 5 and Figure 6 , Figure 5 The network includes five first network nodes: A, B, C, D, and E, with E being a newly added network node. First network node E sends a first address conflict detection message to its neighboring first network nodes A, B, and C to detect any IP address conflicts. After parsing, first network node E determines that its IP address is duplicated with that of first network node A, both being 192.168.1.5. Then, first network node E sends an IP address conflict message carrying the conflicting IP address to the DHCP server, so that the DHCP server can reassign a new IP address of 192.168.1.4 to first network node E. Figure 6 As shown.
[0108] See Figure 7 For each current second network node, step 301 includes:
[0109] 701. Generate a second address conflict detection message and send it to other second network nodes, and receive second address conflict detection messages sent by other second network nodes.
[0110] The second address conflict detection message includes: IP address.
[0111] 702. Parse the received second address conflict detection message to obtain the IP address field.
[0112] 703. Compare the IP addresses of other second network nodes with the IP address of the current second network node. If they are different, proceed to step 704. If they are the same, proceed to step 705.
[0113] 704. Determine that there is no IP address conflict between the other second network nodes corresponding to the IP address and the current second network node.
[0114] 705. Determine that there is an IP address conflict between the other second network node corresponding to the IP address and the current second network node.
[0115] Steps 701 to 705 can be used to detect whether there are second network nodes with conflicting IP addresses in the current network.
[0116] See Figure 8 and Figure 9 , Figure 8The system includes five second network nodes: F, G, H, I, and M, with M being a newly added second network node. Second network node M receives second address conflict detection messages from the other four nodes, parses these messages to obtain the IP address field, and then compares the IP addresses of the other four second network nodes with the IP address of second network node M. The comparison reveals that second network nodes M and I have the same IP address, 192.168.2.4. The Zeroconf service then reassigns new IP addresses 192.168.2.5 and 192.168.2.6 to second network nodes M and I, respectively.
[0117] The method described in this application embodiment can achieve the following effects:
[0118] 1. Improved usability and reliability of network computers: Through the technical solution of this invention, network nodes can avoid connection interruptions caused by IP address conflicts with other network nodes. This improves the usability of network nodes, eliminating user concerns about instability and interruptions caused by IP address conflicts, thereby enhancing network reliability.
[0119] 2. Reduce administrator workload: Dynamic IP address allocation reduces the workload of administrators. The system automatically manages IP addresses and prevents conflicts, improving management efficiency.
[0120] 3. Dynamic IP Address Allocation: By introducing an intelligent dynamic IP address allocation mechanism, the system automatically allocates IP addresses based on the actual network topology and device connection status, avoiding potential errors and conflicts caused by manual allocation.
[0121] 4. Real-time IP Address Conflict Detection and Handling: The solution in this embodiment utilizes a DHCP server, Zeroconf service, and TLV field to detect IP address conflicts in real time and take timely prompts and handling measures. This ensures that IP address conflicts are quickly detected and resolved, preventing communication failures. Administrators can customize IP address allocation policies according to network configuration requirements, and the system provides flexible and personalized configuration options.
[0122] It should be noted that the dynamic IP address allocation method provided in this application embodiment can be executed by a dynamic IP address allocation device, or a control module within the dynamic IP address allocation device for executing the dynamic IP address allocation method. This application embodiment uses the execution of the dynamic IP address allocation method by a dynamic IP address allocation device as an example to illustrate the dynamic IP address allocation device provided in this application embodiment.
[0123] It should be noted that, in the embodiments of this application, the dynamic 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 dynamic 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.
[0124] The dynamic IP address allocation device provided in this application is described below, and the dynamic IP address allocation method described below can be referred to in correspondence with the dynamic IP address allocation method described above.
[0125] Figure 10 This is a schematic diagram of the structure of a dynamic IP address allocation device provided in an embodiment of this application, used in a network. The network nodes include a first network node and a second network node. The first network node allocates IP addresses through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node allocates IP addresses through a ZeroConfiguration Protocol (Zeroconf) service. Figure 10 As shown, it specifically includes:
[0126] The determination module 1001 is used to determine whether a newly added network node is a first network node or a second network node based on the membership status of the newly added network node in the case of adding a new network node.
[0127] The first address allocation module 1002 is used to send a request to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node if the newly added network node is the first network node, so that the DHCP server allocates an IP address to the newly added network node.
[0128] The second address allocation module 1003 is used to automatically allocate an IP address to the newly added network node through the Zeroconf service if the newly added network node is the second network node.
[0129] Optionally, the device further includes:
[0130] The reallocation module is used to, if it fails to assign an IP address to a new network node via a DHCP server, re-determine the new network node as a second network node and assign an IP address to the new network node via the Zeroconf service.
[0131] If the allocation of an IP address to the newly added network node fails through the Zeroconf service, the newly added network node is re-determined as the first network node, and a request is sent to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server can allocate an IP address to the newly added network node.
[0132] Optionally, the device further includes:
[0133] The conflict detection module is used to initiate IP address conflict detection after the IP address allocation for the new network node via DHCP server or via Zeroconf service has ended, to detect whether there is a first or second network node with IP address conflict in the current network.
[0134] The first conflict handling module is used to reassign a new IP address to the first network node with the address conflict via a DHCP server if there is a network node with the address conflict.
[0135] The second conflict handling module is used to automatically reassign a new IP address to the second network node with the address conflict through the Zeroconf service if there is a network node with the address conflict.
[0136] Optionally, the collision detection module is specifically used for:
[0137] For each current first network node, a first address conflict detection message is generated and sent to the adjacent first network nodes, and a first address conflict detection message sent by the adjacent first network nodes is received. The first address conflict detection message includes: a type field, a length field, and a value field, wherein the value field includes an IP address field.
[0138] The received first address conflict detection message is parsed to obtain the IP address field;
[0139] The IP address of the adjacent first network node is compared with the IP address of the current first network node. If they are different, it is determined that there is no IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node; if they are the same, it is determined that there is an IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node.
[0140] For each current second network node, a second address conflict detection message is generated and sent to other second network nodes, and second address conflict detection messages sent by other second network nodes are received. The second address conflict detection message includes: IP address;
[0141] The received second address conflict detection message is parsed to obtain the IP address field;
[0142] The IP addresses of other second network nodes are compared with the IP address of the current second network node. If they are different, it is determined that there is no IP address conflict between the other second network node corresponding to the IP address and the current second network node; if they are the same, it is determined that there is an IP address conflict between the other second network node corresponding to the IP address and the current second network node.
[0143] Optionally, the first conflict handling module is specifically configured to: send an IP address conflict message carrying the conflicting IP address to the DHCP server through the current first network node where the address conflict has occurred, so that the DHCP server changes the conflicting IP address of the current first network node from an available state to an unavailable state according to the IP address conflict message, and reassigns a new IP address to the current first network node.
[0144] Optionally, the second conflict handling module is specifically used to: restart the Zeroconf service in the second network node with the address conflict and renegotiate and allocate a new IP address.
[0145] The dynamic IP address allocation device provided in this application uses two protocol services in the network to allocate IP addresses, thereby determining whether a new network node is a first network node or a second network node when a new network node is added. If the new network node is the first network node, it sends a request to the Dynamic Host Configuration Protocol (DHCP) server so that the DHCP server can allocate an IP address to the new network node. If the new network node is the second network node, it automatically allocates an IP address to the new network node through the Zeroconf service, thereby achieving IP address allocation for different network nodes while reducing the load on the DHCP server.
[0146] Figure 11 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 11As shown, the electronic device may include a processor 1110, a communications interface 1120, a memory 1130, and a communication bus 1140, wherein the processor 1110, the communications interface 1120, and the memory 1130 communicate with each other via the communication bus 1140. The processor 1110 can call logical instructions in the memory 1130 to execute a dynamic IP address allocation method. This method includes: in the case of a newly added network node, determining whether the newly added network node is a first network node or a second network node based on its membership; if the newly added network node is a first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node to enable the DHCP server to allocate an IP address to the newly added network node; if the newly added network node is a second network node, automatically allocating an IP address to the newly added network node through the Zeroconf service.
[0147] Furthermore, the logical instructions in the aforementioned memory 1130 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 part 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.
[0148] 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 dynamic IP address allocation method provided by the above methods. The method includes: in the case of adding a network node, determining whether the added network node is a first network node or a second network node based on the membership of the added network node; if the added network node is a first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the added network node so that the DHCP server allocates an IP address to the added network node; if the added network node is a second network node, automatically allocating an IP address to the added network node through the Zeroconf service.
[0149] 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 aforementioned dynamic IP address allocation methods. The method includes: in the case of a newly added network node, determining whether the newly added network node is a first network node or a second network node based on its membership status; if the newly added network node is a first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node to enable the DHCP server to allocate an IP address to the newly added network node; if the newly added network node is a second network node, automatically allocating an IP address to the newly added network node through the Zeroconf service.
[0150] 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.
[0151] 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.
[0152] 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 dynamic IP address allocation, characterized in that, For use in a network, the network nodes of the network include a first network node and a second network node, the first network node allocates IP addresses through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node allocates IP addresses through a ZeroConfiguration Network Protocol (Zeroconf) service. The method includes: In the case of adding a new network node, the new network node is determined to be either the first network node or the second network node based on its membership status. If the newly added network node is the first network node, a request is sent to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server can assign an IP address to the newly added network node. If the newly added network node is the second network node, an IP address will be automatically assigned to the newly added network node through the Zeroconf service.
2. The method according to claim 1, characterized in that, If assigning an IP address to the new network node via the DHCP server fails, the method further includes: re-identifying the new network node as a second network node, and assigning an IP address to the new network node via the Zeroconf service; If the allocation of an IP address to the newly added network node via the Zeroconf service fails, the method further includes: re-identifying the newly added network node as the first network node, and sending a request to the DHCP server through the newly added network node so that the DHCP server allocates an IP address to the newly added network node.
3. The method according to claim 1, characterized in that, When the process of assigning an IP address to a new network node via a DHCP server or via the Zeroconf service has ended, the method further includes: Initiate IP address conflict detection to check if there is a first or second network node with a conflicting IP address in the current network. If a network node with an address conflict is identified as the first network node, a new IP address will be reassigned to the first network node with the address conflict via the DHCP server. If a network node with an address conflict is identified as the second network node, a new IP address will be automatically reassigned to the second network node with the address conflict via the Zeroconf service.
4. The method according to claim 3, characterized in that, Initiate IP address conflict detection to identify whether there is a first or second network node with a conflicting IP address in the current network, including: For each current first network node, a first address conflict detection message is generated and sent to the adjacent first network nodes, and a first address conflict detection message sent by the adjacent first network nodes is received. The first address conflict detection message includes: a type field, a length field, and a value field, wherein the value field includes an IP address field. The received first address conflict detection message is parsed to obtain the IP address field; The IP address of the adjacent first network node is compared with the IP address of the current first network node. If they are different, it is determined that there is no IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node; if they are the same, it is determined that there is an IP address conflict between the adjacent first network node corresponding to the IP address and the current first network node. For each current second network node, a second address conflict detection message is generated and sent to other second network nodes, and second address conflict detection messages sent by other second network nodes are received. The second address conflict detection message includes: IP address; The received second address conflict detection message is parsed to obtain the IP address field; The IP addresses of other second network nodes are compared with the IP address of the current second network node. If they are different, it is determined that there is no IP address conflict between the other second network node corresponding to the IP address and the current second network node; if they are the same, it is determined that there is an IP address conflict between the other second network node corresponding to the IP address and the current second network node.
5. The method according to claim 4, characterized in that, If the network node experiencing the address conflict is the first network node, a new IP address will be reassigned to the first network node through the DHCP server. Specifically, this includes: The first network node that experiences an address conflict sends an IP address conflict message to the DHCP server, which then changes the status of the conflicting IP address of the first network node from available to unavailable based on the IP address conflict message, and reassigns a new IP address to the first network node.
6. The method according to claim 4, characterized in that, If a network node with an address conflict is identified as the second network node, a new IP address will be automatically reassigned to the second network node with the address conflict via the Zeroconf service. Specifically, this includes: Restart the Zeroconf service on the second network node with the address conflict and renegotiate and allocate a new IP address.
7. A dynamic IP address allocation device, characterized in that, For use in a network, the network nodes of the network include a first network node and a second network node, the first network node allocates IP addresses through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node allocates IP addresses through a ZeroConfiguration Network Protocol (Zeroconf) service. The device includes: The determination module is used to determine whether a newly added network node is a first network node or a second network node based on the membership status of the newly added network node in the case of the addition. The first address allocation module is used to send a request to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node if the newly added network node is the first network node, so that the DHCP server can allocate an IP address to the newly added network node. The second address allocation module is used to automatically allocate an IP address to the newly added network node through the Zeroconf service if the newly added network node is the second network node.
8. The apparatus according to claim 7, characterized in that, The device further includes: The reallocation module is used to, if it fails to assign an IP address to a new network node via a DHCP server, re-determine the new network node as a second network node and assign an IP address to the new network node via the Zeroconf service. If the allocation of an IP address to the newly added network node fails through the Zeroconf service, the newly added network node is re-determined as the first network node, and a request is sent to the Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server can allocate an IP address to the newly added network node.
9. 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 dynamic IP address allocation method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the dynamic IP address allocation method as described in any one of claims 1 to 6.