Disclosure of Invention
In order to improve the working efficiency of IP address classification management, the application provides an IP address management method, an IP address management device, IP address management equipment and a computer readable storage medium.
In a first aspect, the present application provides an IP address management method, which adopts the following technical solution:
an IP address management method, comprising:
acquiring a plurality of connection information of all managed devices, wherein the connection information comprises IP addresses of the managed devices, numbers and states of first ports corresponding to the IP addresses, and numbers and states of VPN information and second ports corresponding to the VPN information;
if the number of the first port in the plurality of connection information is the same as the number of the second port, generating a mapping relation entry including an IP address corresponding to the number of the first port, VPN information corresponding to the number of the second port and a port state, and adding the mapping relation entry into a preset mapping relation table;
and dividing the types of the IP addresses in the preset mapping relation table, wherein the types of the IP addresses comprise multiplexing IP addresses and/or redundant IP addresses.
By adopting the technical scheme, the mapping relation items related to the IP addresses and the VPN information are generated, and the IP addresses in the mapping relation items are classified, so that the mapping relation items with the IP address types are displayed in front of workers, the workload of manually classifying the IP addresses by the workers is reduced, and the working efficiency of IP address classification management is improved.
Optionally, after the adding the mapping relationship entry to the preset mapping relationship table, the method further includes:
comparing the IP address in the preset mapping relation table with the IP address in a preset IP address pool;
if the IP address in the mapping relation table does not exist in the preset IP address pool, defining the IP address in the preset mapping relation table as an abnormal IP address;
before the dividing the types of the IP addresses in the preset mapping relationship table, the method further includes:
and deleting the mapping relation item to which the abnormal IP address belongs in the preset mapping relation table.
By adopting the technical scheme, the IP address which does not belong to the preset IP address pool is defined as the abnormal IP address, and the corresponding mapping relation entry is deleted, so that the interference of the abnormal IP address in the division of the IP address type in the local area network is reduced, and the management of the IP in the local area network by the working personnel is facilitated.
Optionally, the dividing the types of the IP addresses in the preset mapping relationship table includes:
comparing every two mapping relation items in the preset mapping relation table;
if two mapping relation items exist, wherein the IP address and the VPN information are the same, and the port state is UP, the IP address corresponding to one of the mapping relation items is defined as a multiplexing IP address;
and if two mapping relation entries with the same IP address and VPN information and different port states exist, defining the IP address corresponding to the mapping relation entry with the port state of DOWN as a redundant IP address.
By adopting the technical scheme, the IP addresses corresponding to the mapping relation items are divided into the multiplexing IP addresses and the redundant IP addresses, so that the multiplexing IP addresses and the redundant IP addresses in the local area network can be conveniently found and processed by workers in time, and the occurrence of IP address conflict is reduced.
Optionally, after the defining the IP address corresponding to one of the mapping relationship entries as a multiplexing IP address, the method further includes:
deleting the mapping relation item to which the multiplexing IP address belongs in the preset mapping relation table, and deleting the multiplexing IP address on the managed equipment;
after the defining the IP address corresponding to the mapping relationship entry with the port state of DOWN as the redundant IP address, the method further includes:
deleting the mapping relation item to which the redundant IP address belongs in the preset mapping relation table, and deleting the redundant IP address on the managed equipment.
By adopting the technical scheme, the mapping relation items corresponding to the multiplexing IP address and the redundant IP address and the IP addresses on the corresponding devices are deleted, so that the possibility that information cannot reach the corresponding managed devices due to the conflict of the IP addresses when the two managed devices communicate can be reduced.
Optionally, after the dividing the IP addresses in the preset mapping relationship table, the method further includes:
and if the duration time of the port state DOWN reaches the preset time, defining the IP address corresponding to the port state DOWN as a recyclable IP address.
By adopting the technical scheme, the IP address of the port in the idle state for a long time can be found in time, the idle IP is defined as the recyclable IP address, and the recyclable IP address is redistributed to other managed equipment, so that the problem of IP address waste is reduced.
Optionally, after the defining the IP address whose port status is DOWN as a recyclable IP address, the method further includes:
deleting the mapping relation item to which the recyclable IP address belongs in the preset mapping relation table, and deleting the recyclable IP address from the corresponding managed device;
and dividing the IP address which is the same as the recyclable IP address in the preset IP address pool into unused IP addresses.
By adopting the technical scheme, the recoverable IP address on the corresponding managed device is deleted, the recoverable IP address is divided into unused IP addresses in the preset IP address pool and is reallocated to other managed devices for use, so that the IP address in the local area network can be fully utilized.
Optionally, the mapping relationship entry further includes a subnet mask corresponding to the IP address; after the adding the mapping relation entry into a preset mapping relation table, the method further includes:
acquiring an IP address in the preset mapping relation table and a subnet mask corresponding to the IP address;
converting the IP address to a network address based on the IP address and the subnet mask;
and dividing the network segments corresponding to the network addresses in the preset IP address pool into used network segments, and dividing the rest network segments in the preset IP address pool into unused network segments.
By adopting the technical scheme, the IP address and the subnet mask code are converted into the network address, which network segments are used and which network segments are not used can be obtained, so that the IP addresses in the preset IP address pool are divided, and the workload that workers need to compare the IP addresses in the preset mapping relation table with the IP addresses in the preset IP address pool one by one is reduced.
In a second aspect, the present application provides an IP management apparatus, which adopts the following technical solutions:
an IP management apparatus comprising:
the system comprises an acquisition module, a management module and a management module, wherein the acquisition module is used for acquiring a plurality of connection information of all managed devices, and the connection information comprises IP addresses of the managed devices, numbers and states of first ports corresponding to the IP addresses, and numbers and states of VPN information and second ports corresponding to the VPN information;
the generation adding module is used for generating a mapping relation item which comprises an IP address corresponding to the number of the first port, VPN information corresponding to the number of the second port and a port state if the number of the first port and the number of the second port in the plurality of connection information are the same, and adding the mapping relation item into a preset mapping relation table;
and the first dividing module is used for dividing the types of the IP addresses in the preset mapping relation table, wherein the types of the IP addresses comprise multiplexing IP addresses and/or redundant IP addresses.
In a third aspect, the present application provides an IP address management device, which adopts the following technical solution:
an IP address management apparatus comprising a memory and a processor, the memory having stored thereon a computer program that can be loaded by the processor and that performs the method of any of the first aspects.
In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solutions:
a computer readable storage medium storing a computer program that can be loaded by a processor and executed to perform the method of any of the first aspects.
Detailed Description
The present application is described in further detail below with reference to the attached drawings.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
The embodiment provides an IP address management method, which may be executed by an intelligent terminal, where the intelligent terminal may be a server or a terminal device, where the server may be an independent physical server, a server cluster or a distributed system formed by multiple physical servers, or a cloud server providing cloud computing services. The terminal device may be a smart phone, a tablet computer, a desktop computer, a notebook computer, etc., but is not limited thereto.
The following takes a server as an example to specifically describe the IP address management method.
As shown in fig. 1, an embodiment of the present application provides an IP address management method, and a main flow of the method is described as follows (steps S100 to S300):
step S100, acquiring a plurality of connection information of all managed devices, wherein the connection information comprises IP addresses of the managed devices, numbers and states of first ports corresponding to the IP addresses, and numbers and states of second ports corresponding to VPN information and VPN information;
in this embodiment, the server obtains connection information of all managed devices through the MIB in the SNMP protocol, where the managed devices may be smart phones, and the managed devices may also be notebook computers, but are not limited thereto. Specifically, a node of the IPAddrEntry based on the MIB library acquires IPAdEntAddr information, IPAdEntNetMask information, and IPAdEntIfIndex information, where the IPAdEntAddr information includes an IP address of a managed device, the IPAdEntNetMask information includes a subnet mask corresponding to the IP address, and the IPAdEntIfIndex information includes a number and a state of a first port corresponding to the IP address. The state of the first port comprises an UP state and a DOWN state, wherein the UP state indicates that the port is in an open state, and the managed device can send and receive information through the port at the moment; the DOWN state indicates that the port is in a closed state, and the managed device cannot send and receive information through the port. An mpls L3VpnIfConfidex node based on an MIB library acquires VrfName information and VrfIndex information of a managed device, wherein the VrfName information is a VPN name, and the VrfIndex information includes a serial number and a state of a second port corresponding to the VPN name.
Step S200, if the number of the first port in the plurality of connection information is the same as the number of the second port, generating a mapping relation item comprising an IP address corresponding to the number of the first port, VPN information corresponding to the number of the second port and a port state, and adding the mapping relation item into a preset mapping relation table;
after the connection information of the managed device is obtained, a mapping relation entry is generated by using a screening condition IPAdEntIfIndex = VrfIndex. For example, the value of ipadentindex information is 1, the value of vrfrindex information is also 1, and since ipadentindex = vrfrindex, a mapping relationship entry regarding an IP address, a subnet mask, a port number, a port state, and a VPN name is generated, and the generated mapping relationship entry is added into a preset mapping relationship table.
Table 1 shows a preset mapping table containing 6 mapping entries.
TABLE 1
| Serial number | IP address | Subnet mask | Port numbering | Port state | VPN name |
| 1 | 192.168.1.2 | 255.255.255.0 | 1 | UP | A |
| 2 | 192.168.1.2 | 255.255.255.0 | 2 | UP | A |
| 3 | 192.168.1.3 | 255.255.255.0 | 3 | DOWN | A |
| 4 | 192.168.1.3 | 255.255.255.0 | 4 | UP | A |
| 5 | 192.168.1.4 | 255.255.255.0 | 5 | DOWN | A |
| 6 | 172.16.11.5 | 255.255.0.0 | 6 | UP | A |
The working personnel configure a preset IP address pool on the server, the IP address in the preset IP address pool is the IP address used by the local area network, for example, the value range of the IP address in the preset IP address pool is 192.168.1.0-192.168.16.0.
And comparing the IP address in the preset mapping relation table with the IP address in the preset IP address pool, and if the IP address in the mapping relation table does not exist in the preset IP address pool, defining the IP address in the preset mapping relation table as an abnormal IP address.
In this embodiment, taking the mapping relationship entries in table 1 as an example, the IP addresses in all the mapping relationship entries are extracted, and the IP addresses are sequentially compared with the IP addresses in the preset IP address pool, and since the IP address 172.16.11.5 corresponding to the sequence number 6 is not in the range of 192.168.1.0-192.168.16.0, 172.16.11.5 is defined as an abnormal IP address.
Because the abnormal IP address interferes with the division of the IP address types in the local area network, the mapping relationship entry corresponding to the abnormal IP address needs to be deleted from the preset mapping relationship table, so as to obtain table 2.
TABLE 2
| Serial number | IP address | Subnet mask | Port numbering | Port state | VPN name | Type of IP address |
| 1 | 192.168.1.2 | 255.255.255.0 | 1 | UP | A | |
| 2 | 192.168.1.2 | 255.255.255.0 | 2 | UP | A | Multiplexing IP addresses |
| 3 | 192.168.1.3 | 255.255.255.0 | 3 | DOWN | A | Redundant IP address |
| 4 | 192.168.1.3 | 255.255.255.0 | 4 | UP | A | |
| 5 | 192.168.1.4 | 255.255.255.0 | 5 | DOWN | A | |
Step S300, dividing the types of the IP addresses in the preset mapping relation table, wherein the types of the IP addresses comprise multiplexing IP addresses and/or redundant IP addresses.
Comparing every two mapping relation items in a preset mapping relation table; if two mapping relation items exist, wherein the IP address and the VPN information are the same, and the port state is UP, the IP address corresponding to one of the mapping relation items is defined as a multiplexing IP address; and if two mapping relation entries with the same IP address and VPN information and different port states exist, defining the IP address corresponding to the mapping relation entry with the port state of DOWN as a redundant IP address.
Step S300 is illustrated below with reference to the preset mapping table shown in table 2. Mapping relation entries corresponding to sequence number 1 are 192.168.1.2, 255.255.255.0, 1, UP and a, mapping relation entries corresponding to sequence number 2 are 192.168.1.2, 255.255.255.0, 2, UP and a, and since port states in the mapping relation entries corresponding to sequence numbers 1 and 2 are both UP, 192.168.1.2 in the mapping relation entry corresponding to sequence number 2 is defined as a multiplexing IP address.
When a managed device with an IP address of 192.168.1.3 sends information to a managed device with an IP address of 192.168.1.2, since two identical IP addresses of 192.168.1.2 exist in the lan and the corresponding port states are both UP states, 192.168.1.3 does not know which managed device with an IP address of 192.168.1.2 is sent to, and a situation may occur that 192.168.1.3 information does not reach the corresponding managed device, so deleting one of the mapping relation entries and deleting a multiplexing IP address on the management device corresponding to the mapping relation entry, for example deleting the mapping relation entry of 192.168.1.2, 255.255.255.0, 2, UP, and a, and reallocating an IP address to the managed device with the IP address deleted, in this embodiment, reallocating an IP address to the managed device with the IP address deleted is not specifically limited.
In table 2, mapping entries corresponding to sequence number 3 are 192.168.1.3, 255.255.255.0, 3, DOWN, and a, mapping entries corresponding to sequence number 4 are 192.168.1.3, 255.255.255.0, 3, UP, and a, and since the state of the first port corresponding to sequence number 3 is DOWN, the IP address corresponding to sequence number 3 is defined as a redundant IP address. When the port status of the redundant IP address is changed from DOWN to UP, the redundant IP address is changed to a multiplexing IP address, so that the mapping relationship entry corresponding to the redundant IP address in the preset mapping relationship table and the redundant IP address on the corresponding managed device need to be deleted, and the IP address needs to be reallocated to the managed device.
And deleting mapping relation entries corresponding to the abnormal IP address, the multiplexing IP address and the redundant IP address in the table 1 to obtain a table 3.
TABLE 3
| Serial number | IP address | Subnet mask | Port numbering | Port state | VPN name | Type of IP address |
| 1 | 192.168.1.2 | 255.255.255.0 | 2 | UP | A | |
| 2 | 192.168.1.3 | 255.255.255.0 | 4 | UP | A | |
| 3 | 192.168.1.4 | 255.255.255.0 | 5 | DOWN | A | Recyclable IP address |
And if the duration time of the port state DOWN reaches the preset time, defining the IP address corresponding to the port state DOWN as the recyclable IP address.
In this embodiment, the preset time may be one day, a mapping relationship entry with a port state of DOWN in a preset mapping relationship table is extracted, if the duration of the port state of DOWN reaches one day, the IP address corresponding to the port is defined as a recoverable IP address, and the mapping relationship entry is deleted in the preset mapping relationship table, such as the relationship mapping entry shown in table 3, the mapping relationship entry corresponding to sequence number 3 should be deleted, and the recoverable IP address is deleted on the corresponding managed device, at this time, 192.168.1.4 in the preset IP address pool is defined as an unused IP address, other managed devices are reallocated, and the problem of waste of IP addresses is reduced.
After classifying the IP addresses in the preset mapping relationship table, the IP addresses in the preset IP address pool need to be divided into available IP addresses and unused IP addresses based on the IP addresses in the preset mapping relationship table.
Specifically, as shown in fig. 2, dividing the IP addresses in the preset IP address pool includes the following steps:
step S401, obtaining an IP address in a preset mapping relation table and a subnet mask corresponding to the IP address;
step S402, converting the IP address into a network address based on the IP address and the subnet mask;
in this embodiment, the IP address 192.168.1.255 and the subnet mask 255.255.255.192 are used as an example, and both the IP address and the subnet mask corresponding to the IP address are converted into binary values, where both the IP address and the subnet mask include 32-bit binary numbers. The binary system corresponding to the IP address 192.168.1.255 is 11000000.10101000.00000001.11100001, the binary system corresponding to the subnet mask is 11111111.11111111.11000000, each bit of the IP address corresponds to each bit of the subnet mask one by one, and bit and operation is performed to obtain the network address, wherein the network address corresponding to 192.168.1.255 and 255.255.192 is 11000000.10101000.11000000, and the network address is converted into the decimal system 192.168.1.192.
Step S403, dividing the network segment corresponding to the network address in the preset IP address pool into used network segments, and dividing the rest network segments in the preset IP address pool into unused network segments.
In this embodiment, network addresses corresponding to all IP addresses in the preset mapping table are obtained, whether the same network address exists in the preset mapping table is searched for, if yes, redundant network addresses are deleted, a network segment to which the network address corresponding to the IP address in the preset mapping table belongs is defined as a used network segment, and a remaining network segment in the preset IP address pool is defined as an unused network segment. The IP address in the used network segment is the used IP address in the preset IP address pool; and the IP address in the unused network segment is an unused IP address in a preset IP address pool.
Taking the network addresses in step S401 and step S402 as an example, since the network segments 192.168.1.192 to 192.168.1.255 correspond to 192.168.1.192, 192.168.1.192 to 192.168.1.255 are divided into used IP addresses in the preset IP address pool.
Fig. 3 is a block diagram of an IPaddress management apparatus 500 according to an embodiment of the present application. As shown in fig. 3, the IPaddress management apparatus 500 mainly includes:
an obtainingmodule 501, configured to obtain multiple pieces of connection information of all managed devices, where the connection information includes an IP address of the managed device, a number and a state of a first port corresponding to the IP address, and a number and a state of a second port corresponding to VPN information and VPN information;
a generating and addingmodule 502, configured to generate a mapping relationship entry including an IP address corresponding to a number of a first port, VPN information corresponding to a number of a second port, and a port state if the number of the first port is the same as the number of the second port in the plurality of connection information, and add the mapping relationship entry to a preset mapping relationship table;
thefirst dividing module 503 is configured to divide the types of the IP addresses in the preset mapping relationship table, where the types of the IP addresses include a multiplexing IP address and/or a redundant IP address.
As an optional implementation manner of this embodiment, thefirst dividing module 503 includes:
the comparison submodule is used for comparing every two mapping relation items in the preset mapping relation table;
the first definition sub-module is used for defining the IP address corresponding to one mapping relation item as a multiplexing IP address if two mapping relation items exist, wherein the IP address and the VPN information are the same, and the port state is UP;
and the second definition sub-module is used for defining the IP address corresponding to the mapping relation item with the port state of DOWN as a redundant IP address if two mapping relation items with the same IP address and VPN information and different port states exist.
In this optional embodiment, the IP address management apparatus 400 further includes:
and the first deleting module is used for deleting the mapping relation item to which the multiplexing IP address belongs in the preset mapping relation table and deleting the multiplexing IP address on the managed equipment after the IP address corresponding to one of the mapping relation items is defined as the multiplexing IP address.
In this optional embodiment, the IP address management apparatus 400 further includes:
and the second deleting module is used for deleting the mapping relation item to which the redundant IP address belongs in the preset mapping relation table and deleting the redundant IP address on the managed equipment after the IP address corresponding to the mapping relation item with the port state of DOWN is defined as the redundant IP address.
As an optional implementation manner of this embodiment, the IP address management apparatus 400 further includes:
the comparison definition module is used for comparing the IP address in the preset mapping relation table with the IP address in the preset IP address pool after the mapping relation item is added into the preset mapping relation table; and if the IP address in the mapping relation table does not exist in the preset IP address pool, defining the IP address in the preset mapping relation table as an abnormal IP address.
And the third deleting module is used for deleting the mapping relation items to which the abnormal IP addresses belong in the preset mapping relation table before the types of the IP addresses in the preset mapping relation table are divided.
As an optional implementation manner of this embodiment, the IP address management apparatus 400 further includes:
the acquisition definition module is used for acquiring port state information of a first port number after dividing the IP addresses in the preset mapping relation table, and the port state information represents the service condition of the ports; and if the duration time of the port state DOWN reaches the preset time, defining the IP address corresponding to the port state DOWN as the recyclable IP address.
In this optional embodiment, the IP address management apparatus 400 further includes:
a definition deleting module, configured to delete a mapping relationship entry to which a recyclable IP address belongs in a preset mapping relationship table after an IP address corresponding to a DOWN port state is defined as the recyclable IP address, and delete the recyclable IP address from a corresponding managed device;
and the second division module is used for dividing the IP address which is the same as the recyclable IP address in the preset IP address pool into unused IP addresses.
As an optional implementation manner of this embodiment, the mapping relationship entry further includes a subnet mask corresponding to the IP address; the IP address management apparatus 400 further includes:
the obtaining and adding module is used for obtaining the IP address in the preset mapping relation table and the subnet mask corresponding to the IP address after the mapping relation item is added into the preset mapping relation table;
a conversion module for converting the IP address into a network address based on the IP address and the subnet mask;
and the third division module is used for dividing the network segments corresponding to the network addresses in the preset IP address pool into used network segments and dividing the rest network segments in the preset IP address pool into unused network segments.
The functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part. The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product, where the computer software product is stored in a storage medium and includes several instructions to enable an electronic device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the IP address management method according to the embodiments of the present application.
Fig. 4 is a block diagram of an IPaddress management device 600 according to an embodiment of the present application. As shown in fig. 4, the IPaddress management apparatus 600 includes amemory 601, aprocessor 602, and acommunication bus 603; the memory,processor 602 are connected by acommunication bus 603. Thememory 601 stores thereon an IP address management method capable of being loaded and executed by theprocessor 602 as provided in the above-described embodiments.
Thememory 601 may be used to store instructions, programs, code, sets of codes, or sets of instructions. Thememory 601 may include a storage program area and a storage data area, wherein the storage program area may store instructions for implementing an operating system, instructions for at least one function, and instructions for implementing the IP address management method provided by the above-described embodiments, and the like; the storage data area may store data and the like involved in the IP address management method provided by the above-described embodiment.
Processor 602 may include one or more processing cores. Theprocessor 602 executes various functions of the present application and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in thememory 601 to invoke data stored in thememory 601. TheProcessor 602 may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understood that the electronic devices for implementing the functions of theprocessor 502 may be other devices, and the embodiments of the present application are not limited in particular.
Communication bus 603 may include a path that conveys information between the aforementioned components. Thecommunication bus 603 may be a PCI (PerIPheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. Thecommunication bus 603 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 4, but that does not indicate only one bus or one type of bus.
Embodiments of the present application provide a computer-readable storage medium storing a computer program that can be loaded by a processor and execute the IP address management method provided in the above embodiments.
In this embodiment, the computer readable storage medium may be a tangible device that retains and stores instructions for use by an instruction execution device. The computer readable storage medium may be, but is not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any combination of the foregoing. In particular, the computer readable storage medium may be a portable computer diskette, a hard disk, a U-disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a podium random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, an optical disk, a magnetic disk, a mechanical coding device, and any combination thereof.
The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the application referred to in the present application is not limited to the embodiments with a particular combination of the above-mentioned features, but also encompasses other embodiments with any combination of the above-mentioned features or their equivalents without departing from the spirit of the application. For example, the above features may be replaced with (but not limited to) features having similar functions as those described in this application.