Disclosure of Invention
Aiming at the defects in the prior art, the invention provides an automatic IP address allocation method, an automatic IP address allocation device, electronic equipment and a computer readable medium, which can effectively avoid the phenomena of IP address conflict and subnet partition error and improve the accuracy and rationality of IP address allocation.
An automatic IP address allocation method is provided, wherein the IP address comprises a plane IP address and a two-plane IP address, and the method specifically comprises the following steps:
acquiring IP distribution related information of equipment to be distributed, wherein the IP distribution related information comprises station address information;
acquiring a third-level station address number corresponding to the station address information, wherein the third-level station address number comprises a first-level station address number, a second-level station address number and a third-level station address number;
determining a first byte of the first plane IP address and a first byte of the second plane IP address according to the first-level station address number and the plane number;
the second level station address number and the third level station address number are respectively used as a second byte and a third byte of the first plane IP address and the second plane IP address;
allocating a fourth byte for the one-plane IP address and the two-plane IP address that does not conflict with existing devices.
An optimization scheme, wherein the first bytes of the first plane IP address and the second plane IP address are determined according to the first level station address number and the plane number, the optimization scheme comprises the following steps:
acquiring the plane numbers of the first plane and the second plane;
obtaining a first byte of the plane IP address according to the plane number of the plane and the first-stage station address number;
and obtaining a first byte of the IP address of the second plane according to the plane number of the second plane and the serial number of the first-level station address.
An optimization scheme, when the site information corresponds to a local area network site:
and the first-stage station address number is determined as a number which independently represents a local area network.
An optimization scheme, when the site information corresponds to a local area network site:
if the local area network address is provided with a mobile satellite communication device, the second level address number used as the second byte of the two-plane IP address adopts one of a number representing mobile satellite communication and a corresponding number of the mobile satellite communication device, and the third level address number used as the third byte of the two-plane IP address adopts the other one of the number representing mobile satellite communication and the corresponding number of the mobile satellite communication device.
An advantageous solution is that if the device to be allocated is connected only to the mobile satellite communication means, the second level site number used as the second byte of the one-plane IP address uses one of the numbers representing mobile satellite communications and the corresponding number of the mobile satellite communication means, and the third level site number used as the third byte of the one-plane IP address uses the other of the numbers.
An optimization scheme, wherein the IP distribution related information further comprises a device type;
the allocating a fourth byte that does not conflict with existing devices to the first plane IP address and the second plane IP address includes the following steps:
determining a preset integer interval corresponding to the device type;
and selecting an integer which does not conflict with the existing equipment in the integer interval as a fourth byte of the first plane IP address and the second plane IP address.
An optimization scheme, wherein the obtaining of a tertiary site number corresponding to the site information includes:
and carrying out corresponding number matching on the station address information in a preset third-level station address library, and finding out a first-level station address number, a second-level station address number and a third-level station address number corresponding to the station address information.
An IP address automatic allocation apparatus comprising:
the device information acquisition module is used for acquiring IP distribution related information of the device to be distributed, wherein the IP distribution related information comprises station address information;
a third-level station address number obtaining module, configured to obtain a third-level station address number corresponding to the station address information, where the third-level station address number includes a first-level station address number, a second-level station address number, and a third-level station address number;
a first byte allocation module, configured to determine a first byte of the first plane IP address and a first byte of the second plane IP address according to the first-level station address number and the plane number;
a second third byte allocation module, configured to use the second-level site address number and the third-level site address number as a second byte and a third byte of the first plane IP address and the second plane IP address, respectively;
a fourth byte allocation module, configured to allocate a fourth byte that does not conflict with existing devices for the first plane IP address and the second plane IP address.
An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement an automatic IP address assignment method as in any of the preceding.
A computer-readable medium on which a computer program is stored, wherein the program, when executed by a processor, implements an IP address automatic allocation method as in any one of the preceding.
Compared with the prior art, the invention has the following beneficial effects:
the invention automatically allocates IP addresses based on preset three-level station address numbers, namely, according to the user IP address allocation rules of the metropolitan area network and the local area network of the office network, and in combination with the type characteristics and the station arrangement condition of equipment to be allocated, a model of three-level two types of station addresses and equipment types is constructed, and the IP addresses are automatically allocated to newly added facility equipment. The invention can reduce the workload of artificially allocating the IP address, improve the working efficiency, reduce the error rate, effectively avoid the phenomena of IP address conflict and subnet division error, and is more accurate and more reasonable than the existing IP address allocation mode; the network state of the device can be directly known through the biplane IP address of the device.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, an IP address automatic allocation method, where the IP address includes a planar IP address and a planar IP address, specifically includes:
acquiring IP distribution related information of equipment to be distributed, wherein the IP distribution related information comprises station address information;
acquiring a third-level station address number corresponding to the station address information, wherein the third-level station address number comprises a first-level station address number, a second-level station address number and a third-level station address number;
determining a first byte of the first plane IP address and a first byte of the second plane IP address according to the first-level station address number and the plane number;
the second level station address number and the third level station address number are respectively used as a second byte and a third byte of the first plane IP address and the second plane IP address;
allocating a fourth byte for the one-plane IP address and the two-plane IP address that does not conflict with existing devices.
The site can be divided into two types according to the network scale, one is a metropolitan area network site, and the other is a local area network site, which respectively correspond to a metropolitan area network and a remote station local area network of an office network. The metropolitan area network site is generally located in the home and other large-scale areas, and the local area network site is generally located in a middle and small area far away from the home. The station addresses can be divided into three stages according to the membership, and the first stage station address corresponds to a large area in the geography; the second level station address corresponds to the middle area in the large area in the geographic information; the third level of site addresses corresponds to a small area in the middle area of the geographical area. In the third-level station address library, a group of numbers are respectively allocated to the area corresponding to each station address in advance (each station address has the corresponding first, second and third-level station address numbers, and the nonexistence can be replaced by 0); the first-stage site address number, the second-stage site address number and the third-stage site address number of the equipment to be allocated have different purposes and are respectively used for generating a first byte, a second byte and a third byte of an IP address. The fourth byte selects a number that does not conflict with existing devices. In addition, the local area network site includes, in addition to the corresponding geographical area, mobile equipment, such as a mobile satellite communicator (e.g., a satellite vehicle); when the device to be allocated is accessed to the network through the mobile satellite communication device, the local area network number can be used as a first byte, and the number corresponding to the mobile satellite communication and the device thereof can be used as a second byte and a third byte.
In this embodiment, a bi-plane structure is adopted, and IP addresses of different planes are distinguished according to the first byte. For the second byte and the third byte, corresponding second level site number and third level site number can be directly adopted, and the number does not exceed 8-bit binary number. In the method, on one hand, the geographic area division of the site is effectively utilized to carry out numbering and IP allocation, and on the other hand, reasonable IP allocation processing is carried out on various conditions which may occur to the site of the local area network.
As shown in fig. 2, in an embodiment, the determining the first bytes of the first plane IP address and the second plane IP address according to the first-level site number and the plane number includes the following steps:
acquiring the plane numbers of the first plane and the second plane;
obtaining a first byte of the plane IP address according to the plane number of the plane and the first-stage station address number;
and obtaining a first byte of the IP address of the second plane according to the plane number of the second plane and the serial number of the first-level station address.
As shown in fig. 3, the first byte may be divided into a plane number segment for identifying a plane and a first-level site number segment for identifying an area where the first byte is located, and lengths of the plane number segment and the first-level site number segment may be adjusted according to actual requirements (the plane number shown in fig. 3 is 3 bits, and the first-level site number is 5 bits).
In one embodiment, when the station address information corresponds to a local area network station address, the first-stage station address number is determined as a number which solely represents a local area network.
In the invention, the local area network station address and the metropolitan area network station address can be uniformly numbered as the first stage station address number; as described in this embodiment, a single number may also be allocated to the local area network site, and all the local area network sites adopt the number. Considering that the number of the local area network sites is usually much smaller than that of the metropolitan area network sites, the number of the first site numbers corresponding to the local area network sites can be reduced according to the actual situation, for example, in this embodiment, the number of the first site numbers of the local area network sites is adjusted to 1, and the first site numbers of all the local area network sites are unified, so that the management of the IP addresses is facilitated to a certain extent, and a larger number space can be reserved for the metropolitan area network sites.
In one embodiment, when the station address information corresponds to a local area network station address, if a mobile satellite communication device is disposed in the local area network station address, the second-level station address number used as the second byte of the two-plane IP address adopts a number representing mobile satellite communication/a corresponding number of the mobile satellite communication device, and the third-level station address number used as the third byte of the two-plane IP address adopts a corresponding number representing mobile satellite communication/a number representing mobile satellite communication.
For the local area network site, if a mobile satellite communication device is arranged, the distribution strategy of a plane can be kept unchanged (namely, the second byte and the third byte are set according to the second-level site number and the third-level site number of a corresponding geographic area), and the IP address is distributed according to the mobile satellite communication device by the plane, namely, the number of the mobile satellite communication device is set as the second-level site number, and a number representing mobile satellite communication is set as the third-level site number; the reverse arrangement is also possible, such as the number representing the mobile satellite communication being the second level site number and the number of the mobile satellite communication device being the third level site number.
On the basis of the previous embodiment, if the device to be allocated is connected only to the mobile satellite communication device, the second level site number used as the second byte of the one-plane IP address adopts the number representing mobile satellite communication/the corresponding number of the mobile satellite communication device, and the third level site number used as the third byte of the one-plane IP address adopts the corresponding number representing mobile satellite communication/the number representing mobile satellite communication.
For the local area network site, if only the mobile satellite communication device is provided, that is, the suitable second site number cannot be found in the third-level site library for representation (for example, the area is not numbered), or the device to be allocated is only connected to the mobile satellite communication device and does not access the local area network, the second-level site number therein may be set to 0 (other numbers are also possible) when the third-level site number is obtained. When the second-level station address number is 0, the present embodiment may allocate an IP address to a plane according to the mobile communication device based on the previous embodiment. Thus, the network state of the corresponding device can be known only through the information provided by different plane IP addresses.
As shown in fig. 4, in an embodiment, the IP allocation related information further includes a device type;
the allocating a fourth byte that does not conflict with existing devices to the first plane IP address and the second plane IP address includes the following steps:
determining a preset integer interval corresponding to the device type;
and selecting an integer which does not conflict with the existing equipment in the integer interval as a fourth byte of the first plane IP address and the second plane IP address.
Wherein, for the fourth byte, the most basic requirement is no conflict with the existing devices. However, if the fourth byte allocation is performed at will, it causes some trouble in subsequent management. In this embodiment, the device library is set to classify and number different devices, the device address library is also set to divide integer intervals for different types of devices, and the device to be allocated searches for an integer that does not conflict with the existing device from the integer interval corresponding to the device type after acquiring the device type, so that it is ensured that the devices in one integer interval are all of the same type, and subsequent management and identification and further information processing are facilitated.
In one embodiment, the obtaining of the third-level station address number corresponding to the station address information includes:
and carrying out corresponding number matching on the station address information in a preset third-level station address library, and finding out a first-level station address number, a second-level station address number and a third-level station address number corresponding to the station address information.
For convenience of understanding, the following embodiments are specifically enumerated (as shown in fig. 3, the following scheme is default to have a plane number of three-bit binary, where the first plane is "000", the second plane is "010"; in practical applications, the number of bits of the plane number is variable, and can be changed to another binary representation, and can also be adapted to the case where there are more planes):
example 1, scenario for metropolitan area network:
in the station address information of the device to be allocated, if the number of the station address a of the primary metropolitan area network is 1, the first byte of the IP address corresponding to the first plane is 1, and the 1 st byte of the IP address of the second plane is 65. The number of the second level metropolitan area network corresponding to the station address A is 11, and the second byte corresponding to the first and second plane IP addresses is 11. If the number of the third-level metropolitan area network station address corresponding to the station address A is 4, the 3 rd byte corresponding to the first and second plane IP addresses is 4. The integral interval of the station address A corresponding to the device type of the device to be allocated is 101-150, and the station address A is allocated to the integral 150 through collision detection. The first plane IP address of the device to be allocated in site a is 1.11.4.150; the second planar IP address is 65.11.4.150.
Embodiment 2, scheme for no mobile satellite communication device in local area network:
in the station address information of the device to be allocated, if the number of the station address B of the primary local area network is 21 (the local area network number may be a fixed number), the first byte of the IP address corresponding to the first plane is 21, and the first byte of the IP address of the second plane is 85. If the serial number of the second-level local area network station address B of the station address B is 11, the second byte of the IP address corresponding to the first plane and the second plane is 11. The number of the third-level metropolitan area network site corresponding to the site B is 15, and the 3 rd byte corresponding to the first and second plane IP addresses is 15. And the integral interval of the station address B corresponding to the equipment type of the equipment to be allocated is 81-100, and the station address B is allocated to an integer 90 through collision detection. The first plane IP address of the device to be allocated in site B is 21.11.15.90; the second planar IP address is 85.11.15.90.
Embodiment 3, regarding the scheme of the local area network with mobile satellite communication devices:
in the station address information of the equipment to be allocated, the serial number of a plane of a secondary local area network station address C is 50, and a satellite communication vehicle No. 61 is configured in the station address C, so that the first byte of the IP address corresponding to the first plane is 20 (the serial number of the local area network can be fixed), and the first byte of the IP address of the second plane is 84; the second byte of the IP address corresponding to the first plane is 50 (second level station address number) and the second byte of the IP address corresponding to the second plane is 61 (satellite vehicle number). If the network number of one plane of the third-level lan address of the address C is 22, the 3 rd byte of the IP address corresponding to the first plane is 22 (the third-level address number of the lan), and the 3 rd byte of the IP address corresponding to the second plane is 21 (the mobile satellite communication number). The integer interval of the station address C corresponding to the equipment type of the equipment to be allocated is 26-30, and the integer allocated by the collision detection is 27. The first plane IP address of the data interface of the device to be detected in the station address C is 20.50.22.27; the second planar IP address is 84.61.21.27.
Embodiment 4, scheme for local area network with mobile satellite communication device only:
in the station address information of the equipment to be allocated, the station address D of the secondary local area network does not have a serial number corresponding to the first plane, and a 62 # satellite vehicle is configured in the station address D, so that the first byte of the IP address corresponding to the first plane is 20 (the serial number of the local area network can be fixed), and the first byte of the IP address of the second plane is 84; the second byte of the IP address corresponding to the first plane is 62 (satellite vehicle number), and the second byte of the IP address of the second plane is 62 (satellite vehicle number). The station address D corresponds to 21 (mobile satellite communication number) for the third byte of the IP address of the first plane, and 21 (mobile satellite communication number) for the third byte of the IP address of the second plane. And the integral interval of the station address D corresponding to the equipment type of the equipment to be allocated is 50-80, and the integral allocated by collision detection is 58. The station address D is 20.62.21.58 for the first plane IP address of the data interface of the equipment to be detected; the second planar IP address is 84.62.21.58.
As shown in fig. 5, an embodiment of the present invention further provides an IP address automatic allocation apparatus, including:
the device information acquisition module is used for acquiring IP distribution related information of the device to be distributed, wherein the IP distribution related information comprises station address information;
a third-level station address number obtaining module, configured to obtain a third-level station address number corresponding to the station address information, where the third-level station address number includes a first-level station address number, a second-level station address number, and a third-level station address number;
a first byte allocation module, configured to determine a first byte of the first plane IP address and a first byte of the second plane IP address according to the first-level station address number and the plane number;
a second third byte allocation module, configured to use the second-level site address number and the third-level site address number as a second byte and a third byte of the first plane IP address and the second plane IP address, respectively;
a fourth byte allocation module, configured to allocate a fourth byte that does not conflict with existing devices for the first plane IP address and the second plane IP address.
An embodiment of the present invention further provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon; when executed by the one or more processors, cause the one or more processors to implement an automatic IP address assignment method as described above.
The electronic device may be a computer system, and the computer system may include a server and a terminal in communication with the server in a server/client or server/browser mode, where the server provides database creation and maintenance of an IP address atomic model and a business model, determination and maintenance of an IP address pool, and receives IP address application requests, and the client presents a UI interface interacting with a user.
An embodiment of the present invention further provides a computer readable medium, on which a computer program is stored, where the program, when executed by a processor, implements the above-mentioned method for automatically allocating an IP address.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples are merely illustrative of several embodiments of the present invention, and the description thereof is more specific and detailed, but not to be construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present invention should be subject to the appended claims.