CN115174525A - Method and device for allocating equipment IP addresses - Google Patents

Method and device for allocating equipment IP addresses Download PDF

Info

Publication number
CN115174525A
CN115174525A CN202210770669.3A CN202210770669A CN115174525A CN 115174525 A CN115174525 A CN 115174525A CN 202210770669 A CN202210770669 A CN 202210770669A CN 115174525 A CN115174525 A CN 115174525A
Authority
CN
China
Prior art keywords
address
static
dynamic
target device
addresses
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.)
Granted
Application number
CN202210770669.3A
Other languages
Chinese (zh)
Other versions
CN115174525B (en
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.)
Beijing Baiyou Technology Co ltd
Original Assignee
Beijing Baiyou 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 Beijing Baiyou Technology Co ltd filed Critical Beijing Baiyou Technology Co ltd
Priority to CN202210770669.3A priority Critical patent/CN115174525B/en
Publication of CN115174525A publication Critical patent/CN115174525A/en
Application granted granted Critical
Publication of CN115174525B publication Critical patent/CN115174525B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The disclosure relates to the technical field of communication, and provides a method and a device for allocating an equipment IP address. The method comprises the following steps: acquiring a dynamic IP address network segment; based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices; setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device; performing IP collision detection processing on the first static IP addresses of all the devices in the target device group; if the dynamic IP address is failed to be allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool; and performing the IP collision detection processing on the second static IP addresses of all the devices in the target device group.

Description

Method and device for allocating equipment IP addresses
Technical Field
The present disclosure relates to the field of communications technologies, and in particular, to a method and an apparatus for allocating an IP address of a device.
Background
In order to provide more intelligent services for people, a lot of monitoring devices are deployed on a building at present, security personnel of the building can also carry an interphone (the building with many kinds of devices deployed is called as a digital building) … …, so that each device in the building needs to be assigned with an IP address for facilitating management of the monitoring devices, the interphone and other devices in the building, and the IP address assigned to the device is the best static IP address for facilitating monitoring of each device in the building. Currently, dynamic IP addresses can be automatically assigned, but static IP addresses can only be assigned manually.
In the course of implementing the disclosed concept, the inventors found that there are at least the following technical problems in the related art: in digital buildings, assigning static IP addresses to devices is a problem that can only be assigned manually.
Disclosure of Invention
In view of this, embodiments of the present disclosure provide a method and an apparatus for allocating an IP address of a device, so as to solve the problem in the prior art that allocating a static IP address to a device in a digital building can only be manually allocated.
In a first aspect of the embodiments of the present disclosure, a method for allocating an IP address of a device is provided, including: acquiring a dynamic IP address network segment, wherein the dynamic IP address network segment comprises a plurality of dynamic IP addresses; based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices; setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device; performing IP collision detection processing on the first static IP addresses of all the devices in the target device group; if the dynamic IP address is unsuccessfully allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool; and performing the IP collision detection processing on the second static IP addresses of all the devices in the target device group.
In a second aspect of the embodiments of the present disclosure, an apparatus for allocating an IP address of a device is provided, including: the system comprises an acquisition module, a processing module and a control module, wherein the acquisition module is configured to acquire a dynamic IP address network segment, and the dynamic IP address network segment comprises a plurality of dynamic IP addresses; an allocation module configured to allocate the dynamic IP address to each device in a target device group based on the dynamic IP address network segment by using a dynamic host configuration protocol, wherein the target device group includes a plurality of devices; the setting module is configured to set the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device; a first processing module configured to perform IP collision detection processing on first static IP addresses of all devices in the target device group; a generation module configured to randomly generate a second static IP address for each device in the target device group from a pool of static IP addresses if the allocation of the dynamic IP address to each device in the target device group fails; a second processing module configured to perform the IP collision detection processing on the second static IP addresses of all the devices in the target device group.
In a third aspect of the embodiments of the present disclosure, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the above method when executing the computer program.
In a fourth aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, which stores a computer program, which when executed by a processor, implements the steps of the above-mentioned method.
Compared with the prior art, the embodiment of the disclosure has the following beneficial effects: because the embodiment of the present disclosure obtains the dynamic IP address network segment, wherein the dynamic IP address network segment includes a plurality of dynamic IP addresses; based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices; setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device; performing IP collision detection processing on the first static IP addresses of all the devices in the target device group; if the dynamic IP address is failed to be allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool; and performing the IP conflict detection processing on the second static IP addresses of all the devices in the target device group, so that the technical means can solve the problem that the static IP addresses allocated to the devices in the digital building in the prior art can only be allocated manually, further improve the efficiency of allocating the static IP addresses in the digital building and reduce the cost.
Drawings
To more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings needed for the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without inventive efforts.
FIG. 1 is a scenario diagram of an application scenario of an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a method for allocating an IP address of a device according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of an apparatus for allocating an IP address of a device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the disclosed embodiments. However, it will be apparent to one skilled in the art that the present disclosure may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present disclosure with unnecessary detail.
A method and apparatus for allocating an IP address of a device according to an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.
Fig. 1 is a scene schematic diagram of an application scenario of an embodiment of the present disclosure. The application scenario may include a server 101, a computer 102, and a device cluster 103.
The server 101 and the computer 102 may be hardware or software running thereon. It should be noted that, the device cluster 103 includes a plurality of devices, and only one of the server 101 and the computer 102 is required to complete the assignment of the IP addresses of the devices in the device cluster 103.
Fig. 2 is a schematic flowchart of a method for allocating an IP address of a device according to an embodiment of the present disclosure. The method of assigning device IP addresses of fig. 2 may be performed by the computer or server of fig. 1, or software on the computer or server (the software being a tool for testing smart helmets). As shown in fig. 2, the method for allocating an IP address of a device includes:
s201, acquiring a dynamic IP address network segment, wherein the dynamic IP address network segment comprises a plurality of dynamic IP fields;
s202, based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices;
s203, setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device;
s204, IP collision detection processing is carried out on the first static IP addresses of all the devices in the target device group;
s205, if the dynamic IP address is unsuccessfully allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool;
s206, the IP conflict detection processing is carried out on the second static IP addresses of all the devices in the target device group.
The embodiment of the disclosure is applied to an equipment management center, which runs on a server and is used for managing a plurality of pieces of equipment of a target equipment group, and allocates the dynamic IP address to each piece of equipment by using a dynamic host configuration protocol, or randomly generates a second static IP address for each piece of equipment from a static IP address pool when allocation of the dynamic IP address to each piece of equipment fails. DHCP (dynamic host configuration protocol) is a network protocol for a local area network. The method is characterized in that a server controls a range of IP addresses, and a client can automatically obtain the IP address and the subnet mask allocated by the server when logging in the server.
The disclosed embodiments are applied to the scene of a digital building (the building is provided with a plurality of devices such as monitoring devices and interphones), and the target device group can be all the devices in the digital building.
And setting the dynamic IP address allocated to each device as a static IP, namely, the dynamic IP address allocated to each device is not subject to the dynamic host configuration protocol, and fixing the dynamic IP address allocated to each device, thereby obtaining a first static IP address of each device.
And the IP conflict detection processing is used for detecting whether the first static IP addresses or the second static IP addresses of all the devices in the target device group have IP conflicts or not, and if the IP conflicts exist, redistributing the first static IP addresses or the second static IP addresses to the devices with the IP conflicts.
Because the dynamic IP address changes frequently, the dynamic IP address of the device changes every time the device connects to the network, which is not beneficial for monitoring the device, and the static IP address is a permanent address assigned to the device, and the static IP address of the device does not change every time the device connects to the network, which is not beneficial for monitoring the device.
According to the technical scheme provided by the embodiment of the disclosure, a dynamic IP address network segment is obtained, wherein the dynamic IP address network segment comprises a plurality of dynamic IP addresses; based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices; setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device; performing IP collision detection processing on the first static IP addresses of all the devices in the target device group; if the dynamic IP address is failed to be allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool; and performing the IP conflict detection processing on the second static IP addresses of all the devices in the target device group, so that the technical means can solve the problem that the static IP addresses allocated to the devices in the digital building in the prior art can only be allocated manually, further improve the efficiency of allocating the static IP addresses in the digital building and reduce the cost.
Before step S201 is executed, that is, before a dynamic IP address network segment is obtained, where the dynamic IP address network segment includes a plurality of dynamic IP addresses, the method further includes: dividing the dynamic IP address network segment, the static IP address network segment and other IP address network segments by using an object program; and generating the static IP address pool based on a static IP address network segment, wherein the static IP address network segment comprises a plurality of second static IP addresses.
Before the target program is used to divide the dynamic IP address network segment, the static IP address network segment and other IP address network segments, some data that is set in advance, such as the type of the IP address, the network number and the subnet mask, should be acquired.
For example, the following steps are carried out: the type of the IP address is class B, the network number is 172.20, and the subnet mask is 255.255.0.0 (class B IP address, in the four segments of the IP address, the first two segments are network numbers, and the second two segments are device numbers). Then the range of IP addresses that can be partitioned is 172.20.0.1-172.20.254.254. 172.20.4.1-172.20.50.254 are dynamic IP address segments, 172.20.51.1-1272.20.254.254 are static IP address segments, and 172.20.0.1-172.20.3.254 are other IP address segments.
Optionally, the IP addresses in other IP address network segments may be used as a specific scenario, and the IP addresses in other IP address network segments may be configured according to the received IP address configuration instruction.
The target program can divide the dynamic IP address network segment, the static IP address network segment and other IP address network segments according to a preset proportion. Optionally, the static IP address pool may not be generated according to a static IP address network segment, and a second static IP address may be randomly generated for each device in the target device group directly from the static IP address network segment. The static IP address pool is generated according to the static IP address network segment because the randomness of the static IP address pool is better.
In step S204, performing IP collision detection processing on the first static IP addresses of all devices in the target device group, including: when IP conflict exists, based on the dynamic IP address network segment, reallocating the dynamic IP address to each first target device in a target device group by using a dynamic host configuration protocol, wherein the first target device is a device of which the first static IP address has IP conflict; setting the dynamic IP address reassigned to each first target device as the static IP to update the first static IP address of each first target device.
The number of devices with IP collisions should be equal to or greater than two. If at least two devices in the target device group have IP conflicts, that is, at least two devices in the target device group have the same IP address, it is impossible to distinguish the devices having the same IP address, and it is also impossible to separately manage and operate the devices having the same IP address. For example, two devices have the same IP address, and either both devices are controlled together or both devices are not controlled, and one of the devices cannot be controlled independently.
Reallocating the dynamic IP address for each first target device in the target device group by using a dynamic host configuration protocol; setting the dynamic IP address reassigned to each first target device as the static IP to update the first static IP address of each first target device. The dynamic IP address reassigned to each device is set as a static IP, that is, the dynamic IP address reassigned to each device is not subject to the dynamic host configuration protocol, and the dynamic IP address reassigned to each device is fixed, so that the first static IP address of each device is finally obtained.
In step S206, the performing the IP collision detection processing on the second static IP addresses of all the devices in the target device group includes: and when the IP conflict exists, randomly generating the second static IP address again for each second target device in the target device group from the static IP address pool, wherein the second target device is a device with the IP conflict existing in the second static IP address.
IP collision detection processing, comprising: acquiring a target log for distributing or generating IP addresses for all the devices in the target device group, wherein the IP addresses comprise: the first static IP address and the second static IP address; determining whether an IP conflict exists based on the target log.
The execution subject of the embodiment of the present disclosure is an equipment management center, and in the process of allocating or generating IP addresses for all the equipment in the target equipment group, the equipment management center may obtain a target log recording the process of generating IP addresses, and may determine whether an IP conflict exists according to the target log. For example, when the device management center allocates or generates an IP address for the 5 th device in the target device group, an "error on setting up interface 0:" appears in the target log, which indicates that the IP address of the 5 th device in the target device group and one of the 1 st to 4 th devices in the target device group are duplicated. By comparing the IP address of each device, a device that duplicates the IP address of the 5 th device can be specified.
IP collision detection processing, comprising: enabling all devices in the target device group to carry out interaction once, and acquiring all traffic in the interaction through traffic acquisition devices in the interaction, wherein each device can send out at least one traffic in the interaction; analyzing the collected flow to obtain an IP address and an MAC address of each device, wherein the IP address comprises: the first static IP address and the second static IP address; when one IP address corresponds to a plurality of MAC addresses, it is determined that an IP collision exists.
The method may include that all the devices in the target device group perform one-time interaction, and all the devices in the target device group send one message to a device management center, where one message is one flow. The flow collection equipment is arranged in the equipment management center, or the flow collection equipment provides flow collection service for the equipment management center. And analyzing each message to obtain the IP address and the MAC address carried by each message, and determining that IP conflict exists if one IP address corresponds to a plurality of MAC addresses. Since the IP address of each device is assigned by the device management center, the device management center knows the IP address of each device, and determines the device with the IP conflict when determining the IP address with the IP conflict.
In step S205, if the dynamic IP address fails to be allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool, including: when each device is not allocated or acquires the dynamic IP address within preset time, and it is determined that the allocation of the dynamic IP address for each device in the target device group fails, the second static IP address is randomly generated for each device in the target device group from the static IP address pool.
Optionally, when a specific device does not allocate or acquire the dynamic IP address within a preset time, the second static IP address is randomly generated for the specific device from the static IP address pool.
All the above optional technical solutions may be combined arbitrarily to form optional embodiments of the present application, and are not described in detail herein.
The following are embodiments of the disclosed apparatus that may be used to perform embodiments of the disclosed methods. For details not disclosed in the embodiments of the apparatus of the present disclosure, refer to the embodiments of the method of the present disclosure.
Fig. 3 is a schematic diagram of an apparatus for allocating an IP address of a device according to an embodiment of the present disclosure. As shown in fig. 3, the apparatus for allocating an IP address of a device includes:
an obtaining module 301 configured to obtain a dynamic IP address network segment, where the dynamic IP address network segment includes a plurality of dynamic IP addresses;
an allocating module 302 configured to allocate the dynamic IP address to each device in a target device group based on the dynamic IP address network segment by using a dynamic host configuration protocol, wherein the target device group includes a plurality of devices;
a setting module 303, configured to set the dynamic IP address allocated to each device as a static IP, to obtain a first static IP address of each device;
a first processing module 304, configured to perform IP collision detection processing on first static IP addresses of all devices in the target device group;
a generating module 305 configured to randomly generate a second static IP address for each device in the target device group from a pool of static IP addresses if the assigning of the dynamic IP address to each device in the target device group fails;
a second processing module 306, configured to perform the IP collision detection processing on the second static IP addresses of all the devices in the target device group.
The embodiment of the disclosure is applied to an equipment management center, which runs on a server and is used for managing a plurality of pieces of equipment of a target equipment group, and allocates the dynamic IP address to each piece of equipment by using a dynamic host configuration protocol, or randomly generates a second static IP address for each piece of equipment from a static IP address pool when allocation of the dynamic IP address to each piece of equipment fails. DHCP (dynamic host configuration protocol) is a network protocol for a local area network. The method is characterized in that a server controls a range of IP addresses, and a client can automatically obtain the IP address and the subnet mask allocated by the server when logging in the server.
The disclosed embodiments are applied to the scene of a digital building (the building deploys a plurality of devices such as monitoring devices and interphones), and the target device group can be all the devices in the digital building.
And setting the dynamic IP address allocated to each device as a static IP, namely, the dynamic IP address allocated to each device is not subject to the dynamic host configuration protocol, and fixing the dynamic IP address allocated to each device, thereby obtaining a first static IP address of each device.
And the IP conflict detection processing is used for detecting whether the first static IP addresses or the second static IP addresses of all the devices in the target device group have IP conflicts or not, and if the IP conflicts exist, redistributing the first static IP addresses or the second static IP addresses to the devices with the IP conflicts.
Because the dynamic IP address changes frequently, the dynamic IP address of the device changes every time the device connects to the network, which is not beneficial for monitoring the device, and the static IP address is a permanent address assigned to the device, and the static IP address of the device does not change every time the device connects to the network, which is not beneficial for monitoring the device.
According to the technical scheme provided by the embodiment of the disclosure, a dynamic IP address network segment is obtained, wherein the dynamic IP address network segment comprises a plurality of dynamic IP addresses; based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices; setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device; performing IP collision detection processing on the first static IP addresses of all the devices in the target device group; if the dynamic IP address is unsuccessfully allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool; and performing the IP conflict detection processing on the second static IP addresses of all the devices in the target device group, so that the technical means can solve the problem that the static IP addresses allocated to the devices in the digital building in the prior art can only be allocated manually, further improve the efficiency of allocating the static IP addresses in the digital building and reduce the cost.
Optionally, the obtaining module 301 is further configured to divide the dynamic IP address network segment, the static IP address network segment, and other IP address network segments by using an object program; and generating the static IP address pool based on a static IP address network segment, wherein the static IP address network segment comprises a plurality of second static IP addresses.
Before the dynamic IP address network segment, the static IP address network segment, and other IP address network segments are divided by the target program, some data set in advance, such as the type of the IP address, the network number, and the subnet mask, should be acquired.
For example, the following steps are carried out: the type of the IP address is class B, the network number is 172.20, and the subnet mask is 255.255.0.0 (class B IP address, in the four segments of the IP address, the first two segments are network numbers, and the last two segments are device numbers). Then the range of IP addresses that can be partitioned is 172.20.0.1-172.20.254.254. 172.20.4.1-172.20.50.254 are dynamic IP address segments, 172.20.51.1-1272.20.254.254 are static IP address segments, and 172.20.0.1-172.20.3.254 are other IP address segments.
Optionally, the IP addresses in other IP address network segments may be used as a specific scenario, and the IP addresses in other IP address network segments may be configured according to the received IP address configuration instruction.
The target program can divide the dynamic IP address network segment, the static IP address network segment and other IP address network segments according to a preset proportion. Optionally, the static IP address pool may not be generated according to a static IP address network segment, and a second static IP address may be randomly generated for each device in the target device group directly from the static IP address network segment. The static IP address pool is generated according to the static IP address network segment because the randomness of the static IP address pool is better.
Optionally, the first processing module 304 is further configured to, in step S204, perform IP collision detection processing on the first static IP addresses of all the devices in the target device group, where the processing includes: when IP conflict exists, based on the dynamic IP address network segment, reallocating the dynamic IP address to each first target device in a target device group by using a dynamic host configuration protocol, wherein the first target device is a device of which the first static IP address has IP conflict; setting the dynamic IP address reassigned to each first target device as the static IP to update the first static IP address of each first target device.
The number of devices with IP collisions should be equal to or greater than two. If at least two devices in the target device group have IP conflicts, that is, at least two devices in the target device group have the same IP address, it is impossible to distinguish the devices having the same IP address, and it is also impossible to separately manage and operate the devices having the same IP address. For example, two devices have the same IP address, and either both devices are controlled together or both devices are not controlled, and one of the devices cannot be controlled independently.
Reallocating the dynamic IP address to each first target device in the target device group by using a dynamic host configuration protocol; setting the dynamic IP address reassigned to each first target device as the static IP to update the first static IP address of each first target device. The dynamic IP address reassigned to each device is set as a static IP, that is, the dynamic IP address reassigned to each device is not subject to the dynamic host configuration protocol, and the dynamic IP address reassigned to each device is fixed, so that the first static IP address of each device is finally obtained.
Optionally, the second processing module 306 is further configured to, when there is an IP collision, randomly generate the second static IP address again for each second target device in the target device group from the static IP address pool, where the second target device is a device whose second static IP address has an IP collision.
Optionally, the first processing module 304 or the second processing module 306 is further configured to obtain a target log for allocating or generating IP addresses for all devices in the target device group, where the IP addresses include: the first static IP address and the second static IP address; determining whether an IP conflict exists based on the target log.
The execution subject of the embodiment of the present disclosure is an equipment management center, and in the process of allocating or generating IP addresses for all the equipment in the target equipment group, the equipment management center may obtain a target log recording the process of generating IP addresses, and may determine whether an IP conflict exists according to the target log. For example, when the device management center allocates or generates an IP address for the 5 th device in the target device group, an "error on setting up interface 0:" appears in the target log, which indicates that the IP address of the 5 th device in the target device group and one of the 1 st to 4 th devices in the target device group are duplicated. By comparing the IP address of each device, a device that duplicates the IP address of the 5 th device can be specified.
Optionally, the first processing module 304 or the second processing module 306 is further configured to enable all devices in the target device group to perform interaction once, and collect all traffic in the interaction through a traffic collection device during the interaction, where each device sends out at least one traffic in the interaction; analyzing the collected flow to obtain an IP address and an MAC address of each device, wherein the IP address comprises: the first static IP address and the second static IP address; when one IP address corresponds to a plurality of MAC addresses, it is determined that an IP collision exists.
The method may include that all the devices in the target device group perform one-time interaction, and all the devices in the target device group send one message to a device management center, where one message is one flow. The flow collection equipment is arranged in the equipment management center, or the flow collection equipment provides flow collection service for the equipment management center. And analyzing each message to obtain the IP address and the MAC address carried by each message, and determining that IP conflict exists if one IP address corresponds to a plurality of MAC addresses. Since the IP address of each device is assigned by the device management center, the device management center knows the IP address of each device, and determines the device with the IP conflict when determining the IP address with the IP conflict.
Optionally, the generating module 305 is further configured to, when it is determined that the dynamic IP address allocation for each device in the target device group fails when each device is not allocated or acquires the dynamic IP address within a preset time, randomly generate the second static IP address for each device in the target device group from the static IP address pool.
Optionally, when a specific device does not allocate or acquire the dynamic IP address within a preset time, the second static IP address is randomly generated for the specific device from the static IP address pool.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not constitute any limitation to the implementation process of the embodiments of the present disclosure.
Fig. 4 is a schematic diagram of an electronic device 4 provided by the embodiment of the present disclosure. As shown in fig. 4, the electronic apparatus 4 of this embodiment includes: a processor 401, a memory 402 and a computer program 403 stored in the memory 402 and executable on the processor 401. The steps in the various method embodiments described above are implemented when the processor 401 executes the computer program 403. Alternatively, the processor 401 implements the functions of the respective modules/units in the above-described respective apparatus embodiments when executing the computer program 403.
The electronic device 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other electronic devices. The electronic device 4 may include, but is not limited to, a processor 401 and a memory 402. Those skilled in the art will appreciate that fig. 4 is merely an example of electronic device 4, and does not constitute a limitation of electronic device 4, and may include more or fewer components than shown, or different components.
The Processor 401 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like.
The storage 402 may be an internal storage unit of the electronic device 4, for example, a hard disk or a memory of the electronic device 4. The memory 402 may also be an external storage device of the electronic device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like provided on the electronic device 4. The memory 402 may also include both internal storage units of the electronic device 4 and external storage devices. The memory 402 is used for storing computer programs and other programs and data required by the electronic device.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the above embodiments may be realized by the present disclosure, and the computer program may be stored in a computer readable storage medium to instruct related hardware, and when the computer program is executed by a processor, the steps of the above method embodiments may be realized. The computer program may comprise computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, software distribution medium, etc. It should be noted that the computer readable medium may contain suitable additions or additions that may be required in accordance with legislative and patent practices within the jurisdiction, for example, in some jurisdictions, computer readable media may not include electrical carrier signals or telecommunications signals in accordance with legislative and patent practices.
The above examples are only intended to illustrate the technical solutions of the present disclosure, not to limit them; although the present disclosure 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present disclosure, and are intended to be included within the scope of the present disclosure.

Claims (10)

1. A method for allocating an IP address of a device, comprising:
acquiring a dynamic IP address network segment, wherein the dynamic IP address network segment comprises a plurality of dynamic IP addresses;
based on the dynamic IP address network segment, allocating the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol, wherein the target device group comprises a plurality of devices;
setting the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device;
performing IP collision detection processing on the first static IP addresses of all the devices in the target device group;
if the dynamic IP address is failed to be allocated to each device in the target device group, randomly generating a second static IP address for each device in the target device group from a static IP address pool;
and performing the IP collision detection processing on the second static IP addresses of all the devices in the target device group.
2. The method of claim 1, wherein before obtaining a dynamic IP address network segment, wherein the dynamic IP address network segment comprises a plurality of dynamic IP addresses, the method further comprises:
dividing the dynamic IP address network segment, the static IP address network segment and other IP address network segments by using an object program;
and generating the static IP address pool based on a static IP address network segment, wherein the static IP address network segment comprises a plurality of second static IP addresses.
3. The method of claim 1, wherein performing the IP collision detection processing on the first static IP addresses of all the devices in the target device group comprises:
when IP conflict exists, reallocating the dynamic IP address to each first target device in the target device group by using a dynamic host configuration protocol based on the dynamic IP address network segment, wherein the first target device is a device with the IP conflict existing in the first static IP address;
setting the dynamic IP address reassigned to each first target device as the static IP to update the first static IP address of each first target device.
4. The method of claim 1, wherein the performing the IP collision detection processing on the second static IP addresses of all the devices in the target device group comprises:
and when the IP conflict exists, randomly generating the second static IP address again for each second target device in the target device group from the static IP address pool, wherein the second target device is a device with the IP conflict existing in the second static IP address.
5. The method of claim 1, wherein the IP collision detection process comprises:
acquiring a target log for allocating or generating IP addresses for all the devices in the target device group, wherein the IP addresses comprise: the first static IP address and the second static IP address;
determining whether an IP conflict exists based on the target log.
6. The method of claim 1, wherein the IP collision detection process comprises:
enabling all devices in the target device group to carry out interaction once, and acquiring all traffic in the interaction through traffic acquisition devices in the interaction, wherein each device can send out at least one traffic in the interaction;
analyzing the collected flow to obtain an IP address and an MAC address of each device, wherein the IP address comprises: the first static IP address and the second static IP address;
when one IP address corresponds to a plurality of MAC addresses, it is determined that an IP collision exists.
7. The method of claim 1, wherein randomly generating a second static IP address for each device in the target device group from a pool of static IP addresses if assigning the dynamic IP address to each device in the target device group fails comprises:
and when each device is not allocated or acquires the dynamic IP address within preset time, determining that the allocation of the dynamic IP address for each device in the target device group fails, and randomly generating the second static IP address for each device in the target device group from the static IP address pool.
8. An apparatus for assigning an IP address of a device, comprising:
the system comprises an acquisition module, a processing module and a control module, wherein the acquisition module is configured to acquire a dynamic IP address network segment, and the dynamic IP address network segment comprises a plurality of dynamic IP addresses;
an allocation module configured to allocate the dynamic IP address to each device in a target device group by using a dynamic host configuration protocol based on the dynamic IP address network segment, wherein the target device group includes a plurality of devices;
the setting module is configured to set the dynamic IP address allocated to each device as a static IP to obtain a first static IP address of each device;
a first processing module configured to perform IP collision detection processing on first static IP addresses of all devices in the target device group;
a generation module configured to randomly generate a second static IP address for each device in the target device group from a pool of static IP addresses if the allocation of the dynamic IP address to each device in the target device group fails;
a second processing module configured to perform the IP collision detection processing on the second static IP addresses of all the devices in the target device group.
9. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202210770669.3A 2022-06-30 2022-06-30 Equipment IP address allocation method and device Active CN115174525B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210770669.3A CN115174525B (en) 2022-06-30 2022-06-30 Equipment IP address allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210770669.3A CN115174525B (en) 2022-06-30 2022-06-30 Equipment IP address allocation method and device

Publications (2)

Publication Number Publication Date
CN115174525A true CN115174525A (en) 2022-10-11
CN115174525B CN115174525B (en) 2024-03-15

Family

ID=83488593

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210770669.3A Active CN115174525B (en) 2022-06-30 2022-06-30 Equipment IP address allocation method and device

Country Status (1)

Country Link
CN (1) CN115174525B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1333647A2 (en) * 2002-01-29 2003-08-06 Samsung Electronics Co., Ltd. Domain name management method and apparatus therefor
US20040022222A1 (en) * 2002-07-31 2004-02-05 Allister Clisham Wireless metropolitan area network system and method
CN103237093A (en) * 2013-04-17 2013-08-07 厦门亿联网络技术股份有限公司 Self-adaptive IP (internet protocol) address acquiring method
CN105704261A (en) * 2012-02-03 2016-06-22 联想(北京)有限公司 IP address conflict solving method, electronic equipment and computer
CN106131235A (en) * 2016-06-28 2016-11-16 上海斐讯数据通信技术有限公司 A kind of IP address configuration method
CN106612189A (en) * 2015-10-22 2017-05-03 鸿富锦精密电子(天津)有限公司 Computer and network attribute setting method
CN110445887A (en) * 2019-08-12 2019-11-12 北京百佑科技有限公司 Repeat IP recognition methods, device and intelligent talk back equipment
CN112769965A (en) * 2019-10-21 2021-05-07 中盈优创资讯科技有限公司 IP address management and distribution method, device and system
CN114363881A (en) * 2021-12-03 2022-04-15 京信网络系统股份有限公司 IP address allocation method, device, equipment and medium
CN114448932A (en) * 2021-12-29 2022-05-06 锐捷网络股份有限公司 Address allocation method and device and electronic equipment
CN114650273A (en) * 2022-04-01 2022-06-21 河南创新科信息技术有限公司 Initialization method, device, equipment and storage medium for operating system configuration

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1333647A2 (en) * 2002-01-29 2003-08-06 Samsung Electronics Co., Ltd. Domain name management method and apparatus therefor
US20040022222A1 (en) * 2002-07-31 2004-02-05 Allister Clisham Wireless metropolitan area network system and method
CN105704261A (en) * 2012-02-03 2016-06-22 联想(北京)有限公司 IP address conflict solving method, electronic equipment and computer
CN103237093A (en) * 2013-04-17 2013-08-07 厦门亿联网络技术股份有限公司 Self-adaptive IP (internet protocol) address acquiring method
CN106612189A (en) * 2015-10-22 2017-05-03 鸿富锦精密电子(天津)有限公司 Computer and network attribute setting method
CN106131235A (en) * 2016-06-28 2016-11-16 上海斐讯数据通信技术有限公司 A kind of IP address configuration method
CN110445887A (en) * 2019-08-12 2019-11-12 北京百佑科技有限公司 Repeat IP recognition methods, device and intelligent talk back equipment
CN112769965A (en) * 2019-10-21 2021-05-07 中盈优创资讯科技有限公司 IP address management and distribution method, device and system
CN114363881A (en) * 2021-12-03 2022-04-15 京信网络系统股份有限公司 IP address allocation method, device, equipment and medium
CN114448932A (en) * 2021-12-29 2022-05-06 锐捷网络股份有限公司 Address allocation method and device and electronic equipment
CN114650273A (en) * 2022-04-01 2022-06-21 河南创新科信息技术有限公司 Initialization method, device, equipment and storage medium for operating system configuration

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
陈松;: "基于端口隔离静态IP地址冲突防范策略", 计算机工程与设计, no. 01 *
陈松;: "基于端口隔离静态IP地址冲突防范策略", 计算机工程与设计, no. 01, 16 January 2009 (2009-01-16) *

Also Published As

Publication number Publication date
CN115174525B (en) 2024-03-15

Similar Documents

Publication Publication Date Title
CN108924268B (en) Container cloud service system and pod creation method and device
US9100353B2 (en) Cloud server for managing hostnames and IP addresses, and management method for the cloud server
CN110719209B (en) Cluster network configuration method, system, equipment and readable storage medium
CN104468574B (en) A kind of method, system and device of virtual machine dynamic access IP address
CN110868435B (en) Bare metal server scheduling method and device and storage medium
CN110798507B (en) Method and system for DHCP address allocation memory
CN102970161A (en) Cloud machine deployment platform and deployment method
CN109298937A (en) Document analysis method and the network equipment
CN111163186A (en) ID generation method, device, equipment and storage medium
CN112910854A (en) Method and device for safe operation and maintenance of Internet of things, terminal equipment and storage medium
CN108834130B (en) Identification distribution method, device, terminal and computer readable storage medium
CN115174525B (en) Equipment IP address allocation method and device
CN108259639B (en) IP address allocation method and device
US20230283525A1 (en) Method and apparatus for fine-grained isolation in cn nss domain of e2e network slice
CN111131529B (en) Method, device and storage medium for centralized management of address pools
CN109819059B (en) Method, device, equipment and storage medium for managing network equipment
CN116436968A (en) Service grid communication method, system, device and storage medium
CN115801733A (en) Network address allocation method and device, electronic equipment and readable medium
CN116489123A (en) Industrial Internet identification-based processing method and device
CN113839783A (en) Task processing method, device and equipment
CN114866371B (en) Method and device for establishing IPSec tunnel, storage medium and electronic equipment
CN111683164A (en) IP address configuration method and VPN service system
CN110377548A (en) A kind of address space multiplexing method, device and multiplexer
CN116488917A (en) Multi-tenant service access method, device, node and storage medium
CN111327666A (en) Service management method, device and system, computer equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant