CN117793057A - Dynamic IP address allocation method and device - Google Patents

Dynamic IP address allocation method and device Download PDF

Info

Publication number
CN117793057A
CN117793057A CN202311811850.5A CN202311811850A CN117793057A CN 117793057 A CN117793057 A CN 117793057A CN 202311811850 A CN202311811850 A CN 202311811850A CN 117793057 A CN117793057 A CN 117793057A
Authority
CN
China
Prior art keywords
network node
address
newly added
network
conflict
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311811850.5A
Other languages
Chinese (zh)
Inventor
王柏森
纪柏雄
陈翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Metabrain Intelligent Technology Co Ltd
Original Assignee
Suzhou Metabrain Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Metabrain Intelligent Technology Co Ltd filed Critical Suzhou Metabrain Intelligent Technology Co Ltd
Priority to CN202311811850.5A priority Critical patent/CN117793057A/en
Publication of CN117793057A publication Critical patent/CN117793057A/en
Pending legal-status Critical Current

Links

Abstract

The application provides a dynamic IP address allocation method and a device, which relate to the technical field of mobile communication, and the method comprises the following steps: under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service. The IP address allocation of different network nodes is realized, and meanwhile, the pressure of the DHCP server is relieved.

Description

Dynamic IP address allocation method and device
Technical Field
The present invention relates to the field of mobile communications technologies, and in particular, to a method and an apparatus for allocating a dynamic IP address.
Background
The network protocol (Internet Protocol, IP) address is an identification of network devices in the IP network, for forwarding IP messages in the network, where the IP address is assigned to uniquely identify each network node.
In the prior art, a method for allocating IP addresses of devices in a network is generally used for allocating IP addresses to network nodes located in the same network by adopting the same configuration protocol, for example, uniformly allocating the IP addresses of the network nodes through a server. This approach is also more trial when there are fewer network nodes. But as traffic continues to develop, there are more and more network nodes joining the network. For either a newly added network node or a failed network node, it is necessary to request an allocation of an IP address. The pressure of the server can be increased, and hidden danger is brought to the normal operation of the server.
Disclosure of Invention
The purpose of the application is to provide a dynamic IP address allocation method and a device, which are used for realizing IP address allocation through two different protocols in a network so as to share the pressure of a server for IP address allocation.
The application provides a dynamic IP address allocation method, which is used for a network, wherein a network node of the network comprises 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) service;
The method comprises the following steps:
under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node;
if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node;
if the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service.
Optionally, if the allocation of the IP address to the newly added network node by the DHCP server fails, the method further includes: the newly added network node is re-determined to be a second network node, and an IP address is distributed to the newly added network node through Zeroconf service;
if the allocation of the IP address to the newly added network node fails through Zeroconf service, the method further includes: and re-determining the newly-added network node as a first network node, and sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly-added network node so that the DHCP server distributes an IP address for the newly-added network node.
Optionally, in the case that the allocation of the IP address to the newly added network node by the DHCP server ends or the allocation of the IP address to the newly added network node by the Zeroconf service ends, the method further includes:
Starting IP address conflict detection, and detecting whether a first network node or a second network node with IP address conflict exists in the current network;
if the network node with address conflict is the first network node, reallocating a new IP address for the first network node with address conflict through the DHCP server;
and if the network node with the address conflict is a second network node, automatically reassigning a new IP address to the second network node with the address conflict through the Zeroconf service.
Optionally, starting IP address conflict detection, detecting whether there is a first network node or a second network node with an IP address conflict in the current network, including:
for each current first network node, generating a first address conflict detection message, sending the first address conflict detection message to adjacent first network nodes, and receiving the first address conflict detection message sent by the adjacent first network nodes, wherein the first address conflict detection message comprises: a type field, a length field, and a value field, wherein the value field includes an IP address field;
analyzing the received first address conflict detection message to obtain an IP address field;
comparing the IP addresses of the adjacent first network nodes with the IP addresses of the current first network nodes, and if the IP addresses are different, determining that the adjacent first network nodes corresponding to the IP addresses do not have IP address conflict with the current first network nodes; if the IP addresses are the same, determining that the adjacent first network node corresponding to the IP addresses conflicts with the current first network node;
For each current second network node, generating a second address conflict detection message, transmitting the second address conflict detection message to other second network nodes in groups, and receiving the second address conflict detection message transmitted by the other second network nodes, wherein the second address conflict detection message comprises: an IP address;
analyzing the received second address conflict detection message to obtain an IP address field;
comparing the IP addresses of other second network nodes with the IP addresses of the current second network node, and if the IP addresses are different, determining that the other second network nodes corresponding to the IP addresses do not have IP address conflict with the current second network node; if the IP addresses are the same, determining that other second network nodes corresponding to the IP addresses have IP address conflicts with the current second network node;
optionally, if the network node with the address conflict is the first network node, reassigning a new IP address to the first network node with the address conflict through the DHCP server specifically includes:
and sending an IP address conflict message carrying the conflict IP address to a DHCP server through the current first network node with address conflict, so that the DHCP server changes the conflict 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.
Optionally, if the network node with the address conflict is the second network node, automatically reassigning a new IP address to the second network node with the address conflict through Zeroconf service, which specifically includes:
restarting Zeroconf service in the second network node with the address conflict, and renegotiating to allocate a new IP address.
The application also provides a dynamic IP address allocation device which is used for a network, wherein the network nodes of the network comprise 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);
the device comprises:
the determining module is used for determining whether the newly added network node is a first network node or a second network node according to the membership of the newly added network node under the condition of the newly added network node;
the first address allocation module is used for sending 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 for the newly added network node;
And the second address allocation module is used for automatically allocating an IP address to the newly added network node through the Zeroconf service if the newly added network node is the second network node.
Optionally, the apparatus further comprises:
a reassignment module, configured to, if the assignment of the IP address to the newly added network node by the DHCP server fails, redetermine the newly added network node to be a second network node, and assign the IP address to the newly added network node by Zeroconf service;
if the IP address allocation for the newly-added network node fails through the Zeroconf service, the newly-added network node is re-determined to be the first network node, and a request is sent to a Dynamic Host Configuration Protocol (DHCP) server through the newly-added network node, so that the DHCP server allocates the IP address for the newly-added network node.
The present application also provides a computer program product comprising computer programs/instructions which when executed by a processor implement the steps of a dynamic IP address allocation method as described in any of the above.
The application also provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the dynamic IP address allocation method as described in any one of the above when executing the program.
The present application also provides a computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of a dynamic IP address allocation method as described in any of the above.
According to the dynamic IP address allocation method and device, IP address allocation is carried out by using two protocol services in the network, so that under the condition of newly adding a network node, the newly added network node is determined to be a first network node or a second network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is a second network node, the IP address is automatically allocated to the newly added network node through the Zeroconf service, so that the IP address allocation of different network nodes is realized, and meanwhile, the pressure of a DHCP server is relieved.
Drawings
In order to more clearly illustrate the technical solutions of the present application or the prior art, the following description will briefly introduce the drawings used in the embodiments or the description of the prior art, and it is obvious that, in the following description, the drawings are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a network provided herein;
FIG. 2 is a schematic flow chart of a dynamic IP address allocation method provided in the present application;
FIG. 3 is a second flow chart of the dynamic IP address allocation method provided in the present application;
FIG. 4 is a third flow chart of the dynamic IP address allocation method provided in the present application;
FIG. 5 is one of the schematics provided herein for detecting a first network node IP address collision;
FIG. 6 is a second schematic diagram of detecting an IP address collision of a first network node provided in the present application;
FIG. 7 is a flow chart of a dynamic IP address allocation method provided in the present application;
FIG. 8 is one of the schematics provided herein for detecting IP address conflicts of a second network node;
FIG. 9 is a second schematic diagram of detecting IP address collision of a second network node provided in the present application;
fig. 10 is a schematic structural diagram of a dynamic IP address allocation apparatus provided in the present application;
fig. 11 is a schematic structural diagram of an electronic device provided in the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the present application more apparent, the technical solutions in the present application will be clearly and completely described below with reference to the drawings in the present application, and it is apparent that the described embodiments are some, but not all, embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type and not limited to the number of objects, e.g., the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
Further, for the detection of the conflict of the IP address in the prior art, an ARP request message with the local IP address as the source IP address is broadcast to the local area network through the network device, the data type of the message is identified when the network message is received, the source IP address of the ARP request message is identified for the ARP message, and whether the source IP address is consistent with the local IP address is compared, so as to detect whether the conflict of the IP address exists. The method can effectively prevent the condition of connection interruption caused by IP address conflict between the network equipment and the server and the like, and improves the usability and the safety of the network equipment. However, the ARP method has a problem in that when an IP address conflict occurs, other devices except for the network device that has the conflict cannot know that the IP address conflict exists in the network in time, so that the IP conflict cannot be self-healed, and normal network communication is affected.
In a local area network, when an IP address of a network device collides with other devices (including servers, routers, general computers, etc.), network connection interruption and communication failure may be caused. As can be seen, the conventional method for detecting the conflict of the IP address has a certain limitation, and cannot timely transmit the conflict information of the IP address to other devices except the device generating the conflict.
According to the method, not only is IP address allocation realized by introducing two different protocols into the same network, but also detection of IP address conflict between network nodes can be allowed, so that comprehensive and timely detection of IP address conflict is realized, stability and reliability of network communication are improved, and network connection interruption and communication faults caused by IP address conflict are effectively prevented.
The dynamic IP address allocation method provided in the embodiment of the present application is described in detail below with reference to the accompanying drawings through specific embodiments and application scenarios thereof.
First, a network to which the embodiments of the present application are applied will be schematically described. Referring to fig. 1, a network includes a plurality of network nodes including a first network node and a second network node. The first network node performs IP address allocation through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node performs IP address allocation through a zero configuration network protocol (Zeroconf) service.
The dynamic host configuration protocol (Dynamic Host Configuration Protocol, DHCP) is a standard protocol that allows servers to dynamically allocate IP addresses and configuration information to clients.
The DHCP protocol supports a C/S (client/server) architecture, which is mainly divided into two parts:
1. DHCP client: that is, the network node, typically a terminal device such as a PC or a printer in the network, uses the IP information distributed from the DHCP server, including an IP address, DNS, and the like.
2. DHCP server: all IP network setting information is centrally managed by a DHCP server and processes DHCP requests of network nodes.
The DHCP service uses UDP as a transport protocol and the client sends a request to the 67 port of the DHCP server, which returns a response to the 68 port of the client.
Zeroconf (Zero Configuration Networking, zero configuration network) is a network configuration protocol that aims to allow network devices to automatically discover and connect to other devices in the network without any configuration, and to provide some basic network services such as IP address assignment and name resolution. With Zeroconf protocol automatic IP address allocation functionality, zero configuration network technology allows devices to automatically configure and discover services in a local area network without requiring a central configuration. When a new network node joins the network, it randomly generates an IP address for the newly added network device and broadcasts a multicast message to the network requesting other devices to respond to its presence. Other devices will also broadcast similar messages, thus creating a list of devices and informing each other of their IP addresses. In this way, dynamic allocation of IP addresses can also be accomplished without requiring a DHCP server.
As shown in fig. 2, the method for allocating a dynamic IP address according to the embodiment of the present application may include the following steps 201 to 203:
201. and under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node.
Specifically, in the case of a newly added network node in the network, it is necessary to determine whether the newly added network node belongs to the first network node or the second network node. May be based on membership of the network node.
For example, in one mode, the network is divided into a first subnet and a second subnet, the first subnet performs IP address allocation through a DHCP server, and the second subnet performs IP address allocation through a zero configuration network protocol Zeroconf service. Under the condition of the newly added network node, determining whether the newly added network node belongs to a first subnet or a second subnet, and further determining whether the newly added network node belongs to the first network node or the second network node.
In another mode, the network may be divided according to the purpose, for example, into a client network and an employee network, where the employee network is generally an internal local area network, and IP address allocation may be performed through Zeroconf service; the client network is typically a wide area network and IP address assignment may be performed through a DHCP server. Whether the newly added network node corresponds to the client ID or the employee ID is judged first, and then whether the newly added network node is classified as the first network node or the second network node is determined.
202. If the newly added network node is the first network node, a request is sent to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node, so that the DHCP server distributes an IP address for the newly added network node.
Specifically, the DHCP server stores all IP addresses of the first network node. After receiving the request of the newly added network node, the DHCP server issues a response to the newly added network node according to the request and the stored IP address, where the response carries the allocated IP address.
203. If the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service.
Specifically, when a newly added network node joins the network, zeroconf service randomly generates an IP address for the newly added network device, and broadcasts a multicast message to the second network, requesting other device nodes to respond, where the response carries the IP address of the other device nodes. In this way, each second network node knows the IP addresses of other network nodes in the network and the IP addresses of itself, so as to avoid allocation conflicts of the IP addresses.
According to the dynamic IP address allocation method provided by the embodiment of the application, IP address allocation is carried out by using two protocol services in a network, so that under the condition of newly adding a network node, the newly added network node is determined to be a first network node or a second network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is a second network node, the IP address is automatically allocated to the newly added network node through the Zeroconf service, so that the IP address allocation of different network nodes is realized, and meanwhile, the pressure of a DHCP server is relieved.
Alternatively, in the process of assigning an IP address, failure of IP address assignment may occur due to network fluctuations, equipment failure, or other human error operations. And in the case of failure of the first allocation, the second allocation can be repeated, and if the allocation is not successful after the set time length is exceeded, the failure of allocating the IP address to the newly added network node through the DHCP server or the Zeroconf service is determined. The newly added network node can be replaced by the method of the application, so that a mode of distributing the IP address is replaced. Specifically:
if the allocation of the IP address to the newly added network node by the DHCP server fails, the method further includes: the newly added network node is re-determined to be a second network node, and an IP address is distributed to the newly added network node through Zeroconf service;
if the allocation of the IP address to the newly added network node fails through Zeroconf service, the method further includes: and re-determining the newly-added network node as a first network node, and sending a request to the DHCP server through the newly-added network node so that the DHCP server distributes an IP address for the newly-added network node.
By the method, under the condition that one IP address allocation protocol is problematic, IP address allocation can be continuously carried out on the newly-added network node through the other IP address allocation protocol, so that the reliability of the network is improved.
Optionally, the IP address collision detection is performed in case that the allocation of the IP address to the newly added network node by the DHCP server is ended or the allocation of the IP address to the newly added network node by the Zeroconf service is ended. In general, the IP address assignment by the DHCP server or by Zeroconf service does not involve an IP address conflict, but in some special cases, there may be cases where an IP address conflict occurs, such as a human change, e.g., a network node is damaged and a new network node is replaced, etc.
Referring to fig. 3, the method further comprises:
301. and starting IP address conflict detection, and detecting whether a first network node or a second network node with the IP address conflict exists in the current network.
Because the first network node performs IP address allocation through the DHCP protocol and the second network node performs IP address allocation through the Zeroconf protocol, IP address conflict detection can be performed on the first network node and the second network node through corresponding protocols respectively.
In addition, detection is also required for situations where there may be an IP address collision between the first network node and the second network node. In a specific implementation method, middleware can be set between the first network and the second network, and the stored address table of the IP address of each first network node is transmitted to each second network node through the DHCP server, or the IP address of each second network node maintained in the second network node is sent to the DHCP server through the middleware, so as to realize the detection of the collision of the IP address between the first network node and the second network node.
302. If the network node with address conflict is the first network node, the new IP address is reassigned to the first network node with address conflict through the DHCP server.
Specifically, in step 302, an IP address conflict message carrying a conflict IP address is sent to a DHCP server by a current first network node having an address conflict, so that the DHCP server changes a conflict IP address of the current first network node from an available state to an unavailable state according to the IP address conflict message, and allocates a new IP address to the current first network node again.
For example, if the DHCP server detects that the IP addresses of the two first network nodes are 192.168.100.10, a response message is issued to the two first network nodes by the DHCP server to change the IP addresses of the three first network nodes to 192.168.100.11 and 192.168.100.12, the original IP addresses of the two first network nodes are set to be in an unavailable state at the DHCP server, and the changed IP addresses are set to be in an available state.
After reassigning the IP address of the row, the IP address collision detection in step 301 is repeatedly performed until there is no IP address collision.
303. And if the network node with the address conflict is a second network node, automatically reassigning a new IP address to the second network node with the address conflict through the Zeroconf service.
Specifically, in step 303, zeroconf service is restarted in the address conflicting second network node, and a new IP address is renegotiated for allocation. The reassigned IP addresses may all be different from before, or one may be the same and the other may be different. For example, the IP addresses of the two second network nodes with conflicting addresses are 192.168.0.5, then through negotiation, one of the second network nodes has an IP address of 192.168.0.6, and the other second network node has an IP address of 192.168.0.7; it is also possible that one of the second network nodes maintains an IP address of 192.168.0.5 and the other second network node maintains an IP address of 192.168.0.6.
After reassigning the IP address of the row, the IP address collision detection in step 301 is repeatedly performed until there is no IP address collision.
Through the steps 301 to 303, the IP address conflict can be accurately detected and prevented, the condition that the same IP address exists with other equipment can be timely found, and network connection interruption and communication faults caused by the IP address conflict are avoided.
Further, referring to fig. 4, for each current first network node, step 301 includes:
401. and generating a first address conflict detection message, sending the first address conflict detection message to the adjacent first network node, and receiving the first address conflict detection message sent by the adjacent first network node.
The first address conflict detection message includes: a type field T, a length field L, and a value field V including an IP address field therein.
Among them, 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.
The TLV consists of three parts:
type (type): specifying the type or identifier of the data. It is typically represented by a fixed-size integer or identifier that identifies the meaning and format of the data.
Length (length): the length of the data portion is specified. It indicates the number of bytes or elements of the Value field, which may be of fixed or variable length.
Value (value): the actual data content. It is structured data parsed according to the format defined by Type and Length.
The TLV is designed to provide a flexible and scalable way to transfer data. It can accommodate different types and lengths of data and can easily expand and add new data types. Due to the versatility and flexibility of TLVs, it is widely used in many network protocols and applications.
In practical applications, TLVs are often used for metadata transmission, configuration information representation, parameter delivery, protocol extension, and the like. It provides a generic data encoding and decoding mechanism enabling the understanding and processing of TLV formatted data between different network nodes.
402. And resolving the received first address conflict detection message to obtain an IP address field.
403. Comparing the IP address of the adjacent first network node with the IP address of the current first network node, if not, executing step 404, and if not, executing step 405.
404. And determining that the adjacent first network node corresponding to the IP address does not have IP address conflict with the current first network node.
405. And determining that the adjacent first network node corresponding to the IP address has IP address conflict with the current first network node.
Through steps 401 to 405, it can be implemented to detect whether there is a first network node with an IP address conflict in the current network.
According to the technical scheme, the TLV field based on LLDP can accurately detect and prevent IP address conflict. The method can discover the condition that the same IP address exists in the network node in time, and avoid network connection interruption and communication failure caused by IP address conflict.
Referring to fig. 5 and 6, fig. 5 includes 5 first network nodes A, B, C, D and E, where E is a newly added network node. The first network node E transmits a first address collision detection message to the neighboring first network node A, B, C to detect whether an IP address collision exists. After parsing, the first network node E determines that the IP address of the first network node a is 192.168.1.5, and then the first network node E sends an IP address collision message carrying the collision IP address to the DHCP server, so that the DHCP server allocates a new IP address 192.168.1.4 to the first network node E again, as shown in fig. 6.
Referring to fig. 7, for each current second network node, step 301 includes:
701. and generating a second address conflict detection message, transmitting the second address conflict detection message to other second network nodes in a group mode, and receiving the second address conflict detection message transmitted by the other second network nodes.
The second address conflict detection message includes: an IP address.
702. And resolving the received second address conflict detection message to obtain an IP address field.
703. Comparing the IP addresses of the other second network nodes with the IP address of the current second network node, if not, executing step 704, and if not, executing step 705.
704. And determining that other second network nodes corresponding to the IP address do not have IP address conflict with the current second network node.
705. And determining that other second network nodes corresponding to the IP address have IP address conflict with the current second network node.
Through steps 701-705, it may be achieved that the second network node in the current network is detected if there is an IP address collision.
Referring to fig. 8 and 9, fig. 8 includes 5 second network nodes F, G, H, I and M, where M is a newly added second network node. And receiving second address conflict detection messages sent by other 4 nodes through the second network node M, analyzing the received second address conflict detection messages to obtain IP address fields, and comparing the IP addresses of the other 4 second network nodes with the IP address of the second network node M. The comparison shows that the IP addresses of the second network node M and I are the same, and are 192.168.2.4. The second network nodes M and I are reassigned new IP addresses 192.168.2.5 and 192.168.2.6 by Zeroconf services.
By the method of the embodiment of the application, the following effects can be achieved:
1. the usability and the reliability of the network computer are improved: by the technical scheme of the embodiment of the invention, the network node can avoid connection interruption caused by IP address conflict with other network nodes. This improves the ease of use of the network node, and the user does not have to worry about the unstable and interruption situation caused by the collision of the IP address, thereby improving the reliability of the network.
2. The burden of an administrator is reduced: dynamic IP address allocation reduces the workload of an administrator, and the system automatically carries out IP address management and conflict prevention, thereby improving the management efficiency.
3. Dynamic IP address assignment: by introducing an intelligent dynamic IP address allocation mechanism, the system automatically allocates IP addresses according to the actual network topology structure and the equipment connection state, and potential errors and conflicts caused by manual allocation are avoided.
4. Real-time IP address collision detection and handling: according to the scheme, the DHCP server, the Zeroconf service and the TLV field are used, so that IP address conflict can be detected in real time, and corresponding prompt and processing measures can be timely adopted. This ensures that an IP address collision can be quickly found and necessary measures are taken to resolve the collision, avoiding occurrence of communication failure. An administrator may customize the IP address allocation policies according to network configuration requirements, and the system provides flexibility and personalized configuration options.
It should be noted that, in the dynamic IP address allocation method provided in the embodiments of the present application, the execution body may be a dynamic IP address allocation device, or a control module in the dynamic IP address allocation device for executing the dynamic IP address allocation method. In the embodiment of the present application, a dynamic IP address allocation device executes a dynamic IP address allocation method as an example, and the dynamic IP address allocation device provided in the embodiment of the present application is described.
In the embodiment of the present application, the dynamic IP address allocation methods shown in the foregoing method drawings are all exemplified by a drawing in combination with one of the embodiments of the present application. In specific implementation, the dynamic IP address allocation method shown in the foregoing method drawings may also be implemented in combination with any other drawing that may be combined and is illustrated in the foregoing embodiment, which is not repeated herein.
The dynamic IP address allocation apparatus provided in the present application is described below, and the dynamic IP address allocation method described below and the dynamic IP address allocation method described above may be referred to correspondingly to each other.
Fig. 10 is a schematic structural diagram of a dynamic IP address allocation apparatus provided in an embodiment of the present application, where the network nodes of the network include a first network node and a second network node, where the first network node performs IP address allocation through a dynamic host configuration protocol DHCP server, and the second network node performs IP address allocation through a zero configuration network protocol Zeroconf service. As shown in fig. 10, specifically, the method includes:
a determining module 1001, configured to determine, in a case of a newly added network node, that the newly added network node is a first network node or a second network node according to membership of the newly added network node;
A first address allocation module 1002, configured to send a request to a DHCP server through a newly added network node if the newly added network node is the first network node, so that the DHCP server allocates an IP address for the newly added network node;
and the second address allocation module 1003 is configured to, if the newly added network node is a second network node, automatically allocate an IP address to the newly added network node through Zeroconf service.
Optionally, the apparatus further comprises:
a reassignment module, configured to, if the assignment of the IP address to the newly added network node by the DHCP server fails, redetermine the newly added network node to be a second network node, and assign the IP address to the newly added network node by Zeroconf service;
if the IP address allocation for the newly-added network node fails through the Zeroconf service, the newly-added network node is re-determined to be the first network node, and a request is sent to a Dynamic Host Configuration Protocol (DHCP) server through the newly-added network node, so that the DHCP server allocates the IP address for the newly-added network node.
Optionally, the apparatus further comprises:
the conflict detection module is used for starting IP address conflict detection and detecting whether a first network node or a second network node with IP address conflict exists in the current network under the condition that the IP address distribution for the newly-added network node is finished through a DHCP server or the IP address distribution for the newly-added network node is finished through a Zeroconf service;
The first conflict processing module is used for reallocating a new IP address for the first network node with the address conflict through the DHCP server if the network node with the address conflict is the first network node;
and the second conflict processing module is used for automatically reassigning a new IP address to the address conflict second network node through Zeroconf service if the address conflict second network node exists.
Optionally, the conflict detection module is specifically configured to:
for each current first network node, generating a first address conflict detection message, sending the first address conflict detection message to adjacent first network nodes, and receiving the first address conflict detection message sent by the adjacent first network nodes, wherein the first address conflict detection message comprises: a type field, a length field, and a value field, wherein the value field includes an IP address field;
analyzing the received first address conflict detection message to obtain an IP address field;
comparing the IP addresses of the adjacent first network nodes with the IP addresses of the current first network nodes, and if the IP addresses are different, determining that the adjacent first network nodes corresponding to the IP addresses do not have IP address conflict with the current first network nodes; if the IP addresses are the same, determining that the adjacent first network node corresponding to the IP addresses conflicts with the current first network node;
For each current second network node, generating a second address conflict detection message, transmitting the second address conflict detection message to other second network nodes in groups, and receiving the second address conflict detection message transmitted by the other second network nodes, wherein the second address conflict detection message comprises: an IP address;
analyzing the received second address conflict detection message to obtain an IP address field;
comparing the IP addresses of other second network nodes with the IP addresses of the current second network node, and if the IP addresses are different, determining that the other second network nodes corresponding to the IP addresses do not have IP address conflict with the current second network node; if the second network node and the current second network node are the same, determining that other second network nodes corresponding to the IP address have IP address conflict with the current second network node.
Optionally, the first conflict processing module is specifically configured to: and sending an IP address conflict message carrying the conflict IP address to a DHCP server through the current first network node with address conflict, so that the DHCP server changes the conflict 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.
Optionally, the second conflict processing module is specifically configured to: restarting Zeroconf service in the second network node with the address conflict, and renegotiating to allocate a new IP address.
According to the dynamic IP address allocation device, IP address allocation is carried out by using two protocol services in the network, so that under the condition of newly adding a network node, the newly added network node is determined to be a first network node or a second network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is a second network node, the IP address is automatically allocated to the newly added network node through the Zeroconf service, so that the IP address allocation of different network nodes is realized, and meanwhile, the pressure of a DHCP server is relieved.
Fig. 11 illustrates a physical structure diagram of an electronic device, as shown in fig. 11, which may include: processor 1110, communication interface Communications Interface 1120, memory 1130 and communication bus 1140, wherein processor 1110, communication interface 1120 and memory 1130 communicate with each other via communication bus 1140. Processor 1110 may invoke logic instructions in memory 1130 to perform a dynamic IP address allocation method comprising: under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service.
Further, the logic instructions in the memory 1130 described above may be implemented in the form of software functional units and sold or used as a stand-alone product, stored on a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
In another aspect, the present application also provides a computer program product comprising a computer program stored on a computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the dynamic IP address allocation method provided by the above methods, the method comprising: under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service.
In yet another aspect, the present application further provides a computer readable storage medium having stored thereon a computer program which when executed by a processor is implemented to perform the dynamic IP address allocation methods provided above, the method comprising: under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node; if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node; if the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions.

Claims (10)

1. The dynamic IP address allocation method is characterized by comprising a first network node and a second network node, wherein the network node of the network comprises the first network node and the second network node, the first network node allocates the IP address through a Dynamic Host Configuration Protocol (DHCP) server, and the second network node allocates the IP address through a zero configuration network protocol (Zeroconf) service;
the method comprises the following steps:
under the condition of the newly added network node, determining the newly added network node as a first network node or a second network node according to the membership of the newly added network node;
if the newly added network node is the first network node, sending a request to a Dynamic Host Configuration Protocol (DHCP) server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node;
if the newly added network node is the second network node, the IP address is automatically distributed to the newly added network node through the Zeroconf service.
2. The method of claim 1, wherein if the assignment of the IP address to the newly added network node by the DHCP server fails, the method further comprises: the newly added network node is re-determined to be a second network node, and an IP address is distributed to the newly added network node through Zeroconf service;
If the allocation of the IP address to the newly added network node fails through Zeroconf service, the method further includes: and re-determining the newly added network node as a first network node, and sending a request to the DHCP server through the newly added network node so that the DHCP server distributes an IP address for the newly added network node.
3. The method according to claim 1, wherein in case the assignment of an IP address to a newly added network node by a DHCP server ends or the assignment of an IP address to the newly added network node by Zeroconf service ends, the method further comprises:
starting IP address conflict detection, and detecting whether a first network node or a second network node with IP address conflict exists in the current network;
if the network node with address conflict is the first network node, reallocating a new IP address for the first network node with address conflict through the DHCP server;
and if the network node with the address conflict is a second network node, automatically reassigning a new IP address to the second network node with the address conflict through the Zeroconf service.
4. A method according to claim 3, wherein initiating an IP address collision detection, detecting whether an IP address collision exists in the current network, the first network node or the second network node, comprises:
For each current first network node, generating a first address conflict detection message, sending the first address conflict detection message to adjacent first network nodes, and receiving the first address conflict detection message sent by the adjacent first network nodes, wherein the first address conflict detection message comprises: a type field, a length field, and a value field, wherein the value field includes an IP address field;
analyzing the received first address conflict detection message to obtain an IP address field;
comparing the IP addresses of the adjacent first network nodes with the IP addresses of the current first network nodes, and if the IP addresses are different, determining that the adjacent first network nodes corresponding to the IP addresses do not have IP address conflict with the current first network nodes; if the IP addresses are the same, determining that the adjacent first network node corresponding to the IP addresses conflicts with the current first network node;
for each current second network node, generating a second address conflict detection message, transmitting the second address conflict detection message to other second network nodes in groups, and receiving the second address conflict detection message transmitted by the other second network nodes, wherein the second address conflict detection message comprises: an IP address;
analyzing the received second address conflict detection message to obtain an IP address field;
Comparing the IP addresses of other second network nodes with the IP addresses of the current second network node, and if the IP addresses are different, determining that the other second network nodes corresponding to the IP addresses do not have IP address conflict with the current second network node; if the second network node and the current second network node are the same, determining that other second network nodes corresponding to the IP address have IP address conflict with the current second network node.
5. The method according to claim 4, wherein if the network node having the address conflict is the first network node, reassigning the new IP address to the first network node having the address conflict through the DHCP server, specifically comprising:
and sending an IP address conflict message carrying the conflict IP address to a DHCP server through the current first network node with address conflict, so that the DHCP server changes the conflict 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.
6. The method according to claim 4, wherein if there is a network node with an address conflict as a second network node, automatically reassigning a new IP address to the address conflict second network node through Zeroconf service, specifically comprising:
Restarting Zeroconf service in the second network node with the address conflict, and renegotiating to allocate a new IP address.
7. The dynamic IP address allocation device is characterized by being used for a network, wherein a network node of the network comprises 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) service;
the device comprises:
the determining module is used for determining whether the newly added network node is a first network node or a second network node according to the membership of the newly added network node under the condition of the newly added network node;
the first address allocation module is used for sending 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 for the newly added network node;
and the second address allocation module is used for automatically allocating 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 of claim 7, wherein the apparatus further comprises:
A reassignment module, configured to, if the assignment of the IP address to the newly added network node by the DHCP server fails, redetermine the newly added network node to be a second network node, and assign the IP address to the newly added network node by Zeroconf service;
if the IP address allocation for the newly-added network node fails through the Zeroconf service, the newly-added network node is re-determined to be the first network node, and a request is sent to a Dynamic Host Configuration Protocol (DHCP) server through the newly-added network node, so that the DHCP server allocates the IP address for the newly-added network node.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the steps of the dynamic IP address allocation method of any one of claims 1 to 6 when the program is executed by the processor.
10. A computer readable storage medium, having stored thereon a computer program which, when executed by a processor, implements the steps of the dynamic IP address allocation method according to any of claims 1 to 6.
CN202311811850.5A 2023-12-26 2023-12-26 Dynamic IP address allocation method and device Pending CN117793057A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311811850.5A CN117793057A (en) 2023-12-26 2023-12-26 Dynamic IP address allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311811850.5A CN117793057A (en) 2023-12-26 2023-12-26 Dynamic IP address allocation method and device

Publications (1)

Publication Number Publication Date
CN117793057A true CN117793057A (en) 2024-03-29

Family

ID=90382797

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311811850.5A Pending CN117793057A (en) 2023-12-26 2023-12-26 Dynamic IP address allocation method and device

Country Status (1)

Country Link
CN (1) CN117793057A (en)

Similar Documents

Publication Publication Date Title
CN101951417B (en) Method, system and trunk equipment for assigning multiple server addresses
US10122679B2 (en) Method, relay agent, and system for acquiring internet protocol address in network
US5835723A (en) Dynamic assignment of multicast addresses
US20160080483A1 (en) Method for setting gateway device identity, and management gateway device
KR100689734B1 (en) method and apparatus for allocating address in wireless network
US9882802B2 (en) Auto management of a virtual device context enabled network infrastructure
US20120221700A1 (en) System, Method and Program for Telecom Infrastructure Virtualization and Management
CN108989476B (en) Address allocation method and device
CN101883158A (en) Method and client for acquiring VLAN (Virtual Local Area Network) IDs (Identifiers) and network protocol addresses
US20150113168A1 (en) Network Bridging
CN108429824B (en) Address allocation method and device
US20180054415A1 (en) Internet Protocol Address Allocation Method and Router
US9503418B2 (en) Method and apparatus for obtaining remote IP address
CN112689029A (en) Method, device and equipment for acquiring IP address of group user
CN102025797A (en) Address prefix processing method, device, system and network equipment
CN117793057A (en) Dynamic IP address allocation method and device
CN113660357B (en) Method and device for automatically acquiring IP address by IPv6 dual stack system
CN115174528A (en) Equipment address control method, device and system
EP4216510A1 (en) Method for acquiring address, apparatus and system
CN113194119B (en) Configuration file acquisition method and device
CN111343296B (en) Virtualized application communication method, device, server and storage medium
CN111654390B (en) Data transmission method, device, terminal equipment and storage medium
CN107786682B (en) Method and device for processing DHCP REQUEST message
KR100977399B1 (en) Method and apparatus of processing DHCP packet in dynamic IP address allocation for reducing network load
CN107770070B (en) Information transmission method, equipment and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination