CN110290228B - Internet protocol IP address allocation method and device - Google Patents

Internet protocol IP address allocation method and device Download PDF

Info

Publication number
CN110290228B
CN110290228B CN201910477096.3A CN201910477096A CN110290228B CN 110290228 B CN110290228 B CN 110290228B CN 201910477096 A CN201910477096 A CN 201910477096A CN 110290228 B CN110290228 B CN 110290228B
Authority
CN
China
Prior art keywords
section
allocated
sub
type
network equipment
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.)
Active
Application number
CN201910477096.3A
Other languages
Chinese (zh)
Other versions
CN110290228A (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.)
Wangsu Science and Technology Co Ltd
Original Assignee
Wangsu Science and 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 Wangsu Science and Technology Co Ltd filed Critical Wangsu Science and Technology Co Ltd
Priority to CN201910477096.3A priority Critical patent/CN110290228B/en
Publication of CN110290228A publication Critical patent/CN110290228A/en
Application granted granted Critical
Publication of CN110290228B publication Critical patent/CN110290228B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses

Abstract

The application provides an Internet Protocol (IP) address allocation method and device, wherein the method comprises the following steps: and determining the IP sections to be allocated according to the number of the network devices and the types of the network devices, wherein the number of the IP which is not allocated in the IP sections to be allocated is greater than or equal to the number of the network devices. And determining a first sub-IP section corresponding to the type of the network equipment in the IP section to be distributed according to the type of the network equipment. And allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the IP which is not allocated in the first sub IP section. According to the scheme, one IP section to be allocated is selected according to the number and the type of the network equipment, the IP is regularly allocated to the network equipment according to the number of the IP which is not allocated in the first sub-IP section in the IP section to be allocated and the number of the network equipment, and the IP allocated to the network equipment has a certain rule, so that the network equipment can be managed more conveniently.

Description

Internet protocol IP address allocation method and device
Technical Field
The present application relates to the field of network communication technologies, and in particular, to a method and an apparatus for allocating an internet protocol IP address.
Background
When network devices such as switches and servers are shelved on a large scale, Internet Protocol (IP) addresses of the network devices need to be allocated.
At present, the allocation of the IP of the network device is implemented by manual allocation, specifically, some idle IPs are manually determined to be allocated to the corresponding device.
The method of manually allocating the IP to the network device consumes human resources, and when the number of network devices is large, the allocation result of manual allocation is not scientific enough, the randomness of the IP allocated to each network device is large, and it is difficult to manage each network device subsequently.
Disclosure of Invention
The application provides an Internet Protocol (IP) address allocation method and device, which are used for allocating IP to network equipment more reasonably and further facilitating management of the network equipment.
In a first aspect, the present application provides an internet protocol IP address allocation method, including: and determining the IP sections to be allocated according to the number of the network devices and the types of the network devices, wherein the number of the unallocated IPs in the IP sections to be allocated is greater than or equal to the number of the network devices. And then determining a first sub-IP section corresponding to the type of the network equipment in the IP section to be distributed according to the type of the network equipment. And allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the IP which is not allocated in the first sub IP section. According to the scheme, a reasonable IP section to be distributed is selected according to the number and the types of network equipment, a first sub-IP section corresponding to the type of the network equipment exists in the IP section to be distributed, then according to the number of the IP which is not distributed in the first sub-IP section and the number of the network equipment, if the number of the IP which is not distributed in the first sub-IP section is larger than or equal to the number of the network equipment, the IP which is distributed to the network equipment is in the first sub-IP section, otherwise, after all the IP in the first sub-IP section is distributed to the network equipment, specific IP of the IP section to be distributed is selected to be distributed to the network equipment, finally, the network equipment is regularly distributed to obtain the IP, and the network equipment can be managed more conveniently subsequently.
In a possible implementation manner, the determining an IP segment to be allocated according to the number of network devices and the type of the network device includes: and determining that the first type of IP section exists in the candidate IP sections, and acquiring one IP section in the first type of IP section as the IP section to be allocated, wherein the number of the unallocated IPs in the sub IP section corresponding to the type of the network equipment in the first type of IP section is greater than or equal to the number of the network equipment. In the scheme, the selected IP section to be allocated is the IP section of the first type, the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment, namely, the IPs allocated to the network equipment are all in the sub-IP section corresponding to the type of the network equipment in the IP section, and the management of the network equipment can be realized more conveniently.
In a possible implementation manner, the number of unallocated IPs in the first sub-IP segment is less than or equal to the number of unallocated IPs in sub-IP segments corresponding to the type of the network device in other IP segments in the first type of IP segment. In the scheme, the selected to-be-allocated IP segment is the IP segment with the least number of unallocated IPs in the sub-IP segments corresponding to the types of the network devices among all the first-type IP segments, and the selection of the IP segment as the to-be-allocated IP segment has the following beneficial effects: the residual unallocated IP quantity in the IP section is less, and the IP section resources are more fully utilized.
In a possible implementation manner, allocating, to the network device, the IPs in the IP segment to be allocated according to the number of the network devices and the number of the IPs not allocated in the first sub-IP segment includes: and from the first IP in the first sub-IP section, sequentially allocating IPs to the network devices according to the ascending order of the IPs, wherein one network device is allocated with one IP. And the IP in the first sub-IP section is sequentially distributed to the network equipment according to the increasing sequence of the IP, so that the network equipment can obtain continuous IP, and the management of the network equipment is facilitated.
In another possible implementation manner, the determining an IP segment to be allocated according to the number of network devices and the type of the network device includes: and if the candidate IP section is determined not to have the IP section of the first type, acquiring one IP section in the IP section of the second type as the IP section to be allocated, wherein the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment, and the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the second type is smaller than the number of the network equipment. When the first type of IP section does not exist in the candidate IP sections, the second type of IP section is selected, the number of the unallocated IPs in the second type of IP section is larger than or equal to the number of the network equipment, so that the IPs which are allocated by the network equipment all belong to one IP section, and the management of the network equipment is facilitated.
In yet another possible implementation manner, the number of the network devices is M, the IPs before the first IP in the first sub-IP segment are all allocated, and the IPs after the first IP and the first IP in the first sub-IP segment are not allocated. The allocating the IP in the IP segment to be allocated to the network device according to the number of the network devices and the number of the unassigned IPs in the first sub-IP segment includes: and sequentially allocating IPs to the network equipment from the first IP in the first sub-IP section according to the ascending order of the IPs, wherein N network equipment in the network equipment is respectively allocated with one IP, N is the number of the unallocated IPs in the first sub-IP section, and N is a positive integer smaller than M. And sequentially allocating IPs to other M-N network devices in the network devices according to the descending order of the IPs from the last IP in a second sub-IP section in the IP section to be allocated, wherein the M-N network devices are respectively allocated with one IP, and the type of the network device corresponding to the second sub-IP section is different from that of the network device corresponding to the first sub-IP section. In the scheme, all the unallocated IPs in the first sub-IP section are sequentially allocated to the network equipment, and then the IPs in the second sub-IP section are allocated to the network equipment from back to front, so that the IPs in the first sub-IP section and the IPs at the tail of the second sub-IP section are both allocated to the same type of network equipment, and the management of the network equipment is facilitated.
In a possible implementation manner, the determining, according to the type of the network device, a first sub-IP segment corresponding to the type of the network device in the IP segment to be allocated includes: and preferentially determining a first sub-IP section corresponding to the switch in the IP section to be allocated for the switch according to the type of the network equipment. Since the role of one switch is more important than that of one server, IP is preferentially allocated to the switch, and the network service quality can be improved.
In a second aspect, the present application provides an internet protocol IP address assignment apparatus, comprising: a first determining unit, a second determining unit and an assigning unit. The first determining unit is used for determining the IP sections to be allocated according to the number of the network devices and the types of the network devices, and the number of the unallocated IPs in the IP sections to be allocated is greater than or equal to the number of the network devices. The second determining unit is used for determining a first sub-IP section corresponding to the type of the network equipment in the IP section to be distributed according to the type of the network equipment. The allocation unit is used for allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the IP which is not allocated in the first sub IP section. According to the scheme, a reasonable IP section to be distributed is selected according to the number and the types of network equipment, a first sub-IP section corresponding to the type of the network equipment exists in the IP section to be distributed, then according to the number of the IP which is not distributed in the first sub-IP section and the number of the network equipment, if the number of the IP which is not distributed in the first sub-IP section is larger than or equal to the number of the network equipment, the IP which is distributed to the network equipment is in the first sub-IP section, otherwise, after all the IP in the first sub-IP section is distributed to the network equipment, characteristic IP of the IP section to be distributed is selected to be distributed to the network equipment, finally, the network equipment is regularly distributed to obtain the IP, and the network equipment can be managed more conveniently subsequently.
In a possible implementation manner, the first determining unit may specifically be configured to: and if the IP section of the first type exists in the candidate IP sections, acquiring one IP section in the IP section of the first type as the IP section to be distributed, wherein the number of the IP which is not distributed in the sub IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment. In the scheme, the selected IP section to be allocated is the IP section of the first type, the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment, namely, the IPs allocated to the network equipment are all in the sub-IP section corresponding to the type of the network equipment in the IP section, and the management of the network equipment can be realized more conveniently.
In a possible implementation manner, the number of unallocated IPs in the first sub-IP segment is less than or equal to the number of unallocated IPs in sub-IP segments corresponding to the type of the network device in other IP segments in the first type of IP segment. In the scheme, the selected to-be-allocated IP segment is the IP segment with the least number of unallocated IPs in the sub-IP segments corresponding to the types of the network devices among all the first-type IP segments, and the selection of the IP segment as the to-be-allocated IP segment has the following beneficial effects: the residual unallocated IP quantity in the IP section is less, and the IP section resources are more fully utilized.
In a possible implementation manner, the IP before the first IP in the first sub-IP segment is already allocated, and the IP after the first IP and the IP in the first sub-IP segment are not allocated. The allocation unit may be specifically configured to: and from the first IP in the first sub-IP section, sequentially allocating IPs to the network devices according to the ascending order of the IPs, wherein one network device is allocated with one IP. And the IP in the first sub-IP section is sequentially distributed to the network equipment according to the increasing sequence of the IP, so that the network equipment can obtain continuous IP, and the management of the network equipment is facilitated.
In another possible implementation manner, the first determining unit may be specifically configured to: and if the candidate IP sections are determined not to have the IP section of the first type, acquiring one IP section in the IP section of the second type as the IP section to be allocated, wherein the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment, and the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the second type is smaller than the number of the network equipment. When the first type of IP section does not exist in the candidate IP sections, the second type of IP section is selected, the number of the unallocated IPs in the second type of IP section is larger than or equal to the number of the network equipment, so that the IPs which are allocated by the network equipment all belong to one IP section, and the management of the network equipment is facilitated.
In a possible implementation manner, the number of the network devices is M, the IPs before the first IP in the first sub-IP segment are all allocated, and the IPs after the first IP and the first IP in the first sub-IP segment are not allocated. The allocation unit may be specifically configured to: and sequentially allocating IPs to the network equipment from the first IP in the first sub-IP section according to the ascending order of the IPs, wherein N network equipment in the network equipment is respectively allocated with one IP, N is the number of the unallocated IPs in the first sub-IP section, and N is a positive integer smaller than M. And sequentially allocating IPs to other M-N network devices in the network devices according to the descending order of the IPs from the last IP in a second sub-IP section in the IP section to be allocated, wherein the M-N network devices are respectively allocated with one IP, and the type of the network device corresponding to the second sub-IP section is different from that of the network device corresponding to the first sub-IP section. In the scheme, all the unallocated IPs in the first sub-IP section are sequentially allocated to the network equipment, and then the IPs in the second sub-IP section are allocated to the network equipment from back to front, so that the IPs in the first sub-IP section and the IPs at the tail of the second sub-IP section are both allocated to the same type of network equipment, and the management of the network equipment is facilitated.
In a third aspect, the present application provides a network device, comprising:
a memory for storing program instructions;
a processor, configured to call the program instructions stored in the memory, and execute the method according to any of the foregoing first aspect or embodiments of the first aspect according to the obtained program.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions for causing a computer to perform the method of any of the preceding first aspect or embodiments thereof.
Drawings
Fig. 1 is a schematic diagram illustrating an internet protocol IP address allocation method according to the present application;
fig. 2 is a schematic diagram illustrating a detailed flow of a possible method for allocating an IP address according to the present application;
fig. 3 is a schematic diagram of an IP address assignment device according to the present application;
fig. 4 is a schematic structural diagram of a network device provided in the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more clear, the present application will be further described in detail with reference to the accompanying drawings. The particular methods of operation in the method embodiments may also be applied to apparatus embodiments or system embodiments. In the description of the present application, the term "plurality" means two or more unless otherwise specified.
To facilitate understanding of the present application, some terms or nouns referred to in the present application are explained below.
One, IP section, sub IP section
1. IP section
An IP segment refers to a continuous IP composed of a plurality of continuous IPs. For example, 122.102.80.2-122.102.80.200 are IP segments that include 199 consecutive IPs.
Wherein, an IP is composed of four parts, which are respectively called A section, B section, C section and D section in the application. Such as for IP: 122.102.80.2, 122 for segment A, 102 for segment B, 80 for segment C, and 2 for segment D. An IP block is also understood to mean a continuous IP consisting of a plurality of IPs having the same A, B and C blocks and different and continuous D blocks.
2. sub-IP section
The sub-IP segment is a continuous IP composed of a plurality of continuous IPs in one IP segment, such as the following IP segments: 122.102.80.2-122.102.80.200, examples of which sub-IP segments are: 122.102.80.2-122.102.80.20, the sub-IP section includes 19 consecutive IPs.
Type of network device
In the present application, the type of network device refers to the type of device to which an IP address is to be assigned. For example, the type of network device may be a switch, server, wireless terminal, etc.
Third, the relation between the type of network device and IP section
In the application, the IP sections are divided according to the types of the network equipment, namely, one type of network equipment preferentially uses a sub-IP section corresponding to the type of the network equipment in one IP section.
For example, for an IP segment: 122.102.80.2-122.102.80.200, can be agreed in advance: the sub IP sections 122.102.80.2-122.102.80.20 are corresponding to switches, and the sub IP sections 122.102.80.21-122.102.80.200 are corresponding to servers. This example shows that: when an IP address is allocated to the switch, preferably selecting an IP from 122.102.80.2-122.102.80.20 to allocate to the switch; when allocating an IP address to a server, an IP address is preferably selected from 122.102.80.21 to 122.102.80.200 and allocated to the server.
For another example, for the IP segments 122.102.80.2-122.102.80.200, it can be agreed in advance: the sub IP sections 122.102.80.2-122.102.80.20 correspond to switches, the sub IP sections 122.102.80.21-122.102.80.170 correspond to servers, and the sub IP sections 122.102.80.171-122.102.80.200 correspond to wireless terminals.
The length of the sub IP segment corresponding to one type of network device may be determined according to the type of network device and the length of the IP segment.
For example, if the type of the network device includes servers and switches, a certain IP segment is 122.102.80.2 to 122.102.80.200, and the number of the servers is usually greater than the number of the switches, when dividing the sub-IP segments, the length of the sub-IP segment corresponding to the server may be greater than the length of the sub-IP segment corresponding to the switch, for example, the sub-IP segment corresponding to the switch is 122.102.80.2 to 122.102.80.20, and the sub-IP segment corresponding to the server is 122.102.80.21 to 122.102.80.200. Of course, the lengths of the sub IP segments corresponding to different network devices may be adjusted according to actual needs, and the present application is not particularly limited. When the sub-IP segments are actually divided, the division may be performed according to the number of the IPs in the IP segment, specifically, when the number of the IPs in the IP segment is greater than a threshold, a sub-IP segment with a first length is allocated to the first type of network device, and when the number of the IPs in the IP segment is not greater than the threshold, a sub-IP segment with a second length is allocated to the first type of network device, where the first length is different from the second length.
Fig. 1 is a schematic flow chart of an internet protocol IP address allocation method provided by the present application, and the method may be executed by a cloud device, where the cloud device may be, for example, a cloud control server, a computer, a notebook computer, and the like. As shown in fig. 1, the method includes:
step 101, determining an IP segment to be allocated according to the number of network devices and the types of the network devices.
And the number of the unallocated IPs in the IP section to be allocated is greater than or equal to the number of the network equipment. For example, if the network devices needing to allocate the IPs are 10 switches, the IP segments 122.102.80.2-122.102.80.200 are allocated with the IPs of 122.102.80.2 and 122.102.80.3, the number of unallocated IPs in the IP segment is 197, that is, 122.102.80.4-122.102.80.200, and the IP segments 122.102.80.2-122.102.80.200 satisfy that the number of unallocated IPs is greater than or equal to the number of the network devices, so the IP segments 122.102.80.2-122.102.80.200 can be selected as the IP segments to be allocated.
And 102, determining a first sub-IP section corresponding to the type of the network equipment in the IP section to be distributed according to the type of the network equipment.
And 103, allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the unallocated IP in the first sub-IP section.
In a possible implementation manner, the step 101 may specifically include: and if the IP section of the first type exists in the candidate IP sections, acquiring one IP section in the IP sections of the first type as the IP section to be distributed. The candidate IP segment may be a plurality of C segments different IP segments, such as candidate IP segment a: 122.102.80.2-122.102.80.200, candidate IP segment B: 122.102.81.2-122.102.81.200, candidate IP segment C: 122.102.82.2-122.102.82.200, etc. The number of unassigned IPs in the sub-IP section corresponding to the type of the network device in the IP section of the first type is greater than or equal to the number of network devices. For example, the sub IP segments corresponding to the switch in the three IP segments listed above are: candidate IP segment a: 122.102.80.2-122.102.80.20, candidate IP segment B: 122.102.81.2-122.102.81.20, candidate IP segment C: 122.102.82.2-122.102.82.20, wherein the unallocated IP in the sub-IP section corresponding to the switch in the candidate IP section A is 122.102.80.18-122.102.80.20, the unallocated IP in the sub-IP section corresponding to the switch in the candidate IP section B is 122.102.80.11-122.102.80.20, and the unallocated IP in the sub-IP section corresponding to the switch in the candidate IP section C is 122.102.80.4-122.102.80.20, then when the number of switches needing to allocate IP is 15, only the candidate IP section C in the candidate IP section A, the candidate IP section B and the candidate IP section C is the IP section of the first type, so the candidate IP section C is selected as the IP section to be allocated.
In a possible implementation manner, if multiple different network device types exist at the same time, for example, the types of the network devices include a switch and a server, in step 102, according to the types of the network devices, the first sub-IP segment corresponding to the type of the network device in the IP segment to be allocated is determined, specifically, according to the type of each network device, the first sub-IP segment corresponding to each network device type is determined respectively. Further, according to the type of the network device, a first sub-IP segment corresponding to the switch in the IP segment to be allocated is preferentially determined for the switch, and then a first sub-IP segment corresponding to the server in the IP segment to be allocated is determined for the server. In other words, an IP can be planned and allocated to the network device according to the importance level corresponding to the type of the network device, an IP is reserved for the device with high importance preferentially, an IP is planned for the special server, and an IP is planned for the common server finally. For example, for the same segment, for IP segment: 122.102.80.2-122.102.80.200, a certain number of IP can be planned and reserved for core equipment such as an exchanger preferentially as the first sub-IP section corresponding to the exchanger, such as 122.102.80.2-122.102.80.20; planning a first sub IP section corresponding to the server for other network equipment such as the server, such as 122.102.80.21-122.102.80.200; it is considered that if there are other special servers, such as load balancing servers, a part of the IP may be reserved in the first sub-IP segment, such as 122.102.80.21-122.102.80.200, to the load balancing server as the first sub-IP segment, such as 122.102.80.21-122.102.80.40, corresponding to the load balancing server, and then the first sub-IP segment, such as 122.102.80.41-122.102.80.200, corresponding to the other servers may be planned.
In a possible implementation manner, the number of unallocated IPs in the first sub-IP segment is less than or equal to the number of unallocated IPs in sub-IP segments corresponding to the type of the network device in other IP segments in the first type of IP segment. By taking the candidate IP segment a, the candidate IP segment B, and the candidate IP segment C listed above as an example, when the number of switches to be allocated is 5, the candidate IP segment B and the candidate IP segment C are both IP segments of the first type, and when the IP segment to be allocated is determined, the IP segments corresponding to the switches in the candidate IP segment B are less unassigned, so that the candidate IP segment is selected as the IP segment to be allocated. Therefore, the residual unallocated IP quantity in the IP section is less, and the IP section resource utilization is more sufficient.
After selecting an IP segment of the first type as the IP segment to be allocated by the method, the step 103 may specifically include: and from the first IP in the first sub-IP section, sequentially allocating IPs to the network devices according to the ascending order of the IPs, wherein one network device is allocated with one IP. And allocating the IP before the first IP in the first sub-IP section, and not allocating the first IP in the first sub-IP section and the IP after the first IP. And at the time of allocation, the first IP also needs to be allocated to the network device. Taking 5 network devices needing to be allocated with IP as switches, and the selected IP section to be allocated as the candidate IP section B as an example, the first IP is 122.102.81.12, that is, the allocated IP in the first sub-IP sections 122.102.81.2-122.102.81.20 is 122.102.81.2-122.102.81.11. Then, when allocating IPs for 5 switches, the following 5 IPs are selected in order: 122.102.81.12, 122.102.81.13, 122.102.81.14, 122.102.81.15, 122.102.81.16.
By the method, for one type of network equipment, the network equipment is distributed to the corresponding sub-IP sections, and the IP in the corresponding sub-IP sections is distributed to each network equipment in sequence, so that management operations such as IP inquiry and the like can be conveniently carried out at the later stage.
Of course, when the step 101 selects an IP segment to be allocated, there may be a possibility that the first type IP segment does not exist in the candidate IP segments. In this possibility, the step 101 may specifically include: and acquiring one IP section in the second type of IP sections as the IP section to be distributed. The number of unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the second type is less than the number of the network equipment, and the number of unallocated IPs in the IP section of the second type is greater than or equal to the number of the network equipment. Continuing with the above list of candidate IP segment a, candidate IP segment B, and candidate IP segment C, assume that the number of switches to be allocated at this time is 20. None of the candidate IP segment a, candidate IP segment B and candidate IP segment C are IP segments of the first type. And assuming that 122.102.80.21-122.102.80.180 of the candidate IP segment A have been fully allocated to the server, 122.102.81.21-122.102.81.197 of the candidate IP segment B have been fully allocated to the server, and 122.102.82.21-122.102.82.199 of the candidate IP segment C have been fully allocated to the server, only the candidate IP segment A satisfies the definition of the second type of IP segment, and thus, the candidate IP segment A is selected as the IP segment to be allocated determined in step 101.
Similarly, in a possible implementation manner, when a plurality of candidate IP segments are all IP segments of the second type, one of the IP segments of the second type with the smallest unallocated IP number is selected as the IP segment to be allocated, so that the remaining unallocated IP number in the IP segment is smaller, and the IP segment resources are more fully utilized.
In a possible implementation manner, the number of the network devices is M, the IPs before the first IP in the first sub-IP segment are all allocated, and the IPs after the first IP and the first IP in the first sub-IP segment are not allocated. The step 103 may specifically include: and sequentially allocating IPs to the network equipment from the first IP in the first sub-IP section according to the ascending order of the IPs, wherein N network equipment in the network equipment is respectively allocated with one IP, N is the number of the unallocated IPs in the first sub-IP section, and N is a positive integer smaller than M. And sequentially allocating IPs to other M-N network devices in the network devices according to the descending order of the IPs from the last IP in a second sub-IP section in the IP section to be allocated, wherein the M-N network devices are respectively allocated with one IP, and the type of the network device corresponding to the second sub-IP section is different from that of the network device corresponding to the first sub-IP section. Taking 20 switches as network devices needing to be allocated with the IP, and taking the selected IP segment to be allocated as the candidate IP segment a, the first IP is 122.102.80.19, and the IPs from 122.102.80.19 in the sub-IP segment corresponding to the switch are sequentially allocated to the switch, that is, 122.102.80.19 and 122.102.80.20 are allocated to the switch. Then 18 switches have not been allocated to the IP, and another sub-IP segment of the candidate IP segment is 122.102.80.21-122.102.80.200, 18 IPs are selected from 122.102.80.200 from back to front to be allocated to the remaining switches which are not allocated to the IP, that is, 122.102.80.200-122.102.80.183 are allocated to the switches.
By the method, all the IPs of the first sub-IP section in the final IP section are distributed to the same type of network equipment, and the IPs at the tail end of the second sub-IP section are also distributed to the network equipment of the type. Specifically, if the types of network devices include a switch and a server, a part of the IP at the beginning and a part of the IP at the end in one IP segment are each assigned to the switch, and the IP in the middle are each assigned to the server. By the IP allocation method, management operations such as IP inquiry and the like can be conveniently carried out at the later stage. In addition, the switch and the server executing the same network service are distributed in the same network segment, so that the network service quality can be improved.
In one possible implementation, if neither an IP segment of the first type nor an IP segment of the second type exists in the candidate IP segments, a new IP segment that can satisfy the condition is enabled. Specifically, a new IP segment may be obtained for registration application to a network operator, or an intranet IP segment may be established by itself. Because it takes a certain time to register a new IP segment with a network operator, generally, an intranet IP segment is used first to allocate an IP to a network device, so that the network device can be put into use more quickly, and when an IP segment to be allocated that meets the conditions is available, the intranet IP can be replaced with an available IP in batches. The application is not particularly limited as to how the new IP segment is obtained.
In a possible implementation manner, if multiple network operators have IP segments that meet allocation requirements, the IP of each operator needs to be allocated when each network device is allocated. This may allow the network device to serve more users.
In yet another possible implementation, if one of the plurality of network operators does not satisfy the allocation requirement, all the network operators are not allocated. The scheme can make the services of all operators on line simultaneously.
In the following, a specific example is further described in the present application, and fig. 2 is a method for allocating an IP of a network device, as shown in fig. 2, the method includes:
in step 201, a sub-IP section is divided for each IP section.
For the specific dividing method, reference may be made to the foregoing description on how to determine the length of the sub-IP segment, and details are not described herein again.
At step 202, the number of network devices that need to be allocated is determined.
Step 203, determine the IP allocation in each IP segment.
Specifically, step 203 may include: and determining the number of unallocated IPs in the sub-IP section corresponding to the network equipment in each IP section and the number of unallocated IPs in each IP section.
Step 204, an IP segment is selected in order.
The order of the IP segments may be sorted according to the size of the C segment, or sorted according to the number of unassigned IPs. This is not particularly limited by the present application.
Step 205, determine whether the number of unassigned IPs in the sub-IP segment corresponding to the network device in the IP segment is greater than or equal to the number of the network devices.
If yes, go to step 206, otherwise go to step 207.
Step 206, allocating an IP to the network device according to the first rule.
Wherein, allocating the IP to the network device according to the first rule may specifically include: and from the first IP in the first sub-IP section, sequentially allocating IPs to the network devices according to the ascending order of the IPs, wherein one network device is allocated with one IP. Wherein the first sub-IP segment refers to a sub-IP segment corresponding to the type of the network device. The IP before the first IP in the first sub-IP section is allocated, and the IP in the first sub-IP section and the IP after the first IP are not allocated.
Step 207, determine whether the number of unassigned IPs in the IP segment is greater than or equal to the number of network devices.
If so, go to step 208, otherwise go to step 209.
And step 208, allocating the IP to the network equipment according to the second rule.
Wherein, allocating the IP to the network device according to the second rule may specifically include: and from the first IP in the first sub-IP section, sequentially allocating IPs to the network devices according to the ascending order of the IPs, wherein one network device is allocated with one IP. All network devices are not allocated IP because the number of unallocated IPs in the first sub-IP section from the first IP is insufficient. Therefore, it is further required to perform that, starting from the last IP in the second sub-IP segment in the IP segment to be allocated, the IPs are sequentially allocated to other network devices that are not allocated with IPs in the network devices according to the descending order of the IPs. And the type of the network equipment corresponding to the second sub-IP section is different from the type of the network equipment corresponding to the first sub-IP section.
Step 209 determines whether there are any IP segments that have not been determined.
If yes, returning to step 204, otherwise, indicating that all IP sections do not meet the allocation requirement and not allocating IP for the network equipment.
The method for allocating the network device IP shown in fig. 2 is the same as the method process type shown in fig. 1, and reference may be made to the specific explanation in fig. 1, which is not repeated herein.
Based on the same inventive concept, fig. 3 exemplarily shows an internet protocol IP address allocation apparatus provided by the present application, which may execute a flow of an internet protocol IP address allocation method. As shown in fig. 3, the apparatus includes:
a first determining unit 301, configured to determine an IP segment to be allocated according to the number of network devices and the type of the network device.
The number of unallocated IPs within an IP segment to be allocated is greater than or equal to the number of network devices.
A second determining unit 302, configured to determine, according to the type of the network device, a first sub-IP segment corresponding to the type of the network device in the IP segment to be allocated.
The allocating unit 303 is configured to allocate, to the network device, the IP in the IP segment to be allocated according to the number of the network devices and the number of the unassigned IPs in the first sub-IP segment.
According to the scheme, a reasonable IP section to be distributed is selected according to the number and the types of network equipment, a first sub-IP section corresponding to the type of the network equipment exists in the IP section to be distributed, then according to the number of the IP which is not distributed in the first sub-IP section and the number of the network equipment, if the number of the IP which is not distributed in the first sub-IP section is larger than or equal to the number of the network equipment, the IP which is distributed to the network equipment is in the first sub-IP section, otherwise, after all the IP in the first sub-IP section is distributed to the network equipment, characteristic IP of the IP section to be distributed is selected to be distributed to the network equipment, finally, the network equipment is regularly distributed to obtain the IP, and the network equipment can be managed more conveniently subsequently.
In a possible implementation manner, the first determining unit 301 may specifically be configured to: and if the IP section of the first type exists in the candidate IP sections, acquiring one IP section in the IP section of the first type as the IP section to be distributed. And the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is greater than or equal to the number of the network equipment.
In a possible implementation manner, the number of unallocated IPs in the first sub-IP segment is less than or equal to the number of unallocated IPs in sub-IP segments corresponding to the type of the network device in other IP segments in the first type of IP segment.
In a possible implementation manner, the IP before the first IP in the first sub-IP segment is already allocated, and the IP after the first IP and the IP in the first sub-IP segment are not allocated. The allocating unit 303 may be specifically configured to: and from the first IP in the first sub-IP section, sequentially allocating IPs to the network devices according to the ascending order of the IPs, wherein one network device is allocated with one IP.
In another possible implementation manner, the first determining unit 301 may be specifically configured to: and if the candidate IP sections are determined not to have the IP section of the first type, acquiring one IP section in the IP section of the second type as the IP section to be allocated, wherein the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment, and the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the second type is smaller than the number of the network equipment.
In a possible implementation manner, the number of the network devices is M, the IPs before the first IP in the first sub-IP segment are all allocated, and the IPs after the first IP and the first IP in the first sub-IP segment are not allocated. The allocating unit 303 may be specifically configured to: and sequentially allocating IPs to the network equipment from the first IP in the first sub-IP section according to the ascending order of the IPs, wherein N network equipment in the network equipment is respectively allocated with one IP, N is the number of the unallocated IPs in the first sub-IP section, and N is a positive integer smaller than M. And sequentially allocating IPs to other M-N network devices in the network devices according to the descending order of the IPs from the last IP in a second sub-IP section in the IP section to be allocated, wherein the M-N network devices are respectively allocated with one IP, and the type of the network device corresponding to the second sub-IP section is different from that of the network device corresponding to the first sub-IP section.
For the concepts, explanations, detailed descriptions and other steps related to the above-mentioned apparatus and related to the technical solutions provided in the present application, please refer to the foregoing internet protocol IP address allocation method or descriptions related to these contents in other embodiments, which are not described herein again.
Based on the same concept as the embodiment, the application also provides a network device.
Fig. 4 is a schematic structural diagram of a network device provided in the present application. As shown in fig. 4, the network device 400 includes:
a memory 401 for storing program instructions;
a processor 402, configured to call the program instructions stored in the memory, and execute the internet protocol IP address allocation method in any of the foregoing embodiments according to the obtained program.
Based on the same concept as the above embodiments, the present application also provides a computer storage medium storing computer-executable instructions for causing a computer to perform the internet protocol IP address allocation method described in any one of the foregoing embodiments.
It should be noted that the division of the units in the present application is schematic, and is only one division of logic functions, and there may be another division manner in actual implementation. In the present application, each functional unit may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. The procedures or functions according to the present application are generated in whole or in part when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
As will be appreciated by one skilled in the art, the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (9)

1. An internet protocol, IP, address assignment method, comprising:
determining IP sections to be allocated according to the number of network devices and the types of the network devices, wherein the number of the IP which is not allocated in the IP sections to be allocated is greater than or equal to the number of the network devices;
determining a first sub-IP section corresponding to the type of the network equipment from the IP section to be distributed according to the importance level corresponding to the type of the network equipment;
allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the IP which is not allocated in the first sub IP section;
the determining the IP section to be allocated according to the number of the network devices and the types of the network devices comprises:
and aiming at a plurality of candidate IP sections corresponding to the network equipment, determining one candidate IP section from the candidate IP sections as a first type of IP section according to the number of unallocated IPs of the candidate IP sections, and acquiring one IP section in the first type of IP section as the IP section to be allocated, wherein the number of unallocated IPs in a sub-IP section corresponding to the type of the network equipment in the first type of IP section is greater than or equal to the number of the network equipment.
2. The method of claim 1, wherein the number of unassigned IPs in the first sub-IP segment is less than or equal to the number of unassigned IPs in sub-IP segments corresponding to the type of network device in other ones of the first type of IP segments.
3. The method of claim 1 or 2, wherein if the IP before the first IP in the first sub-IP segment is allocated, neither the first IP in the first sub-IP segment nor the IP after the first IP is allocated; then
Allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the unallocated IP in the first sub-IP section, including:
and sequentially allocating the IPs to the network equipment from the first IP in the first sub-IP section according to the ascending order of the IPs, wherein one network equipment is allocated with one IP.
4. The method of claim 1, wherein the determining the IP segment to be allocated based on the number of network devices and the type of network devices comprises:
and if the candidate IP section is determined not to have the IP section of the first type, acquiring one IP section in the IP section of the second type as the IP section to be allocated, wherein the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the first type is larger than or equal to the number of the network equipment, and the number of the unallocated IPs in the sub-IP section corresponding to the type of the network equipment in the IP section of the second type is smaller than the number of the network equipment.
5. The method of claim 4, wherein the number of network devices is M, wherein the IPs before the first IP in the first sub-IP section are all allocated, and wherein the IPs after the first IP and the first IP in the first sub-IP section are not allocated;
allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the unallocated IP in the first sub-IP section, including:
sequentially allocating IPs to the network devices according to the ascending order of IPs from a first IP in the first sub-IP section, wherein N network devices in the network devices are respectively allocated with one IP, N is the number of the unassigned IPs in the first sub-IP section, and N is a positive integer smaller than M;
and sequentially allocating IPs to other M-N network devices in the network devices according to the descending order of the IPs from the last IP in a second sub-IP section in the IP section to be allocated, wherein the M-N network devices are respectively allocated with one IP, and the type of the network device corresponding to the second sub-IP section is different from that of the network device corresponding to the first sub-IP section.
6. The method of claim 1, wherein the type of the network device comprises a switch and a server, and the determining a first sub-IP segment corresponding to the type of the network device in the IP segment to be allocated according to the type of the network device comprises:
and preferentially determining a first sub-IP section corresponding to the switch in the IP section to be allocated for the switch according to the type of the network equipment.
7. An internet protocol, IP, address assignment apparatus, comprising:
a first determining unit, configured to determine an IP segment to be allocated according to the number of network devices and the type of the network device, where the number of unassigned IPs in the IP segment to be allocated is greater than or equal to the number of the network devices;
a second determining unit, configured to determine, according to an importance level corresponding to the type of the network device, a first sub-IP segment corresponding to the type of the network device from the IP segment to be allocated;
the allocation unit is used for allocating the IP in the IP section to be allocated to the network equipment according to the number of the network equipment and the number of the IP which is not allocated in the first sub IP section;
the first determining unit is specifically configured to:
and aiming at a plurality of candidate IP sections corresponding to the network equipment, determining one candidate IP section from the candidate IP sections as a first type of IP section according to the number of unallocated IPs of the candidate IP sections, and acquiring one IP section in the first type of IP section as the IP section to be allocated, wherein the number of unallocated IPs in a sub-IP section corresponding to the type of the network equipment in the first type of IP section is greater than or equal to the number of the network equipment.
8. A computing device, comprising:
a memory for storing program instructions;
a processor for calling program instructions stored in said memory to execute the method of any one of claims 1 to 6 in accordance with the obtained program.
9. A computer-readable non-transitory storage medium including computer-readable instructions which, when read and executed by a computer, cause the computer to perform the method of any one of claims 1 to 6.
CN201910477096.3A 2019-06-03 2019-06-03 Internet protocol IP address allocation method and device Active CN110290228B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910477096.3A CN110290228B (en) 2019-06-03 2019-06-03 Internet protocol IP address allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910477096.3A CN110290228B (en) 2019-06-03 2019-06-03 Internet protocol IP address allocation method and device

Publications (2)

Publication Number Publication Date
CN110290228A CN110290228A (en) 2019-09-27
CN110290228B true CN110290228B (en) 2022-03-11

Family

ID=68003133

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910477096.3A Active CN110290228B (en) 2019-06-03 2019-06-03 Internet protocol IP address allocation method and device

Country Status (1)

Country Link
CN (1) CN110290228B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111339099B (en) * 2020-02-27 2023-08-25 紫光云技术有限公司 Concurrent IP distribution method based on database optimistic lock
CN112887322A (en) * 2021-02-07 2021-06-01 上海英方软件股份有限公司 Redis-based IP resource management method and device
CN115484227B (en) * 2022-08-31 2024-03-08 湖南锐思华创科技有限公司 HUD automatic adaptation method, HUD automatic adaptation system, HUD automatic adaptation device and vehicle

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103297560A (en) * 2013-05-21 2013-09-11 江苏物联网研究发展中心 Data flow classification method and data flow classification server
CN104333610A (en) * 2014-10-29 2015-02-04 中国联合网络通信集团有限公司 IPv6 address allocation method and device
CN104769573A (en) * 2012-09-18 2015-07-08 亚马逊科技公司 Dynamically allocating network addresses
EP2911343A1 (en) * 2012-10-17 2015-08-26 Nec Corporation Terminal, message distribution system, message distribution method, and message reception program
CN104994182A (en) * 2015-06-15 2015-10-21 中国联合网络通信集团有限公司 Method of adjusting address pool and apparatus thereof

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104769573A (en) * 2012-09-18 2015-07-08 亚马逊科技公司 Dynamically allocating network addresses
EP2911343A1 (en) * 2012-10-17 2015-08-26 Nec Corporation Terminal, message distribution system, message distribution method, and message reception program
CN103297560A (en) * 2013-05-21 2013-09-11 江苏物联网研究发展中心 Data flow classification method and data flow classification server
CN104333610A (en) * 2014-10-29 2015-02-04 中国联合网络通信集团有限公司 IPv6 address allocation method and device
CN104994182A (en) * 2015-06-15 2015-10-21 中国联合网络通信集团有限公司 Method of adjusting address pool and apparatus thereof

Also Published As

Publication number Publication date
CN110290228A (en) 2019-09-27

Similar Documents

Publication Publication Date Title
US11700300B2 (en) Cluster resource management in distributed computing systems
CN110290228B (en) Internet protocol IP address allocation method and device
CN110753131A (en) Microservice distributed current limiting method and device, storage medium and electronic equipment
CN104468401A (en) Message processing method and device
CN112486860A (en) Method, apparatus and computer program product for managing address mapping for a storage system
CN110474845A (en) Flow entry eliminates method and relevant apparatus
CN111163186B (en) ID generation method, device, equipment and storage medium
CN111490890A (en) Hierarchical registration method, device, storage medium and equipment based on micro-service architecture
CN112269661A (en) Partition migration method and device based on Kafka cluster
CN110868435B (en) Bare metal server scheduling method and device and storage medium
CN108833570B (en) Cluster storage and balanced transmission system based on cloud storage
CN108696557B (en) Information processing system, method and device
CN114640678A (en) Pod management method, device and medium based on SR-IOV
CN111679918B (en) Message transmission method and device
CN115878309A (en) Resource allocation method, device, processing core, equipment and computer readable medium
CN110046040B (en) Distributed task processing method and system and storage medium
CN113904871A (en) Network slice access method, PCF entity, terminal and communication system
CN108173689B (en) Output system of load balancing data
CN108683608B (en) Method and device for distributing flow
US11558301B2 (en) Method, device, and computer program product for accessing application system
JP6339978B2 (en) Resource allocation management device and resource allocation management method
CN114124541B (en) Data processing method, device and equipment for rule ID and storage medium
CN113835862B (en) Task processing method and device
CN110795667B (en) Method, device, equipment and storage medium for determining resources to be pushed
CN113703826A (en) Method, apparatus, device and storage medium for responding to data processing request

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