[go: up one dir, main page]

CN114357274B - IP information query method and device - Google Patents

IP information query method and device Download PDF

Info

Publication number
CN114357274B
CN114357274B CN202111621861.8A CN202111621861A CN114357274B CN 114357274 B CN114357274 B CN 114357274B CN 202111621861 A CN202111621861 A CN 202111621861A CN 114357274 B CN114357274 B CN 114357274B
Authority
CN
China
Prior art keywords
address
character string
record
information
section
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
CN202111621861.8A
Other languages
Chinese (zh)
Other versions
CN114357274A (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.)
China Telecom Corp Ltd
Original Assignee
China Telecom Corp 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 China Telecom Corp Ltd filed Critical China Telecom Corp Ltd
Priority to CN202111621861.8A priority Critical patent/CN114357274B/en
Publication of CN114357274A publication Critical patent/CN114357274A/en
Application granted granted Critical
Publication of CN114357274B publication Critical patent/CN114357274B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明实施例提供了一种IP信息查询方法及装置,该方法包括从检测到的IP信息查询请求中确定出对应的IP地址,按照设定的掩码位,对IP地址进行按位切分处理,确定出第一IP字符串,确定第一级联式IP记录中是否存在所述第一IP字符串,若是,则在确定第一级联式IP记录中不存在与第一IP字符串关联的IP信息时,将IP地址与第二级联式IP记录中的各IP地址进行匹配,以此确定出IP地址对应的IP信息。如此,该方案通过针对IP地址进行按掩码位进行切分,可以有效地节省因针对IP地址进行转换运算所耗费的时间,且只针对第一级联式IP记录中未存储IP信息的IP地址进行第二级查询,从而可以有效地提高IP信息的查询效率。

The embodiment of the present invention provides an IP information query method and device, the method comprising determining the corresponding IP address from the detected IP information query request, performing bit segmentation processing on the IP address according to the set mask bit, determining the first IP string, determining whether the first IP string exists in the first cascade IP record, and if so, when it is determined that the IP information associated with the first IP string does not exist in the first cascade IP record, matching the IP address with each IP address in the second cascade IP record, thereby determining the IP information corresponding to the IP address. In this way, the scheme can effectively save the time consumed by performing conversion operations on the IP address by segmenting the IP address according to the mask bit, and only performs the second-level query on the IP address for which the IP information is not stored in the first cascade IP record, thereby effectively improving the query efficiency of the IP information.

Description

IP information query method and device
Technical Field
The embodiment of the invention relates to the technical field of network and information security, in particular to an IP information query method and device.
Background
With the development of computer technology, in some big data processing, an IP address query is required, and generally, in order to query related information corresponding to an IP, the query is required according to an IP database.
At present, there are two general IP information query methods, namely, the first IP information query method is to store each IP address in a database (such as rediss or mysql) in advance according to an address segment, and meanwhile, the starting IP and the ending IP of each IP address segment in the database need to be converted into long integers in advance for storage, so that the subsequent matching query for the IP address is facilitated. When the related information corresponding to a certain IP address needs to be queried, the IP address needs to be converted into a long integer, and then the converted IP address and each converted IP address segment are matched and queried, so that the related information corresponding to the IP address needing to be queried is queried. However, this method of querying an IP address requires conversion and then matching query for the IP address, which requires a long time, resulting in low query efficiency of IP information. The second way of querying the IP information is that each IP address is directly stored in a database (such as Redis or mysql) in advance, and when related information corresponding to a certain IP address needs to be queried, the IP address is directly compared with each IP address in the database, so that related information corresponding to the IP address needing to be queried is queried. However, when the IP address query mode is used for querying the IP address on a large scale, the IP address query mode needs to be compared with each IP address in the database, so that the query efficiency of the IP information is low, the requirement on the cache capacity is high, and the hardware resource investment is large.
In summary, there is a need for an IP information query method to effectively improve the query efficiency of IP information.
Disclosure of Invention
The embodiment of the invention provides an IP information query method and device, which are used for effectively improving the query efficiency of IP information.
In a first aspect, an embodiment of the present invention provides an IP information query method, including:
When an IP information inquiry request aiming at any network protocol IP address is detected, determining a corresponding IP address from the IP information inquiry request;
Performing bit-wise segmentation processing on the IP address according to the set mask bit to determine a first IP character string;
Determining whether the first IP character string exists in a first cascaded IP record;
If yes, when the first cascade type IP record does not have the IP information related to the first IP character string, the IP address is matched with each IP address in the second cascade type IP record, and when the matching is successful, the IP information corresponding to the IP address is determined.
In the above technical solution, when the IP information corresponding to the IP address is queried in the prior art solution, the IP address needs to be converted to match or the IP address needs to be directly matched, but a certain time is consumed to match the IP address, so that the query efficiency of the IP information is low. Aiming at the problem, the technical scheme of the invention is to split the IP address according to mask bits instead of adding different weights after converting the IP address, so that the time cost can be effectively reduced, the hierarchical inquiry in the second cascade IP record is further carried out only for the IP address without associated IP information in the first cascade IP record, and the corresponding IP information can be timely and accurately inquired only in the first cascade IP record for the IP address with associated IP information in the first cascade IP record, so that the storage cost of the IP address can be effectively reduced, and the inquiry efficiency of the IP information can be effectively improved. Specifically, when an IP information query request for any IP address is detected, the corresponding IP address may be resolved from the IP information query request, and according to a set mask bit, bitwise slicing may be performed on the IP address to obtain the first IP string, so that time consumed for adding different weights after conversion of the IP address may be saved. And then determining whether the first IP character string exists in the first cascaded IP record, which is equivalent to performing first-stage matching on the IP address, if it is determined that the first IP character string exists in the first cascaded IP record but no IP information associated with the first IP character string exists, it is necessary to match the IP address corresponding to the first IP character string with each IP address in the second cascaded IP record, and determining the IP information corresponding to the IP address when the matching is determined to be successful, that is, only if a certain first IP character string is stored in the first cascaded IP record but no IP information associated with the first IP character string is stored, performing second-stage query on the IP address corresponding to the first IP character string is performed, and then reducing the query time (because a certain first IP character string is stored in the first cascaded IP record and the IP address corresponding to the IP information associated with the first IP character string is stored in the first cascaded IP record), so that the cost of only storing the first IP address corresponding to the first IP character string can be greatly reduced. In this way, the scheme can effectively save the time consumed by adding different weights after the conversion of the IP address by dividing the IP address according to the mask bit, and only perform the second-level query on the IP address corresponding to the IP information which is not stored with the first IP character string and is associated with the first IP character string in the first cascade type IP record, thereby effectively improving the query efficiency of the IP information.
Optionally, the method further comprises:
And when the first cascade type IP record is determined to have the IP information associated with the first IP character string, determining the IP information as the IP information corresponding to the IP address.
According to the technical scheme, when the first cascade IP record is determined to store the first IP character string and the IP information associated with the first IP character string is stored, the IP information corresponding to the first IP character string can be directly inquired from the first cascade IP record, namely the IP information of the IP address corresponding to the first IP character string, and the second-stage inquiry is not needed for the IP address, so that the inquiry times for the IP address can be effectively reduced, and the inquiry efficiency of the IP information is effectively improved.
Optionally, the first cascaded IP record is used for indicating to perform a first-level query on the IP address, the second cascaded IP record is used for indicating to perform a second-level query on the IP address, and the second-level query belongs to the hierarchical query of the first-level query.
In the above technical solution, each IP address is divided into two types of IP addresses, that is, an IP address having an attribute of a whole IP segment and an IP address not having an attribute of a whole IP segment, according to the attribute of each IP address (i.e., the tag attribute carried by each IP address after IP address allocation according to different areas, such as a country or a city, or according to different enterprises, etc.). Because at least one IP address having the whole IP attribute belongs to the same region or the same enterprise, that is, based on the characteristic that a certain segment (such as segment C) of the IP addresses is relatively concentrated, the second character string corresponding to the at least one IP address having the whole IP attribute and the corresponding IP information are stored in the first cascaded IP record, and the IP address not having the whole IP segment attribute (that is, a small part of scattered IP is not located in the whole IP segment) and the corresponding IP information are stored in the second cascaded IP record, so that the query located in the whole IP segment (IP start address-IP end address) can be effectively reduced later. The second cascade type IP record is used for carrying out second-level inquiry on the IP address, namely the IP address which needs to be subjected to hierarchical inquiry is subjected to second-level inquiry, for example, a first IP character string corresponding to a certain IP address exists in the first cascade type IP record, but the IP information associated with the first IP character string does not exist in the first cascade type IP record, so that the second-level inquiry on the IP address in the second cascade type IP record is required to be carried out in order to inquire the IP information associated with the first IP character string, namely the IP address is subjected to hierarchical inquiry, and the IP information corresponding to the IP address is possibly inquired.
Optionally, the performing bitwise slicing processing on the IP address according to the set mask bit, to determine a first IP string, includes:
And carrying out bit-wise segmentation processing on the IP address in a preset direction according to the set mask bit to obtain the first IP character string conforming to the set mask bit, wherein the preset direction is from left to right or from right to left.
In the above technical solution, after the set mask bit is determined, the set mask bit is used as a segmentation reference, and the IP address is segmented according to a preset direction (for example, from left to right or from right to left), so that the first IP character string conforming to the set mask bit can be accurately obtained.
Optionally, the performing a bitwise slicing process on the IP address in a preset direction to obtain the first IP string that conforms to the set mask bit includes:
if the set mask bit is 24, carrying out bit slicing treatment on the IP address in order from left to right to obtain the first IP character string formed by the section A, the section B and the section C of the IP address, or carrying out bit slicing treatment on the section D of the IP address in order from right to left to obtain the first IP character string formed by the section A, the section B and the section C of the IP address;
If the set mask bit is 16, the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the IP address in the order from left to right, or the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the section C and the section D of the IP address in the order from right to left.
In the above technical solution, based on the characteristics of the IP address (i.e., the IP address is composed of a section a, a section B, a section C and a section D, each section is converted into a binary system to occupy 8 bits, i.e., 8 bits), and the performance of using the IP address according to each current industry or each region, it can be known that there are two mask bits that are generally set, one is 24, and one is 16, that is, when the mask bit is set to 24, the IP address is subjected to bit slicing processing in the order from left to right, or the section D of the IP address is subjected to bit slicing processing in the order from right to left, so that the first IP string composed of the section a, the section B and the section C can be accurately obtained. When the set mask bit is 16, the bit cutting processing is carried out on the IP address in the order from left to right, or the bit cutting processing is carried out on the C section and the D section of the IP address in the order from right to left, so that the first IP character string consisting of the A section and the B section can be accurately obtained. Therefore, the scheme is convenient for subsequent quick inquiry of the IP information corresponding to the IP address through the first IP character string.
Optionally, the first cascaded IP record and the second cascaded IP record are determined by:
Acquiring each IP address with the integral IP section attribute, each IP information corresponding to each IP address with the integral IP section attribute, each IP address without the integral IP section attribute and each IP information corresponding to each IP address without the integral IP section attribute from an IP home base;
according to the set mask bit, respectively carrying out bit-wise segmentation processing on each IP address with the whole IP section attribute and each IP address without the whole IP section attribute to obtain each second IP character string corresponding to each IP address with the whole IP section attribute and each second IP character string corresponding to each IP address without the whole IP section attribute;
Storing each second IP string corresponding to each IP address having the whole IP section attribute, each IP information corresponding to each IP address having the whole IP section attribute, and each second IP string corresponding to each IP address not having the whole IP section attribute into the first cascaded IP record, and storing each IP address not having the whole IP section attribute, each IP information corresponding to each IP address not having the whole IP section attribute into the second cascaded IP record.
In the above technical solution, it may be determined, through the IP home base, which IP addresses in the IP home base belong to whole IP segments, and which IP addresses belong to non-whole IP segments (i.e. scattered IP), so when dividing each IP address into two-level IP records (i.e. a first cascaded IP record and a second cascaded IP record), it is first required to determine a mask bit, for example, according to the current use situation of each region (e.g. according to a city level) and each industry for the IP addresses, that is, based on the characteristic that a certain segment (e.g. a C segment) of the IP address is relatively concentrated, for example, some cities are allocated to a certain whole IP segment (e.g. whole C segment), where the whole IP segment contains a plurality of IP addresses, or some cities are allocated to a certain non-whole IP segment, for example, some or some equal scattered IP addresses are allocated to a certain non-whole IP segment. Based on the characteristic that a certain segment (such as a C segment) of the IP address is relatively concentrated, when a certain IP address belonging to the C segment is queried, corresponding IP information can be quickly obtained through an IP character string formed by the A segment, the B segment and the C segment of the IP address (because the A segment, the B segment and the C segment already represent the attribute of the IP address, the matching of the D segment is not needed, so that the whole IP address is not needed to be matched, and for the IP address with the attribute of the whole IP segment, the matching can be quickly and accurately completed only by a part of information in the IP address), and in order to facilitate the query efficiency of the subsequent IP address, the bit-wise segmentation processing is performed for each IP address with the attribute of the whole IP segment and each IP address without the attribute of the whole IP segment according to the set mask bit. Meanwhile, as the corresponding IP information can be inquired through the first-stage inquiry without the second-stage hierarchical inquiry, the corresponding IP information can be inquired through the second-stage hierarchical inquiry for the IP address without the integral IP section attribute, so that the first cascade IP record only stores the corresponding IP information for the IP address with the integral IP section attribute (as the IP address with the integral IP section attribute does not need to be matched with the D section of the IP address, only the A section, the B section and the C section of the IP address can be quickly and accurately matched), so that the inquiry times for the IP address with the integral IP section attribute can be effectively reduced, and the second cascade IP record only stores the corresponding IP information for the IP address without the integral IP section attribute (as the IP address without the integral IP section attribute needs to be matched with the D section of the IP address, the second cascade IP record is set for the second-stage inquiry for the D section, namely the hierarchical inquiry for the D section of the IP address is required to be carried out, and the corresponding IP address without the integral IP section attribute is inquired. Therefore, the scheme can effectively improve the query performance of the IP information by constructing two-stage IP records (namely a first cascade IP record and a second cascade IP record) for carrying out IP information query on IP addresses with different IP attributes (such as a whole IP segment attribute and a non-whole IP segment attribute).
Optionally, determining whether the first IP string exists in the first cascaded IP record includes:
and sequentially matching the first IP character string with each second IP character string in the first cascade type IP record in a preset matching mode, so as to determine whether the first IP character string exists in the first cascade type IP record.
In the above technical solution, when a first level inquiry is performed on a certain IP address through the first cascaded IP record, that is, a first IP string corresponding to the IP address is sequentially matched with each second IP string in the first cascaded IP record, and when it is determined that the first IP string is successfully matched with a certain second IP string, IP information associated with the second IP string can be determined as IP information corresponding to the IP address.
In a second aspect, an embodiment of the present invention further provides an IP information query apparatus, including:
The detection unit is used for determining the corresponding IP address from the IP information inquiry request when the IP information inquiry request aiming at any network protocol IP address is detected;
The processing unit is used for carrying out bit-wise segmentation processing on the IP address according to a set mask bit to determine a first IP character string, determining whether the first IP character string exists in a first cascade IP record, if so, matching the IP address with each IP address in a second cascade IP record when determining that the IP information related to the first IP character string does not exist in the first cascade IP record, and determining the IP information corresponding to the IP address when matching is successful.
Optionally, the processing unit is further configured to:
And when the first cascade type IP record is determined to have the IP information associated with the first IP character string, determining the IP information as the IP information corresponding to the IP address.
Optionally, the first cascaded IP record is used for indicating to perform a first-level query on the IP address, the second cascaded IP record is used for indicating to perform a second-level query on the IP address, and the second-level query belongs to the hierarchical query of the first-level query.
Optionally, the processing unit is specifically configured to:
And carrying out bit-wise segmentation processing on the IP address in a preset direction according to the set mask bit to obtain the first IP character string conforming to the set mask bit, wherein the preset direction is from left to right or from right to left.
Optionally, the processing unit is specifically configured to:
if the set mask bit is 24, carrying out bit slicing treatment on the IP address in order from left to right to obtain the first IP character string formed by the section A, the section B and the section C of the IP address, or carrying out bit slicing treatment on the section D of the IP address in order from right to left to obtain the first IP character string formed by the section A, the section B and the section C of the IP address;
If the set mask bit is 16, the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the IP address in the order from left to right, or the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the section C and the section D of the IP address in the order from right to left.
Optionally, the processing unit is specifically configured to:
Acquiring each IP address with the integral IP section attribute, each IP information corresponding to each IP address with the integral IP section attribute, each IP address without the integral IP section attribute and each IP information corresponding to each IP address without the integral IP section attribute from an IP home base;
according to the set mask bit, respectively carrying out bit-wise segmentation processing on each IP address with the whole IP section attribute and each IP address without the whole IP section attribute to obtain each second IP character string corresponding to each IP address with the whole IP section attribute and each second IP character string corresponding to each IP address without the whole IP section attribute;
Storing each second IP string corresponding to each IP address having the whole IP section attribute, each IP information corresponding to each IP address having the whole IP section attribute, and each second IP string corresponding to each IP address not having the whole IP section attribute into the first cascaded IP record, and storing each IP address not having the whole IP section attribute, each IP information corresponding to each IP address not having the whole IP section attribute into the second cascaded IP record.
Optionally, the processing unit is specifically configured to:
and sequentially matching the first IP character string with each second IP character string in the first cascade type IP record in a preset matching mode, so as to determine whether the first IP character string exists in the first cascade type IP record.
In a third aspect, an embodiment of the present invention provides a computing device, including at least one processor and at least one memory, where the memory stores a computer program, and when the program is executed by the processor, causes the processor to execute the IP information query method described in any of the first aspects above.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium storing a computer program executable by a computing device, where the program, when executed on the computing device, causes the computing device to perform the IP information query method according to any of the first aspects.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of an IP information query method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a C-domain dictionary table and a D-domain dictionary table constructed based on a static IP address list according to an embodiment of the present invention;
Fig. 3 is a schematic structural diagram of an IP information query apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a computing device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 schematically illustrates a flow of an IP information query method according to an embodiment of the present invention, where the flow may be executed by an IP information query device.
As shown in fig. 1, the process specifically includes:
step 101, when an IP information inquiry request for any network protocol IP address is detected, determining a corresponding IP address from the IP information inquiry request.
In some big data processing embodiments of the present invention, an IP address query may be required to query the relevant IP information of the IP address. Based on this, if a certain user wants to query the relevant IP information of a certain IP address, an IP information query request needs to be generated by a client in a used terminal device (such as a notebook, desktop, smart phone or other network device, etc.), where the IP information query request includes the IP address. Or the IP information inquiry command is edited and generated on a client in the used terminal equipment, and the IP information inquiry command contains an IP address. The IP information query method is performed by an IP information query device, which may be a network device (such as a computer) or a communication device capable of supporting functions required for the network device to implement the method, such as a system on a chip. Wherein, a plurality of users can initiate a plurality of IP information inquiry requests or a plurality of IP information inquiry instructions to the network equipment in batches in a parallel mode, the network device performs batch processing for batch IP information inquiry requests or IP information inquiry instructions. And the user can also generate a plurality of IP information inquiry requests or a plurality of IP information inquiry instructions in batch at the same time, and the plurality of IP information inquiry requests or the plurality of IP information inquiry instructions are sent to the network equipment. For example, taking an IP information query request or an IP information query instruction as an example, an IP information query request or an IP information query instruction generated by a user is sent to the network device, and after detecting the IP information query request or the IP information query instruction sent by the user, the network device may perform parsing processing on the IP information query request or the IP information query instruction, so that a corresponding IP address may be parsed.
And 102, carrying out bit-wise segmentation processing on the IP address according to the set mask bit to determine a first IP character string.
In the embodiment of the invention, after the network equipment analyzes the IP address contained in a certain IP information inquiry request, bit-wise segmentation processing can be performed on the IP address according to the set mask bit, so as to determine the first IP character string. Wherein, the set mask bit is set in advance based on the requirements of the actual application scenario (i.e. the mask bits that may be required by different application scenarios are different). That is, since each IP string stored in the first cascaded IP record is also generated by splitting each IP address according to a set mask bit, so that the query efficiency of the IP address is convenient to improve, after the IP address is resolved, the first IP string conforming to the set mask bit needs to be accurately obtained by performing bit-wise splitting processing on the IP based on a preset direction according to the set mask bit, that is, taking the set mask bit as a splitting reference. The preset direction is from left to right or from right to left.
When the IP address is subjected to bitwise slicing in a preset direction, based on the characteristics of the IP address (i.e., the IP address is composed of a section a, a section B, a section C and a section D, each section is converted into a binary system to occupy 8 bits, i.e., 8 bits), and the behavior of using the IP address according to the current industries or regions (such as city level), that is, based on the characteristics that a certain section (such as section C) of the IP address is relatively concentrated, such as that a certain city is allocated to a certain whole IP section (such as whole section C), and the whole IP section contains a plurality of IP addresses, or that a certain city is allocated to a certain non-whole section IP, for example, a certain or a certain number of equal scattered IP addresses, it can be known that the mask bits which are generally set are two, one is 24, and one is 16. That is, if the set mask bit is 24, the IP address is bitwise cut in the order from left to right, or the segment D of the IP address is bitwise cut in the order from right to left, so that the first IP character string composed of the segment a, the segment B, and the segment C can be accurately obtained. If the set mask bit is 16, the bit slicing processing is performed on the IP address in the order from left to right, or the bit slicing processing is performed on the C section and the D section of the IP address in the order from right to left, so that the first IP character string formed by the A section and the B section of the IP address can be accurately obtained. Therefore, the scheme is convenient for subsequent quick inquiry of the IP information corresponding to the IP address through the first IP character string.
Taking a mask bit as 24 as an example and taking a preset direction as left to right as an example, performing primary segmentation according to the position of mask=/24 when an IP address contained in a certain IP information query request generated by a certain user is a.b.c.d, that is, performing bitwise segmentation on the IP address in order from left to right, and stopping segmentation to c, wherein the segmentation to c just meets 24 bits, so that an IP character string "a.b.c" can be extracted from the IP address, the IP character string is sequentially matched with each second IP character string in a first cascade IP record, if the IP character string is not matched, the IP address corresponding to the IP character string is discarded, if the IP address is matched, it is determined that the IP character string belongs to an integral IP segment or a non-integral IP segment, because in a first cascade IP record, the IP character string belonging to the integral IP segment is stored in a key value pair form (that is, the IP character string is used as key y, the IP character string is used as a value), if the IP character string is not matched with each second IP character string in the first cascade IP record, if the IP character string does not belong to the integral IP segment, and if the IP character string does not belong to the integral IP segment, the IP character string is not belong to the integral IP segment, and if the IP string is not required to be directly stored in the first cascade IP record. Or, for example, if the IP address included in a certain IP information query request generated by a certain user is 45.115.45.3, the segmentation is performed once according to the position of mask=/24, that is, in order from left to right, the segmentation is performed according to bits for the IP address, and 5 before the segmentation is 3 stops, because 5 before the segmentation is 3 just meets 24 bits, so that an IP character string "45.115.45" can be extracted from the IP address.
Step 103, determining whether the first IP character string exists in the first cascaded IP record.
In the embodiment of the invention, before judging whether the first cascade type IP record has the first IP character string, the first cascade type IP record and the second cascade type IP record need to be determined in advance. It should be noted that each IP address may be divided into two types of IP addresses, i.e., an IP address having an entire IP segment attribute and an IP address not having an entire IP segment attribute, by an attribute (a tag attribute carried by each IP address after IP address assignment is performed in different areas such as country or city, or in different enterprises, etc.). Because at least one IP address having the whole IP attribute belongs to the same region or the same enterprise, that is, based on the characteristic that a certain segment (such as segment C) of the IP addresses is relatively concentrated, the second character string corresponding to the at least one IP address having the whole IP attribute and the corresponding IP information are stored in the first cascaded IP record in the form of a key value pair, and the IP address not having the whole IP segment attribute (that is, a small part of the scattered IP is not located in the whole IP segment) and the corresponding IP information are stored in the second cascaded IP record in the form of a key value pair, so that the query located in the whole IP segment (IP start address-IP end address) can be effectively reduced later. The first cascade type IP record is used for indicating to perform first-level inquiry aiming at the IP address, the second cascade type IP record is used for indicating to perform second-level inquiry aiming at the IP address, and the second-level inquiry belongs to hierarchical inquiry of the first-level inquiry. For example, a first IP string corresponding to an IP address exists in a first cascaded IP record, but the IP information associated with the first IP string does not exist in the first cascaded IP record, so in order to query the IP information associated with the first IP string, it is necessary to perform a second-level query for the IP address in a second cascaded IP record, that is, it is equivalent to performing a hierarchical query for the IP address, so that it is possible to query the IP information corresponding to the IP address.
Specifically, when determining the first cascaded IP record and the second cascaded IP record, it may be determined, through the IP home library, which IP addresses in the IP home library belong to the whole IP segment and which IP addresses belong to the non-whole IP segment (i.e., scattered IP), that is, each IP address having the whole IP segment attribute, each IP information corresponding to each IP address having the whole IP segment attribute, each IP address not having the whole IP segment attribute, and each IP information corresponding to each IP address not having the whole IP segment attribute may be obtained from the IP home library. At this time, it is also necessary to perform bit-wise slicing processing for each IP address having the whole IP segment attribute and each IP address not having the whole IP segment attribute in a predetermined direction (for example, from left to right or from right to left) according to the set mask bit, so that each second IP string corresponding to each IP address having the whole IP segment attribute and each second IP string corresponding to each IP address not having the whole IP segment attribute can be accurately obtained. In this way, compared with the existing first type of IP information query mode, the scheme does not need IP conversion operation (for example, the existing first type of IP information query mode adopts a classical red-black tree algorithm, and the specific search mode is that if the searched key is equal to the key of the root node, the search hits, otherwise, the search is continued in a proper subtree, if the searched key is smaller, the left subtree is selected, and the right subtree is selected larger, if the fruit tree is empty, the search misses. when the IP sections are too many, the red and black trees also become large, the depth of the tree becomes large, so that the query efficiency is reduced), the time cost can be effectively reduced, and the query efficiency for the IP address can be improved. Then, according to the functions of the first cascade IP record and the second cascade IP record, each second IP character string corresponding to each IP address with the whole IP section attribute, each IP information corresponding to each IP address with the whole IP section attribute are stored in the first cascade IP record in the form of key value pairs, each second IP character string corresponding to each IP address without the whole IP section attribute is stored in the first cascade IP record, each IP address without the whole IP section attribute, and each IP information corresponding to each IP address without the whole IP section attribute is stored in the second cascade IP record in the form of key value pairs. Thus, for the IP address with the whole IP section attribute, the corresponding IP information can be queried only by performing first-level query in the first-level cascaded IP record, and second-level query in the second-level cascaded IP record is not needed. For example, for a region, a plurality of IP addresses with a certain whole C-segment attribute are allocated to the region, and each second IP string composed of a segment a, a segment B and a segment C is stored in the first cascaded IP record, so that the matching of the whole IP address is not needed because the segments a, B and C already represent the attribute of the IP address, and for the IP address with the whole C-segment attribute, only a part of information in the IP address is needed to quickly and accurately complete the matching, thereby effectively reducing the number of times of querying the IP address with the whole IP segment attribute. For the IP address without the integral IP segment attribute, the first cascaded IP record is required to perform the second-stage query in the second cascaded IP record, that is, the IP address without the integral IP segment attribute is required to perform the matching of the IP character string composed of the a segment, the B segment and the C segment in the first cascaded IP record, and the matching of the D segment of the IP address is required to be performed in the second cascaded IP record (that is, the whole of the IP address is taken to perform the matching in the second cascaded IP record), so as to query the IP information corresponding to the IP address without the integral IP segment attribute.
Illustratively, the static IP address list (i.e., the IP address home library) is divided by masks that exist for large-scale whole IP segments, based on the characteristic that it is relatively concentrated in a certain mask segment (e.g., segment C of IP addresses), and the concatenated IP domains are constructed to reduce queries located within the whole IP segment. In order to fully exert the rapid searching performance of the database (such as Redis), the transverse key value of the comparison library can be expanded to 1000 ten thousand orders of magnitude, and the number of the longitudinal cascade Redis libraries is controlled to be 2-3. For example, to realize the scenario of identifying threat IP in information security wind control work, quick query for attribution is required in DNS (Domain NAME SYSTEM ) recursively resolved data for IP. Of these, IPv4 (Internet Protocol Version, fourth edition of Internet protocol) addresses total more than 42 hundred million worldwide, expressed in decimal form in the database as 0.0.0.0-255.255.255.255. In this IP home base, country and city information to which IP belongs is stored in intervals, where IP segments are commonly divided into cities in a minimum of 1C (a.b.c.0-a.b.c.255 contains 256/32 IP) as a basic unit, and a small number of address divisions are smaller than 1C. It is not desirable to split all IP segments into scattered IP for storage exclusively for these small network addresses. Therefore, the technical scheme of the invention can effectively improve the query performance of the IP information by constructing two-stage IP records (namely a first cascade IP record and a second cascade IP record) for carrying out IP information query on the IP addresses with different IP attributes (such as the whole IP section attribute and the non-whole IP section attribute) and caching by Redis.
Specifically, two-level library tables (i.e., a first cascaded IP record and a second cascaded IP record) of a C-domain (i.e., an a-segment, a B-segment, and a C-segment of an IP address) and a D-domain (i.e., an a-segment, a B-segment, a C-segment, and a D-segment of an IP address) are constructed for each IP address in a certain database (e.g., a rediss), where the C-domain dictionary table includes an entire IP segment and an irregular IP segment, so that most of the IP addresses only need to find/24C-segment, and a small portion of the scattered IP addresses are not in the entire IP segment, and are required to search D-segment, so that the cost of querying IP information is greatly reduced, such as first constructing the C-domain dictionary table, i.e., a C-segment prefix character string of mask for/24, and storing corresponding IP information (e.g., an attribute value of an IP address, such as which region or which IP address belongs to) for the entire IP segment in the C-domain dictionary table, and storing the corresponding IP information (e.g., an IP address) for the scattered non-entire IP segment, where the C-domain dictionary table is stored in the C-domain table is only for the C-segment, i.e., the C-segment corresponding to the C-segment, the C-segment is a character string of the C-segment, and the C-segment is used for storing the C-segment, and the character string of the C-segment is set for storing the text, if the C-segment is used for the prefix string is used for storing the C-segment, and the text string is used for storing the text.
For example, the implementation of constructing the C-domain dictionary table and the D-domain dictionary table is described taking a certain large-scale static IP library as shown in table 1 as an example.
TABLE 1
IP address range IP information
45.115.44.0~45.115.46.255 Some area 001
46.103.2.0~46.103.2.255 Certain area 002
... ...
47.132.44.2~47.132.44.255 Somewhere in 009
As can be seen from Table 1, there are a plurality of whole IP segments, such as 45.115.44-45.115.45, 45.115.45-45.115.46, etc., where a small number of regions have scattered IP addresses, such as the IP address corresponding to a certain region 009. In addition, it should be noted that, since the sections C in the IP address corresponding to the certain area 001 are relatively concentrated, that is, 45.115.44-45.115.45 and 45.115.45-45.115.46 are all associated with the certain area 001, it can be seen that the sections a, B and C in the IP address already represent the attribute of the IP address (that is, the attribute corresponding to the certain area 001), the IP information corresponding to the IP address (that is, the certain area 001) can be determined only by matching the IP character strings formed by the sections a, B and C, and the matching of the sections D is not required. For example, if the IP address corresponding to the region 009 does not have a whole IP segment, the IP address belongs to scattered IP addresses, and further query is required, that is, the corresponding IP information needs to be queried through the query of the D domain.
For each IP address in table 1, the IP string corresponding to each IP address may be obtained by performing a bitwise slicing process on each IP address according to a set mask bit (e.g., 24), for example, performing a bitwise slicing process on IP address 45.115.44.0 in table 1 in order from left to right according to a slicing reference of mask bit 24, so as to obtain IP string "45.115.44" corresponding to the IP address, or performing a bitwise slicing process on IP address 46.103.2.0 in table 1 in order from left to right according to a slicing reference of mask bit 24, so as to obtain IP string "46.103.2" corresponding to the IP address. And, for scattered IP addresses of non-whole IP segments, a D-field needs to be constructed, i.e. a mapping relationship between the IP complete address and the IP information is created. Thus, a C-domain dictionary table and a D-domain dictionary table for IP addresses as shown in table 2 can be constructed.
TABLE 2
When determining whether a first IP string exists in the first cascaded IP record, sequentially matching the first IP string with each second IP string in the first cascaded IP record by a preset matching method (such as a cosine similarity algorithm, a pearson correlation coefficient algorithm, or other character matching rules, etc.), so as to determine whether the first IP string exists in the first cascaded IP record. If the first cascade IP record does not have any second IP character string which is successfully matched with the first IP character string, the first IP character string can be determined to be present in the first cascade IP record, and if the first cascade IP record does not have any second IP character string which is successfully matched with the first IP character string, the first IP character string can be determined to be not present in the first cascade IP record, so that the IP address can be discarded without carrying out subsequent matching flow. Taking cosine similarity algorithm as an example, determining each similarity value of the first IP character string and each second IP character string in the first cascaded IP record through the cosine similarity algorithm, comparing each similarity value to determine a maximum similarity value, and if the maximum similarity value is greater than or equal to a preset threshold, determining that the second IP character string corresponding to the maximum similarity value is successfully matched with the first IP character string. For example, taking the IP address 45.115.44.0 as an example, the first IP string "45.115.44" is obtained after the IP address is bitwise segmented according to a set mask bit (e.g., 24). And determining each similarity value of the first IP character string '45.115.44' and each second IP character string in the first cascade IP record through a cosine similarity algorithm, comparing each similarity value to determine a maximum similarity value (such as 0.85), and if the maximum similarity value 0.85 is larger than a preset threshold (such as 0.8), determining that the second IP character string '45.115.44' corresponding to the maximum similarity value is successfully matched with the first IP character string '45.115.44'. Or adopting a direct character matching mode, namely, carrying out character matching on the first IP character string and each second IP character string in the first cascading IP record in sequence, namely, comparing each character in the first character string with each character of any second IP character string according to the sequence, and if one second IP character string is successfully matched with the first IP character string, determining that the first IP character string exists in the first cascading IP record.
Or taking a C-domain dictionary table and a D-domain dictionary table constructed by another static IP address list as shown in fig. 2 as an example, taking an IP address value range (for example, 172.10.1.0-172.10.9.255) corresponding to a certain city as an example, a plurality of whole IP segments exist in the IP address value range corresponding to the city, which indicates that the IP address corresponding to the city has a whole IP segment attribute. Illustratively, taking an IP address in the city as an example, for example, taking 172.10.1.0 as an example, according to the segmentation standard of the mask bit 24, the IP address is segmented according to the order from left to right, so that the IP character string "172.10.1" can be obtained, the IP character string is matched with each IP character string in the C-domain dictionary table (i.e. the first cascade IP record), if one IP character string in the C-domain dictionary table is successfully matched with the IP character string, the IP character string is determined to exist in the C-domain dictionary table, and whether the IP character string has an integral IP segment attribute is determined, or whether the IP information associated with the first IP character string exists in the C-domain dictionary table is determined, if so, the IP information (such as a value of 1) corresponding to the IP character string "172.10.1" can be directly obtained from the C-domain dictionary table, that is, namely, if the matching of the IP character string and the IP character string is successfully matched with the IP character string does not exist in the C-domain dictionary table, the IP address can be discarded if the matching of the IP character string fails. or taking an IP address value range (for example, 172.10.10.1-172.10.10.127) corresponding to another city as an example, the IP address value range corresponding to the city does not have an entire IP segment, which indicates that the IP address corresponding to the city does not have an entire IP segment attribute. Taking an example of an IP address in the city as an example, for example, taking 172.10.10.1 as an example, according to the segmentation standard of the mask bit 24, the IP character string "172.10.10" can be obtained by carrying out bit segmentation on the IP address in order from left to right, the IP character string is matched with each IP character string in the C-domain dictionary table, if one IP character string is successfully matched with the IP character string in the C-domain dictionary table, the IP character string is determined to exist in the C-domain dictionary table, whether the IP character string has an integral IP segment attribute is determined, or whether the IP character string has IP information associated with the first IP character string in the C-domain dictionary table is determined, if no, the IP character string belongs to an integral IP segment, the IP address "172.10.10.1" needs to be matched with each IP address in the D-domain dictionary table in a second stage, if one IP address is successfully matched with the IP address in the D-domain dictionary table, the IP information (for example, a value a) corresponding to the IP address 172.10.10.1 can be obtained, namely, if a value "value a" is obtained, if no IP address matching is successfully matched with the IP address exists in the D-domain dictionary table, and if no IP address matching is successfully exists in the IP dictionary table.
Step 104, if it is determined that the first IP string exists in the first cascaded IP record, when it is determined that no IP information associated with the first IP string exists in the first cascaded IP record, matching the IP address with each IP address in the second cascaded IP record, and determining IP information corresponding to the IP address when the matching is successful.
In the embodiment of the invention, after determining that the first cascade type IP record has the first IP character string, whether the first IP character string has the whole IP section attribute or not can be determined, namely whether the first IP character string belongs to the whole IP section or not is determined, if the first IP character string has the whole IP section attribute, the corresponding IP information can be directly obtained from the first cascade type IP record without performing second-level query in the second cascade type IP record, namely, when determining that the first cascade type IP record has the IP information associated with the first IP character string, the IP information can be determined to be the IP information corresponding to the IP address, so that the query frequency of the IP address can be effectively reduced, the query efficiency of the IP information can be effectively improved, if the first IP character string does not have the whole IP section attribute, the corresponding IP information can be directly obtained from the first cascade type IP record, the second IP address which does not have the whole IP section does not need to be obtained, the second cascade type IP address does not need to be carried out, the second-level IP address can be saved, the cost can be greatly reduced to the same as the first-level IP address, the cost can be greatly reduced, the hardware can be compared with the current cost can be greatly, and the cost can be greatly reduced by the comparison of the hardware, and the range can be compared with the cost of the first-to the IP address can be compared with the cost in terms of the second-3. Or whether the first cascaded IP record has the IP information associated with the first IP character string may be determined, and if it is determined that the first cascaded IP record has the IP information associated with the first IP character string, the corresponding IP information may be directly obtained from the first cascaded IP record, without performing a second-level query in the second cascaded IP record to obtain the corresponding IP information. If it is determined that the first cascaded IP record does not have the IP information associated with the first IP string, the IP address corresponding to the first IP string needs to be matched with each IP address in the second cascaded IP record, so as to determine whether the second cascaded IP record stores the IP information corresponding to the IP address, and if one IP address in the second cascaded IP record successfully matches with the IP address corresponding to the first IP string, the IP information associated with the IP address in the second cascaded IP record can be used as the IP information of the IP address corresponding to the first IP string. If no IP address in the second cascade IP record is successfully matched with the IP address corresponding to the first IP character string, the fact that the IP address corresponding to the first IP character string does not exist in the second cascade IP record is indicated.
For example, taking a certain IP address as 45.115.45.3 as an example, according to the segmentation standard of the mask bit 24, the IP address is segmented according to the order from left to right, so that an IP character string "45.115.45" can be obtained, the IP character string is matched with each IP character string in the C-domain dictionary table (i.e., the first cascade IP record), if one IP character string in the C-domain dictionary table is successfully matched with the IP character string, the existence of the IP character string in the C-domain dictionary table is determined, whether the IP character string belongs to the whole IP segment is determined, or whether the IP information associated with the first IP character string exists in the C-domain dictionary table is determined, if so, the IP information (such as a certain region 001) corresponding to the IP character string can be directly obtained from the C-domain dictionary table, that is, a value "certain region 001" is obtained, and thus, the matching for the IP address is completed. Or taking a certain IP address as 47.132.44.3 as an example, according to the segmentation standard of the mask bit 24, carrying out bit segmentation on the IP address in the order from left to right, so as to obtain an IP character string '47.132.44', matching the IP character string with each IP character string in the dictionary table of the C domain, if one IP character string is successfully matched with the IP character string in the dictionary table of the C domain, determining that the IP character string is present in the dictionary table of the C domain, determining whether the IP character string belongs to the whole IP section, or judging whether the IP character string is associated with the first IP character string in the dictionary table of the C domain, if not, obtaining that the IP character string belongs to the non-whole IP section, carrying out second-level matching on each IP address in the dictionary table of the D domain, so as to determine whether IP information corresponding to the IP address exists in the dictionary table of the D domain, if one IP address is successfully matched with the IP address exists in the dictionary table of the D domain, obtaining the IP information corresponding to the IP address (for example, if a certain region 009 is obtained, namely obtaining a region 009 value). Or taking a certain IP address as 47.132.44.1 as an example, according to the segmentation standard of the mask bit 24, carrying out bit segmentation on the IP address in the order from left to right, so as to obtain an IP character string '47.132.44', matching the IP character string with each IP character string in the C domain dictionary table, if one IP character string is successfully matched with the IP character string in the C domain dictionary table, determining that the IP character string exists in the C domain dictionary table, determining whether the IP character string belongs to an integral IP section, or judging whether IP information related to the first IP character string exists in the C domain dictionary table, if not, obtaining that the IP character string belongs to an irregular IP section, and carrying out second-level matching on each IP address in the D domain dictionary table, but not having the IP address '47.132.44.1' in the D domain dictionary table, thus determining that the matching of the IP address '47.132.44.1' fails in the D domain dictionary table. Or taking a certain IP address as 46.0.0.0 as an example, according to the segmentation standard of the mask bit 24, carrying out bit segmentation on the IP address in the order from left to right, so as to obtain an IP character string '46.0.0', and matching the IP character string with each IP character string in the C-domain dictionary table, wherein the C-domain dictionary table does not have the IP character string '46.0.0', so that the matching failure of the IP character string '46.0.0' in the C-domain dictionary table is determined.
The above embodiment shows that, in the prior art solution, when the IP information corresponding to the IP address is queried, the IP address needs to be converted to match or the IP address needs to be directly matched, but a certain time is consumed to match the IP address, so that the query efficiency of the IP information is low. Aiming at the problem, the technical scheme of the invention is to split the IP address according to mask bits instead of adding different weights after converting the IP address, so that the time cost can be effectively reduced, the hierarchical inquiry in the second cascade IP record is further carried out only for the IP address without associated IP information in the first cascade IP record, and the corresponding IP information can be timely and accurately inquired only in the first cascade IP record for the IP address with associated IP information in the first cascade IP record, so that the storage cost of the IP address can be effectively reduced, and the inquiry efficiency of the IP information can be effectively improved. Specifically, when an IP information query request for any IP address is detected, the corresponding IP address may be resolved from the IP information query request, and according to a set mask bit, bitwise slicing may be performed on the IP address to obtain the first IP string, so that time consumed for adding different weights after conversion of the IP address may be saved. And then determining whether the first IP character string exists in the first cascaded IP record, which is equivalent to performing first-stage matching on the IP address, if it is determined that the first IP character string exists in the first cascaded IP record but no IP information associated with the first IP character string exists, it is necessary to match the IP address corresponding to the first IP character string with each IP address in the second cascaded IP record, and determining the IP information corresponding to the IP address when the matching is determined to be successful, that is, only if a certain first IP character string is stored in the first cascaded IP record but no IP information associated with the first IP character string is stored, performing second-stage query on the IP address corresponding to the first IP character string is performed, and then reducing the query time (because a certain first IP character string is stored in the first cascaded IP record and the IP address corresponding to the IP information associated with the first IP character string is stored in the first cascaded IP record), so that the cost of only storing the first IP address corresponding to the first IP character string can be greatly reduced. In this way, the scheme can effectively save the time consumed by adding different weights after the conversion of the IP address by dividing the IP address according to the mask bit, and only perform the second-level query on the IP address corresponding to the IP information which is not stored with the first IP character string and is associated with the first IP character string in the first cascade type IP record, thereby effectively improving the query efficiency of the IP information.
Based on the same technical concept, fig. 3 illustrates an IP information query apparatus provided in an embodiment of the present invention, which may perform a flow of an IP information query method.
As shown in fig. 3, the apparatus includes:
A detecting unit 301, configured to determine, when an IP information query request for any network protocol IP address is detected, a corresponding IP address from the IP information query request;
The processing unit 302 is configured to perform bit-wise slicing processing on the IP address according to a set mask bit to determine a first IP string, determine whether the first IP string exists in a first cascaded IP record, if yes, match the IP address with each IP address in a second cascaded IP record when determining that IP information associated with the first IP string does not exist in the first cascaded IP record, and determine IP information corresponding to the IP address when matching is successful.
Optionally, the processing unit 302 is further configured to:
And when the first cascade type IP record is determined to have the IP information associated with the first IP character string, determining the IP information as the IP information corresponding to the IP address.
Optionally, the first cascaded IP record is used for indicating to perform a first-level query on the IP address, the second cascaded IP record is used for indicating to perform a second-level query on the IP address, and the second-level query belongs to the hierarchical query of the first-level query.
Optionally, the processing unit 302 is specifically configured to:
And carrying out bit-wise segmentation processing on the IP address in a preset direction according to the set mask bit to obtain the first IP character string conforming to the set mask bit, wherein the preset direction is from left to right or from right to left.
Optionally, the processing unit 302 is specifically configured to:
if the set mask bit is 24, carrying out bit slicing treatment on the IP address in order from left to right to obtain the first IP character string formed by the section A, the section B and the section C of the IP address, or carrying out bit slicing treatment on the section D of the IP address in order from right to left to obtain the first IP character string formed by the section A, the section B and the section C of the IP address;
If the set mask bit is 16, the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the IP address in the order from left to right, or the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the section C and the section D of the IP address in the order from right to left.
Optionally, the processing unit 302 is specifically configured to:
Acquiring each IP address with the integral IP section attribute, each IP information corresponding to each IP address with the integral IP section attribute, each IP address without the integral IP section attribute and each IP information corresponding to each IP address without the integral IP section attribute from an IP home base;
according to the set mask bit, respectively carrying out bit-wise segmentation processing on each IP address with the whole IP section attribute and each IP address without the whole IP section attribute to obtain each second IP character string corresponding to each IP address with the whole IP section attribute and each second IP character string corresponding to each IP address without the whole IP section attribute;
Storing each second IP string corresponding to each IP address having the whole IP section attribute, each IP information corresponding to each IP address having the whole IP section attribute, and each second IP string corresponding to each IP address not having the whole IP section attribute into the first cascaded IP record, and storing each IP address not having the whole IP section attribute, each IP information corresponding to each IP address not having the whole IP section attribute into the second cascaded IP record.
Optionally, the processing unit 302 is specifically configured to:
and sequentially matching the first IP character string with each second IP character string in the first cascade type IP record in a preset matching mode, so as to determine whether the first IP character string exists in the first cascade type IP record.
Based on the same technical concept, the embodiment of the present invention further provides a computing device, as shown in fig. 4, including at least one processor 401 and a memory 402 connected to the at least one processor, where in the embodiment of the present invention, a specific connection medium between the processor 401 and the memory 402 is not limited, and in fig. 4, the processor 401 and the memory 402 are connected by a bus, for example. The buses may be divided into address buses, data buses, control buses, etc.
In the embodiment of the present invention, the memory 402 stores instructions executable by the at least one processor 401, and the at least one processor 401 may execute the steps included in the aforementioned IP information query method by executing the instructions stored in the memory 402.
Where the processor 401 is a control center of a computing device, various interfaces and lines may be utilized to connect various portions of the computing device, through execution or execution of instructions stored in the memory 402, and invocation of data stored in the memory 402, to effect data processing. Alternatively, the processor 401 may include one or more processing units, and the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, an application program, etc., and the modem processor mainly processes an issue instruction. It will be appreciated that the modem processor described above may not be integrated into the processor 401. In some embodiments, processor 401 and memory 402 may be implemented on the same chip, and in some embodiments they may be implemented separately on separate chips.
The processor 401 may be a general purpose processor such as a Central Processing Unit (CPU), digital signal processor, application SPECIFIC INTEGRATED Circuit (ASIC), field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, etc., that may implement or perform the methods, steps, and logic diagrams disclosed in embodiments of the present invention. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in connection with the IP information query method embodiment may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in the processor for execution.
Memory 402 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The Memory 402 may include at least one type of storage medium, which may include, for example, flash Memory, hard disk, multimedia card, card Memory, random access Memory (Random Access Memory, RAM), static random access Memory (Static Random Access Memory, SRAM), programmable Read-Only Memory (Programmable Read Only Memory, PROM), read-Only Memory (ROM), charged erasable programmable Read-Only Memory (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory, EEPROM), magnetic Memory, magnetic disk, optical disk, and the like. Memory 402 is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The memory 402 in embodiments of the present invention may also be circuitry or any other device capable of performing memory functions for storing program instructions and/or data.
Based on the same technical idea, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program executable by a computing device, which when run on the computing device, causes the computing device to perform the steps of the above-described IP information query method.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention 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 invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations 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.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (10)

1. An IP information query method, comprising:
When an IP information inquiry request aiming at any network protocol IP address is detected, determining a corresponding IP address from the IP information inquiry request;
Performing bit-wise segmentation processing on the IP address according to the set mask bit to determine a first IP character string;
Determining whether the first IP character string exists in a first cascaded IP record;
If so, when the first cascade type IP record does not have the IP information related to the first IP character string, the IP address is matched with each IP address in the second cascade type IP record, and the IP information corresponding to the IP address is determined when the matching is successful, the first cascade type IP record stores a second character string corresponding to at least one IP address with the whole IP section attribute and each corresponding IP information in a key value pair mode, and the second cascade type IP record stores the IP address without the whole IP section attribute and each corresponding IP information in a key value pair mode.
2. The method of claim 1, wherein the method further comprises:
And when the first cascade type IP record is determined to have the IP information associated with the first IP character string, determining the IP information as the IP information corresponding to the IP address.
3. The method of claim 1, wherein the first cascaded IP record is used to indicate a first level query for an IP address, wherein the second cascaded IP record is used to indicate a second level query for an IP address, and wherein the second level query belongs to a hierarchical query of the first level query.
4. The method of claim 1, wherein the performing bitwise slicing on the IP address according to the set mask bits to determine the first IP string comprises:
And carrying out bit-wise segmentation processing on the IP address in a preset direction according to the set mask bit to obtain the first IP character string conforming to the set mask bit, wherein the preset direction is from left to right or from right to left.
5. The method as claimed in claim 4, wherein said performing a bitwise slicing process on said IP address in a predetermined direction to obtain said first IP string conforming to said set mask bits comprises:
if the set mask bit is 24, carrying out bit slicing treatment on the IP address in order from left to right to obtain the first IP character string formed by the section A, the section B and the section C of the IP address, or carrying out bit slicing treatment on the section D of the IP address in order from right to left to obtain the first IP character string formed by the section A, the section B and the section C of the IP address;
If the set mask bit is 16, the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the IP address in the order from left to right, or the first IP character string formed by the section A and the section B of the IP address is obtained by carrying out bit segmentation processing on the section C and the section D of the IP address in the order from right to left.
6. The method of claim 3, wherein the first concatenated IP record and the second concatenated IP record are determined by:
Acquiring each IP address with the integral IP section attribute, each IP information corresponding to each IP address with the integral IP section attribute, each IP address without the integral IP section attribute and each IP information corresponding to each IP address without the integral IP section attribute from an IP home base;
according to the set mask bit, respectively carrying out bit-wise segmentation processing on each IP address with the whole IP section attribute and each IP address without the whole IP section attribute to obtain each second IP character string corresponding to each IP address with the whole IP section attribute and each second IP character string corresponding to each IP address without the whole IP section attribute;
Storing each second IP string corresponding to each IP address having the whole IP section attribute, each IP information corresponding to each IP address having the whole IP section attribute, and each second IP string corresponding to each IP address not having the whole IP section attribute into the first cascaded IP record, and storing each IP address not having the whole IP section attribute, each IP information corresponding to each IP address not having the whole IP section attribute into the second cascaded IP record.
7. The method of claim 6, wherein determining whether the first IP string is present in a first cascaded IP record comprises:
and sequentially matching the first IP character string with each second IP character string in the first cascade type IP record in a preset matching mode, so as to determine whether the first IP character string exists in the first cascade type IP record.
8. An IP information query apparatus, comprising:
The detection unit is used for determining the corresponding IP address from the IP information inquiry request when the IP information inquiry request aiming at any network protocol IP address is detected;
The processing unit is used for carrying out bit segmentation processing on the IP address according to a set mask bit to determine a first IP character string, determining whether the first IP character string exists in a first cascade type IP record, if so, matching the IP address with each IP address in a second cascade type IP record and determining IP information corresponding to the IP address when the IP address is successfully matched with each IP address in the first cascade type IP record, wherein the first cascade type IP record stores a second character string corresponding to at least one IP address with a whole IP section attribute and corresponding each IP information in the form of a key value pair, and the second cascade type IP record stores the IP address without the whole IP section attribute and corresponding each IP information in the form of the key value pair.
9. A computing device comprising at least one processor and at least one memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the method of any of claims 1 to 7.
10. A computer readable storage medium, characterized in that it stores a computer program executable by a computing device, which when run on the computing device, causes the computing device to perform the method of any of claims 1 to 7.
CN202111621861.8A 2021-12-28 2021-12-28 IP information query method and device Active CN114357274B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111621861.8A CN114357274B (en) 2021-12-28 2021-12-28 IP information query method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111621861.8A CN114357274B (en) 2021-12-28 2021-12-28 IP information query method and device

Publications (2)

Publication Number Publication Date
CN114357274A CN114357274A (en) 2022-04-15
CN114357274B true CN114357274B (en) 2024-12-27

Family

ID=81102587

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111621861.8A Active CN114357274B (en) 2021-12-28 2021-12-28 IP information query method and device

Country Status (1)

Country Link
CN (1) CN114357274B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1270728A (en) * 1997-09-15 2000-10-18 埃弗内特集团股份有限公司 Method and system for fast route lookup
KR20020074780A (en) * 2001-03-22 2002-10-04 안희일 Method of Constructing the Pipe-Lined Content Addressable Memory for High Speed Lookup of Longest Prefix Matching Algorithm in Internet Protocol Address Lookup

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1270728A (en) * 1997-09-15 2000-10-18 埃弗内特集团股份有限公司 Method and system for fast route lookup
KR20020074780A (en) * 2001-03-22 2002-10-04 안희일 Method of Constructing the Pipe-Lined Content Addressable Memory for High Speed Lookup of Longest Prefix Matching Algorithm in Internet Protocol Address Lookup

Also Published As

Publication number Publication date
CN114357274A (en) 2022-04-15

Similar Documents

Publication Publication Date Title
WO2019174132A1 (en) Data processing method, server and computer storage medium
CN111339293B (en) Data processing method and device of alarm event and classification method of alarm event
CN108363686A (en) A kind of character string segmenting method, device, terminal device and storage medium
CN113868351B (en) Address clustering method, device, electronic device and storage medium
WO2019148712A1 (en) Phishing website detection method, device, computer equipment and storage medium
CN115878803B (en) Sensitive data detection method, system, computer terminal and storage medium
CN106557777A (en) It is a kind of to be based on the improved Kmeans clustering methods of SimHash
CN111339166A (en) Thesaurus-based matching recommendation method, electronic device and storage medium
CN114443688B (en) SQL rewriting method, device, electronic device and storage medium
CN118733717A (en) File duplication checking method, device, equipment, storage medium and program product
CN112100670A (en) Big data based privacy data grading protection method
CN112860712B (en) Block chain-based transaction database construction method, system and electronic equipment
CN113408660A (en) Book clustering method, device, equipment and storage medium
CN110399464B (en) Similar news judgment method and system and electronic equipment
CN114357274B (en) IP information query method and device
CN110046180B (en) A method, device and electronic device for locating similar instances
CN114299505A (en) Method, device and equipment for scanning name list and storage medium
CN113742344A (en) Method and device for indexing power system data
CN116126997B (en) Document deduplication storage method, system, device and storage medium
CN109992708B (en) Method, device, equipment and storage medium for metadata query
CN114357394A (en) Data flow correlation identification method and device, electronic equipment and storage medium
CN118820264B (en) Partition-based data processing method and apparatus
CN113407656B (en) Method and equipment for fast online log clustering
CN112395377B (en) Address recognition method, device and storage medium
CN111506756A (en) Similar picture searching method and system, electronic device and storage medium

Legal Events

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