CN107613039B - IP address attribution query method, device, system and storage medium - Google Patents
IP address attribution query method, device, system and storage medium Download PDFInfo
- Publication number
- CN107613039B CN107613039B CN201710851764.5A CN201710851764A CN107613039B CN 107613039 B CN107613039 B CN 107613039B CN 201710851764 A CN201710851764 A CN 201710851764A CN 107613039 B CN107613039 B CN 107613039B
- Authority
- CN
- China
- Prior art keywords
- domain name
- address
- attribution
- query
- reference domain
- 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
Links
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本公开提供一种IP地址归属地查询方法、装置、系统及存储介质,所述方法包括:将用户终端的IP地址转换为目标域名;向DNS服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;接收DNS服务端返回的基准域名;基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。应用本公开方案可以提高IP地址归属地的查询效率。
The present disclosure provides a method, device, system and storage medium for IP address attribution query. The method includes: converting an IP address of a user terminal into a target domain name; sending a query request carrying the target domain name to a DNS server, The query request instructs the DNS server to query the reference domain name corresponding to the target domain name, where the reference domain name is used to identify the IP address range to which the IP address belongs; receive the reference domain name returned by the DNS server; based on a preset correspondence Searching for the attribution corresponding to the reference domain name, determining the attribution found as the attribution of the IP address, and the preset correspondence is a pre-stored correspondence between the reference domain name and the attribution. By applying the solution of the present disclosure, the query efficiency of the IP address attribution can be improved.
Description
技术领域technical field
本申请涉及通信技术领域,尤其涉及IP地址归属地查询方法、装置、系统及存储介质。The present application relates to the field of communication technologies, and in particular, to a method, device, system and storage medium for querying IP address attribution.
背景技术Background technique
IP地址是指互联网协议地址(英语:Internet Protocol Address,又译为网际协议地址)。IP地址是IP协议提供的一种统一的地址格式,它为互联网上的每一个网络和每一台主机分配一个逻辑地址,以此来屏蔽物理地址的差异。IP address refers to the Internet Protocol Address (English: Internet Protocol Address, also translated as Internet Protocol Address). The IP address is a unified address format provided by the IP protocol. It assigns a logical address to each network and each host on the Internet, thereby shielding the difference in physical addresses.
IP地址归属地查询是一种非常普遍的需求,通过用户请求中的IP地址来查询该IP地址属于哪一个省份、城市或者运营商等等。一般IP地址都是分段分配的,某一个连续范围内的IP地址集合被分配给一个省份、城市或者运营商。例如,归属于IP地址范围1.23.64.0~1.23.74.255的IP属于地区A,归属于IP地址范围1.23.75.0~1.23.79.255的IP属于地区B。可见,用户的IP地址1.23.78.33落在地区B的IP地址范围内,则说明该IP地址的归属地为地区B。The IP address attribution query is a very common requirement. The IP address in the user request is used to query which province, city or operator the IP address belongs to. Generally, IP addresses are allocated in segments, and a set of IP addresses in a continuous range is allocated to a province, city or operator. For example, IPs belonging to the IP address range 1.23.64.0 to 1.23.74.255 belong to region A, and IPs belonging to the IP address range 1.23.75.0 to 1.23.79.255 belong to region B. It can be seen that the user's IP address 1.23.78.33 falls within the IP address range of region B, which means that the IP address belongs to region B.
相关技术中,往往从数据库中查询IP地址所属IP地址范围,进而确定IP地址的归属地,由于数据库存储在硬盘中,查询IP地址归属地时需要从硬盘中读取数据,从而导致查询效率低。In the related art, the IP address range to which the IP address belongs is often queried from the database, and then the attribution of the IP address is determined. Since the database is stored in the hard disk, the data needs to be read from the hard disk when querying the attribution of the IP address, resulting in low query efficiency. .
发明内容SUMMARY OF THE INVENTION
为克服相关技术中存在的问题,本公开提供了IP地址归属地查询方法、装置、系统及存储介质。In order to overcome the problems existing in the related art, the present disclosure provides a method, apparatus, system and storage medium for IP address attribution query.
根据本公开实施例的第一方面,提供一种IP地址归属地查询方法,所述方法应用在查询服务端,所述方法包括:According to a first aspect of the embodiments of the present disclosure, a method for querying IP address attribution is provided. The method is applied to a query server, and the method includes:
将用户终端的IP地址转换为目标域名;Convert the IP address of the user terminal to the target domain name;
向DNS(Domain Name System,网域名称系统)服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;Send a query request carrying the target domain name to the DNS (Domain Name System, domain name system) server, the query request instructing the DNS server to query the reference domain name corresponding to the target domain name, and the reference domain name is used for Identifies the IP address range to which the IP address belongs;
接收DNS服务端返回的基准域名;Receive the base domain name returned by the DNS server;
基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Based on a preset correspondence relationship, the attribution corresponding to the reference domain name is searched, and the found attribution is determined as the attribution of the IP address, and the preset correspondence is a pre-stored correspondence between the reference domain name and the attribution.
在一个可选的实现方式中,所述将用户终端的IP地址转换为目标域名,包括:In an optional implementation, converting the IP address of the user terminal into the target domain name includes:
将IP地址转换为数字;Convert IP addresses to numbers;
将所述数字与预设顶级域结合,获得IP地址对应的目标域名。The number is combined with the preset top-level domain to obtain the target domain name corresponding to the IP address.
在一个可选的实现方式中,所述将IP地址转换为数字可以包括:In an optional implementation manner, the converting the IP address into a number may include:
将IP地址中每个字节的十进制数转换为十六进制数;Convert the decimal number to hexadecimal number of each byte in the IP address;
将各字节转换获得的十六进制数按IP地址中字节顺序进行组合,获得一个十六进制数;Combine the hexadecimal numbers obtained by converting each byte in the order of bytes in the IP address to obtain a hexadecimal number;
将组合获得的十六进制数转换为十进制数,获得所述IP地址对应的数字。Convert the hexadecimal number obtained by the combination into a decimal number to obtain the number corresponding to the IP address.
在一个可选的实现方式中,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。In an optional implementation manner, the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs.
根据本公开实施例的第二方面,提供一种IP地址归属地查询方法,所述方法应用在DNS服务端,所述方法包括:According to a second aspect of the embodiments of the present disclosure, a method for querying IP address attribution is provided. The method is applied to a DNS server, and the method includes:
接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名;receiving a query request sent by the query server, where the query request carries a target domain name corresponding to the IP address;
基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;Query a reference domain name corresponding to the target domain name based on the query request, where the reference domain name is used to identify the IP address range to which the IP address belongs;
向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Send the reference domain name to the query server, so that the query server searches for the attribution corresponding to the reference domain name based on the preset correspondence, and determines the found attribution as the attribution of the IP address. The preset corresponding relationship is the corresponding relationship between the pre-stored reference domain name and the attribution.
在一个可选的实现方式中,所述基于所述查询请求查询与所述目标域名对应的基准域名,包括:In an optional implementation manner, the querying the reference domain name corresponding to the target domain name based on the query request includes:
从区文件中查询与所述目标域名对应的基准域名,所述区文件是利用DNSSEC(Domain Name System Security Extensions,域名系统安全扩展)协议将DNS中基准域名签名后获得,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。The reference domain name corresponding to the target domain name is queried from the zone file. The zone file is obtained by using the DNSSEC (Domain Name System Security Extensions, Domain Name System Security Extensions) protocol to sign the reference domain name in the DNS. The reference domain name is based on the The upper limit IP address in the IP address range to which the IP address belongs is obtained by performing domain name conversion.
在一个可选的实现方式中,所述区文件中各基准域名的记录集合按预设策略进行排序,所述记录集合中至少包括下一条安全记录(Next Secure,可以称为NESC记录),所述NESC记录中记录有下一条记录集合的基准域名的名称;In an optional implementation manner, the record set of each reference domain name in the zone file is sorted according to a preset policy, and the record set at least includes a next security record (Next Secure, which may be referred to as an NESC record), so The name of the base domain name in which the next record set is recorded in the NESC record;
所述从区文件中查询与所述目标域名对应的基准域名,包括:The querying the reference domain name corresponding to the target domain name from the zone file includes:
从区文件中查询所述目标域名,当所述目标域名在第一基准域名和第二基准域名之间时,将所述第一基准域名的记录集合中的NESC记录发送至所述查询服务端;Query the target domain name from the zone file, when the target domain name is between the first benchmark domain name and the second benchmark domain name, send the NESC record in the record set of the first benchmark domain name to the query server ;
其中,发送的NESC记录中记录有第二基准域名的名称,所述第一基准域名和第二基准域名是所述区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前。The name of the second benchmark domain name is recorded in the sent NESC record, the first benchmark domain name and the second benchmark domain name are adjacent benchmark domain names in the zone file, and the first benchmark domain name is arranged before the second benchmark domain name .
根据本公开实施例的第三方面,提供一种IP地址归属地查询装置,所述装置包括:According to a third aspect of the embodiments of the present disclosure, an apparatus for querying IP address attribution is provided, and the apparatus includes:
信息转换模块,被配置为将用户终端的IP地址转换为目标域名;The information conversion module is configured to convert the IP address of the user terminal into the target domain name;
信息通信模块,被配置为向DNS服务端发送携带有所述目标域名的查询请求,并接收DNS服务端返回的基准域名;所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;The information communication module is configured to send a query request carrying the target domain name to the DNS server, and receive the reference domain name returned by the DNS server; the query request instructs the DNS server to query the reference domain name corresponding to the target domain name , the reference domain name is used to identify the IP address range to which the IP address belongs;
归属地确定模块,被配置为基于预设对应关系查找所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。The attribution determination module is configured to search for the attribution corresponding to the reference domain name based on a preset correspondence, and determine the found attribution as the attribution of the IP address, and the preset correspondence is a pre-stored reference domain name Correspondence with the place of belonging.
在一个可选的实现方式中,所述信息转换模块,具体配置为:In an optional implementation manner, the information conversion module is specifically configured as:
将IP地址转换为数字;Convert IP addresses to numbers;
将所述数字与预设顶级域结合,获得IP地址对应的目标域名。The number is combined with the preset top-level domain to obtain the target domain name corresponding to the IP address.
在一个可选的实现方式中,所述信息转换模块,具体配置为:In an optional implementation manner, the information conversion module is specifically configured as:
将IP地址中每个字节的十进制数转换为十六进制数;Convert the decimal number to hexadecimal number of each byte in the IP address;
将各字节转换获得的十六进制数按IP地址中字节顺序进行组合,获得一个十六进制数;Combine the hexadecimal numbers obtained by converting each byte in the order of bytes in the IP address to obtain a hexadecimal number;
将组合获得的十六进制数转换为十进制数,获得所述IP地址对应的数字。Convert the hexadecimal number obtained by the combination into a decimal number to obtain the number corresponding to the IP address.
在一个可选的实现方式中,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。In an optional implementation manner, the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs.
根据本公开实施例的第四方面,提供一种IP地址归属地查询装置,所述装置包括:According to a fourth aspect of the embodiments of the present disclosure, there is provided a device for querying IP address attribution, the device comprising:
信息通信模块,被配置为接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名;an information communication module, configured to receive a query request sent by the query server, where the query request carries a target domain name corresponding to the IP address;
域名查询模块,被配置为基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;a domain name query module, configured to query a reference domain name corresponding to the target domain name based on the query request, where the reference domain name is used to identify the IP address range to which the IP address belongs;
所述信息通信模块,还被配置为向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。The information communication module is further configured to send the reference domain name to the query server, so that the query server searches for the attribution corresponding to the reference domain name based on the preset correspondence, and determines the found attribution as: The attribution of the IP address, and the preset correspondence is the correspondence between the pre-stored reference domain name and the attribution.
在一个可选的实现方式中,所述域名查询模块,具体配置为:In an optional implementation manner, the domain name query module is specifically configured as:
从区文件中查询与所述目标域名对应的基准域名,所述区文件是利用DNSSEC协议将DNS中基准域名签名后获得,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。The reference domain name corresponding to the target domain name is queried from the zone file. The zone file is obtained by using the DNSSEC protocol to sign the reference domain name in the DNS. The reference domain name is based on the upper limit of the IP address range to which the IP address belongs. The IP address is obtained by domain name conversion.
在一个可选的实现方式中,所述区文件中各基准域名的记录集合按预设策略进行排序,所述记录集合中至少包括NESC记录,所述NESC记录中记录有下一条记录集合的基准域名的名称;In an optional implementation manner, the record sets of each reference domain name in the zone file are sorted according to a preset policy, the record set includes at least NESC records, and the NESC records record the benchmark of the next record set the name of the domain name;
所述域名查询模块,具体配置为:The domain name query module is specifically configured as:
从区文件中查询所述目标域名,当所述目标域名在第一基准域名和第二基准域名之间时,将所述第一基准域名的记录集合中的NESC记录发送至所述查询服务端;Query the target domain name from the zone file, when the target domain name is between the first benchmark domain name and the second benchmark domain name, send the NESC record in the record set of the first benchmark domain name to the query server ;
其中,发送的NESC记录中记录有第二基准域名的名称,所述第一基准域名和第二基准域名是所述区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前。The name of the second benchmark domain name is recorded in the sent NESC record, the first benchmark domain name and the second benchmark domain name are adjacent benchmark domain names in the zone file, and the first benchmark domain name is arranged before the second benchmark domain name .
根据本公开实施例的第五方面,提供一种IP地址归属地查询系统,所述系统包括查询服务端和DNS服务端;According to a fifth aspect of the embodiments of the present disclosure, there is provided an IP address attribution query system, the system includes a query server and a DNS server;
所述查询服务端将用户终端的IP地址转换为目标域名,并将携带所述目标域名的查询请求发送至所述DNS服务端;The query server converts the IP address of the user terminal into a target domain name, and sends a query request carrying the target domain name to the DNS server;
所述DNS服务端基于所述查询请求查询与所述目标域名对应的基准域名,并向所述查询服务端发送所述基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;The DNS server queries the reference domain name corresponding to the target domain name based on the query request, and sends the reference domain name to the query server, where the reference domain name is used to identify the IP address range to which the IP address belongs ;
所述查询服务端基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。The query server searches for an attribution corresponding to the reference domain name based on a preset correspondence, and determines the found attribution as the attribution of the IP address, and the preset correspondence is a pre-stored reference domain name and attribution Correspondence to the ground.
根据本公开实施例的第六方面,提供一种IP地址归属地查询装置,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为:According to a sixth aspect of the embodiments of the present disclosure, there is provided an IP address attribution query apparatus, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to:
将用户终端的IP地址转换为目标域名;Convert the IP address of the user terminal to the target domain name;
向DNS服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;Send a query request carrying the target domain name to the DNS server, where the query request instructs the DNS server to query the reference domain name corresponding to the target domain name, and the reference domain name is used to identify the IP address range to which the IP address belongs ;
接收DNS服务端返回的基准域名;Receive the base domain name returned by the DNS server;
基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Based on a preset correspondence relationship, the attribution corresponding to the reference domain name is searched, and the found attribution is determined as the attribution of the IP address, and the preset correspondence is a pre-stored correspondence between the reference domain name and the attribution.
根据本公开实施例的第七方面,提供一种IP地址归属地查询装置,包括:处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为:According to a seventh aspect of the embodiments of the present disclosure, there is provided an IP address attribution query apparatus, comprising: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to:
接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名;receiving a query request sent by the query server, where the query request carries a target domain name corresponding to the IP address;
基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;Query a reference domain name corresponding to the target domain name based on the query request, where the reference domain name is used to identify the IP address range to which the IP address belongs;
向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Send the reference domain name to the query server, so that the query server searches for the attribution corresponding to the reference domain name based on the preset correspondence, and determines the found attribution as the attribution of the IP address. The preset corresponding relationship is the corresponding relationship between the pre-stored reference domain name and the attribution.
根据本公开实施例的第八方面,提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述应用在查询服务端中IP地址归属地查询方法的步骤。According to an eighth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the steps of the above-mentioned method for querying IP address attribution in a query server by an application.
根据本公开实施例的第九方面,提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述应用在DNS服务端中IP地址归属地查询方法的步骤。According to a ninth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the steps of the above application method for IP address attribution in a DNS server.
本公开的实施例提供的技术方案可以包括以下有益效果:The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:
本公开实施例通过查询服务端将用户终端的IP地址转换为目标域名,并将目标域名发送至DNS服务端,DNS服务端基于查询请求查询与目标域名对应的基准域名,由于基准域名用于标识所述IP地址归属的IP地址范围,因此,在DNS服务端向查询服务端发送基准域名后,查询服务端可以基于预设对应关系查找与基准域名对应的归属地,从而将查找到的归属地确定为IP地址的归属地,实现快速查询IP地址的归属地。The embodiment of the present disclosure converts the IP address of the user terminal into the target domain name through the query server, and sends the target domain name to the DNS server. The DNS server queries the reference domain name corresponding to the target domain name based on the query request, because the reference domain name is used to identify The IP address range to which the IP address belongs. Therefore, after the DNS server sends the reference domain name to the query server, the query server can search for the attribution corresponding to the reference domain name based on the preset correspondence, so that the found attribution It is determined as the attribution of the IP address, so as to quickly query the attribution of the IP address.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description serve to explain the principles of the disclosure.
图1是本公开根据一示例性实施例示出的一种IP地址归属地查询的网络架构图。FIG. 1 is a network architecture diagram of IP address attribution query according to an exemplary embodiment of the present disclosure.
图2是本公开根据一示例性实施例示出的一种IP地址归属地查询方法的流程图。FIG. 2 is a flowchart of a method for querying IP address attribution according to an exemplary embodiment of the present disclosure.
图3是本公开根据一示例性实施例示出的另一种IP地址归属地查询方法的流程图。Fig. 3 is a flowchart of another IP address attribution query method according to an exemplary embodiment of the present disclosure.
图4是本公开根据一示例性实施例示出的一种区文件生成过程的流程图。FIG. 4 is a flowchart of a process of generating a zone file according to an exemplary embodiment of the present disclosure.
图5是本公开根据一示例性实施例示出的一种IP地址归属地查询方法的交互示意图。FIG. 5 is an interactive schematic diagram of a method for querying IP address attribution according to an exemplary embodiment of the present disclosure.
图6是本公开根据一示例性实施例示出的一种IP地址归属地查询系统的框图。Fig. 6 is a block diagram of an IP address attribution query system according to an exemplary embodiment of the present disclosure.
图7是本公开根据一示例性实施例示出的一种IP地址归属地查询装置的框图。FIG. 7 is a block diagram of a device for querying IP address attribution according to an exemplary embodiment of the present disclosure.
图8是本公开根据一示例性实施例示出的另一种IP地址归属地查询装置的框图。Fig. 8 is a block diagram of another apparatus for querying IP address attribution according to an exemplary embodiment of the present disclosure.
图9是本申请根据一示例性实施例示出的一种用于IP地址归属地查询的装置的框图。Fig. 9 is a block diagram of an apparatus for IP address attribution query according to an exemplary embodiment of the present application.
图10是本申请根据一示例性实施例示出的另一种用于IP地址归属地查询的装置的框图。Fig. 10 is a block diagram of another apparatus for IP address attribution query according to an exemplary embodiment of the present application.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. Where the following description refers to the drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the illustrative examples below are not intended to represent all implementations consistent with this disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as recited in the appended claims.
在本公开使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本公开。在本公开和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相关联的列出项目的任何或所有可能组合。The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to limit the present disclosure. As used in this disclosure and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It will also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
应当理解,尽管在本公开可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本公开范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various pieces of information, such information should not be limited by these terms. These terms are only used to distinguish the same type of information from each other. For example, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information, without departing from the scope of the present disclosure. Depending on the context, the word "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determining."
为了更好地理解本发明所公开的IP地址归属地查询方法、装置、系统及存储介质,先对DNS和DNSSEC协议进行介绍。网域名称系统(Domain Name System,缩写DNS),因特网上作为域名和IP地址相互映射的一个分布式数据库。DNS包括一系列记录,描述了名称、IP地址和其他关于主机的信息。这些数据库驻留在DNS服务器中。DNS系统中,常见的资源记录类型有:In order to better understand the IP address attribution query method, device, system and storage medium disclosed in the present invention, the DNS and DNSSEC protocols will be introduced first. Domain Name System (DNS) is a distributed database on the Internet that maps domain names and IP addresses to each other. DNS includes a series of records that describe names, IP addresses, and other information about hosts. These databases reside in DNS servers. In the DNS system, common resource record types are:
主机记录(A记录):RFC 1035定义,A记录是用于名称解析的重要记录,它将特定的主机名映射到对应主机的IP地址上。其中,Request For Comments,缩写为RFC,可以是由互联网工程任务组(IETF)发布的一系列备忘录。Host record (A record): As defined by RFC 1035, A record is an important record for name resolution, which maps a specific host name to the IP address of the corresponding host. Among them, Request For Comments, abbreviated as RFC, can be a series of memorandums issued by the Internet Engineering Task Force (IETF).
别名记录(CNAME记录):RFC 1035定义,CNAME记录用于将某个别名指向到某个A记录上,这样就不需要再为某个新名字另外创建一条新的A记录。Alias record (CNAME record): As defined in RFC 1035, a CNAME record is used to point an alias to an A record, so that there is no need to create a new A record for a new name.
IPv6(Internet Protocol version 6,互联网通信协议第6版)主机记录(AAAA记录或IPv6IP地址记录):RFC 3596定义,与A记录对应,用于将特定的主机名映射到一个主机的IPv6地址。IPv6 (Internet Protocol version 6, Internet Protocol version 6) host record (AAAA record or IPv6 IP address record): defined by RFC 3596, corresponding to the A record, used to map a specific host name to a host's IPv6 address.
服务位置记录(SRV记录):RFC 2782定义,用于定义提供特定服务的服务器的位置,如主机(hostname),端口(port number)等。Service Location Record (SRV Record): Defined by RFC 2782 to define the location of a server that provides a specific service, such as host (hostname), port (port number), etc.
命名管理指针(NAPTR记录):RFC 3403定义,它提供了正则表达式方式去映射一个域名。NAPTR记录非常著名的一个应用是用于ENUM查询。Named Management Pointer (NAPTR record): Defined by RFC 3403, it provides a regular expression way to map a domain name. A well-known application of NAPTR records is for ENUM queries.
域名系统安全扩展(Domain Name System Security Extensions,缩写DNSSEC)协议是在DNS协议基础之上的一种安全协议,它通过对原始的DNS的区文件进行签名的方式给DNS加了一层安全屏障。它在原有DNS已有的记录类型如A、AAAA、NS、CNAME等的基础上新增了RRSIG(Resource Record Signature,资源记录签名)、DNSKEY(DNS Public Key,DNS公钥)、DS(Delegation Signer,代表签署者)、NSEC(Next Secure,下一条安全记录)等新的记录,同一域名的各条记录构成该域名的记录集合。经过DNSSEC进行签名的区文件可以是一个根据预设策略(例如按字母顺序排序)将记录集合排序后的总记录集合,并且每条域名的记录集合都有一条对应的NSEC记录,它标识该域名有哪些类型的记录以及它的下一条域名是谁。在区数据签名时,NSEC记录会自动生成。比如在vpn.test.net和xyz.test.net之间会插入NSEC记录,NSEC记录可以包括两项内容:排序后的下一个资源记录的名称(xyz.test.net.)、以及vpn.test.net.这一名称所有的资源记录类型(A、RRSIG、NSEC)等。当用户请求的某个域名在vpn和xyz之间时,如www.test.net.,DNS服务器会返回域名不存在,并返回vpn.test.net的NSEC记录。The Domain Name System Security Extensions (DNSSEC) protocol is a security protocol based on the DNS protocol. It adds a layer of security to the DNS by signing the original DNS zone file. It adds RRSIG (Resource Record Signature, resource record signature), DNSKEY (DNS Public Key, DNS public key), DS (Delegation Signer) to the existing record types of the original DNS such as A, AAAA, NS, CNAME, etc. , representing the signer), NSEC (Next Secure, next security record) and other new records, each record of the same domain name constitutes the record set of the domain name. The zone file signed by DNSSEC can be a total record set after sorting the record set according to a preset policy (such as alphabetical ordering), and each domain name record set has a corresponding NSEC record, which identifies the domain name What types of records are there and who is its next domain name. NSEC records are automatically generated when zone data is signed. For example, an NSEC record will be inserted between vpn.test.net and xyz.test.net. The NSEC record can include two contents: the name of the next resource record after sorting (xyz.test.net.), and vpn.test .net. All resource record types (A, RRSIG, NSEC), etc. with this name. When a domain name requested by the user is between vpn and xyz, such as www.test.net., the DNS server will return that the domain name does not exist and return the NSEC record of vpn.test.net.
另外,还对本公开实施例使用的应用场景进行说明。如图1所示,图1是本公开根据一示例性实施例示出的一种IP地址归属地查询的网络架构图。在该网络架构中,包括用户终端、查询服务端和DNS服务端。用户终端可以是智能手机、平板电脑、PDA(PersonalDigital Assistant,个人数字助理)、电子书阅读器、多媒体播放器等等。查询服务端可以是可以查询IP地址归属地的服务端,该服务端可以是服务器、服务器集群或者云平台等。例如,查询服务端可以是Web服务器。DNS服务端是设有DNS的服务端,该服务端可以是服务器、服务器集群或者云平台等。In addition, the application scenarios used by the embodiments of the present disclosure are also described. As shown in FIG. 1 , FIG. 1 is a network architecture diagram of IP address attribution query according to an exemplary embodiment of the present disclosure. The network architecture includes a user terminal, a query server and a DNS server. The user terminal may be a smart phone, a tablet computer, a PDA (Personal Digital Assistant, personal digital assistant), an e-book reader, a multimedia player, and the like. The query server may be a server that can query the attribution of an IP address, and the server may be a server, a server cluster, a cloud platform, or the like. For example, the query server can be a web server. The DNS server is a server with DNS, and the server can be a server, a server cluster, or a cloud platform.
相关技术中,往往从数据库中查询IP地址所属IP地址范围,进而确定IP地址的归属地,由于数据库存储在硬盘中,查询IP地址归属地时需要从硬盘中读取数据,从而导致查询效率低。In the related art, the IP address range to which the IP address belongs is often queried from the database, and then the attribution of the IP address is determined. Since the database is stored in the hard disk, the data needs to be read from the hard disk when querying the attribution of the IP address, resulting in low query efficiency. .
为了避免相关技术中查询效率低的缺陷,本公开提供一种IP地址归属地查询方法,可以应用于如图1所示的网络架构中,通过查询服务端将用户终端的IP地址转换为目标域名,并将目标域名发送至DNS服务端。DNS服务端基于查询请求查询与目标域名对应的基准域名。由于基准域名用于标识所述IP地址归属的IP地址范围,IP地址范围与归属地对应,因此,在DNS服务端向查询服务端发送基准域名后,查询服务端可以基于预设对应关系查找与基准域名对应的归属地,从而将查找到的归属地确定为IP地址的归属地,实现快速查询IP地址的归属地。以下结合附图对本公开实施例进行示例说明。In order to avoid the defect of low query efficiency in the related art, the present disclosure provides an IP address attribution query method, which can be applied to the network architecture shown in FIG. , and send the target domain name to the DNS server. The DNS server queries the reference domain name corresponding to the target domain name based on the query request. Since the reference domain name is used to identify the IP address range to which the IP address belongs, and the IP address range corresponds to the attribution, therefore, after the DNS server sends the reference domain name to the query server, the query server can search and The attribution corresponding to the reference domain name is determined, so that the found attribution is determined as the attribution of the IP address, so that the attribution of the IP address can be quickly inquired. The embodiments of the present disclosure will be exemplified below with reference to the accompanying drawings.
首先从查询服务端进行介绍,如图2所示,图2是本公开根据一示例性实施例示出的一种IP地址归属地查询方法的流程图,所述方法应用在查询服务端,所述方法包括:First, an introduction is made from the query server. As shown in FIG. 2, FIG. 2 is a flowchart of an IP address attribution query method according to an exemplary embodiment of the present disclosure. The method is applied to the query server. Methods include:
在步骤201中,将用户终端的IP地址转换为目标域名。IP是对网络协议的简写,网络协议地址往往简写为IP地址。In
在步骤202中,向DNS服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。DNS是对网域名称系统的简写,网域名称系统服务端往往简写为DNS服务端。In
在步骤203中,接收DNS服务端返回的基准域名。In
在步骤204中,基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。In
其次,从DNS服务端进行介绍,如图3所示,图3是本公开根据一示例性实施例示出的另一种IP地址归属地查询方法的流程图,所述方法应用在DNS服务端,所述方法包括:Next, introduce from the DNS server, as shown in FIG. 3 , which is a flowchart of another IP address attribution query method shown in the present disclosure according to an exemplary embodiment, and the method is applied to the DNS server, The method includes:
在步骤301中,接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名。In
在步骤302中,基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。In
在步骤303中,向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。In
为了更好地理解本发明所公开的IP地址归属地查询方法,本公开实施例结合应用在查询服务端的实施例和应用在DNS服务端的实施例进行示例说明。In order to better understand the IP address attribution query method disclosed by the present invention, the embodiments of the present disclosure are described in conjunction with the embodiment applied to the query server and the embodiment applied to the DNS server.
用户终端可以向查询服务端发送HTTP(HyperText Transfer Protocol,超文本传输协议)请求,HTTP请求中携带有用户终端的IP地址。在查询服务端中,可以按照预先设定的转换策略将用户终端的IP地址转换为目标域名。其中,目标域名是一种域名,为了与后续基准域名进行区分,将用户终端的IP地址进行域名转换获得的域名称为目标域名。The user terminal may send an HTTP (HyperText Transfer Protocol, hypertext transfer protocol) request to the query server, where the HTTP request carries the IP address of the user terminal. In the query server, the IP address of the user terminal can be converted into the target domain name according to a preset conversion strategy. The target domain name is a type of domain name. In order to distinguish it from the subsequent reference domain name, the domain name obtained by domain name conversion of the IP address of the user terminal is called the target domain name.
在一个实施例中,可以预先存储有不同目标域名与IP地址的对应关系,在获得用户终端的IP地址后,可以从域名与IP地址的对应关系中查询与用户终端的IP地址对应的目标域名,从而将用户终端的IP地址转换为目标域名,例如,将IP地址(208.80.152.2)转换为目标域名(www.wikipedia.org)。In one embodiment, the correspondence between different target domain names and IP addresses may be pre-stored, and after obtaining the IP address of the user terminal, the target domain name corresponding to the IP address of the user terminal may be queried from the correspondence between the domain name and the IP address , thereby converting the IP address of the user terminal into the target domain name, for example, converting the IP address (208.80.152.2) into the target domain name (www.wikipedia.org).
由于IP地址数量较大,域名与IP地址的对应关系的信息量比较大,为了提高域名转换效率,在另一个实施例中,可以将IP地址与预设顶级域结合,构成形式上的域名。预设顶级域是预先设定的顶级域名,例如,可以是.com或者.cn等。结合方式可以是直接在IP地址后添加顶级域名。例如,将IP地址(208.80.152.2)转换为目标域名(208.80.152.2.com)。Due to the large number of IP addresses, the corresponding relationship between domain names and IP addresses has a relatively large amount of information. In order to improve the conversion efficiency of domain names, in another embodiment, the IP addresses can be combined with a preset top-level domain to form a formal domain name. The preset top-level domain is a preset top-level domain, for example, it may be .com or .cn. The combination method can be to add the top-level domain name directly after the IP address. For example, translate the IP address (208.80.152.2) to the target domain name (208.80.152.2.com).
可见,通过在IP地址后直接添加预设顶级域名的方式,可以提高域名转换效率,无需预先为所有IP地址都分配相应的域名以创建域名与IP地址的对应关系。It can be seen that by adding a preset top-level domain name directly after the IP address, the domain name conversion efficiency can be improved, and there is no need to assign corresponding domain names to all IP addresses in advance to create a corresponding relationship between domain names and IP addresses.
在另一个实施例中,IP地址是一个32位的二进制数,通常被分割为4组“8位二进制数”(也就是4个字节)。IP地址通常用“点分十进制”表示成(a.b.c.d)的形式,其中,a,b,c,d都是0~255之间的十进制整数,可以理解为IP地址包括4组十进制数。例:点分十进IP地址(100.4.5.6),实际上是32位二进制数(01100100.00000100.00000101.00000110)。可见,如果在IP地址后直接添加预设顶级域名,后续域名查找时需要将IP地址+顶级域名构成的域名进行查找。In another embodiment, the IP address is a 32-bit binary number, usually divided into 4 groups of "8-bit binary numbers" (ie, 4 bytes). An IP address is usually expressed in the form of (a.b.c.d) in "dotted decimal", where a, b, c, and d are all decimal integers between 0 and 255. It can be understood that an IP address includes four sets of decimal numbers. Example: The dotted decimal IP address (100.4.5.6) is actually a 32-bit binary number (01100100.00000100.00000101.00000110). It can be seen that if a preset top-level domain name is added directly after the IP address, the domain name consisting of the IP address and the top-level domain name needs to be searched for subsequent domain name searches.
为了提高域名转换效率的同时,提高后续域名查找时的查找效率,所述将用户终端的IP地址转换为目标域名,包括:In order to improve the domain name conversion efficiency and improve the search efficiency during subsequent domain name searches, the converting the IP address of the user terminal into the target domain name includes:
将IP地址转换为数字;Convert IP addresses to numbers;
将所述数字与预设顶级域结合,获得IP地址对应的目标域名。The number is combined with the preset top-level domain to obtain the target domain name corresponding to the IP address.
可见,通过将IP地址表示的点分十进制转换为数字,并将数字与预设顶级域名进行结合获得IP地址对应的目标域名,该目标域名是形式上的域名。后续域名查找时,将数字进行比较,可以提高查找效率。It can be seen that the target domain name corresponding to the IP address is obtained by converting the dotted decimal represented by the IP address into a number, and combining the number with the preset top-level domain name, where the target domain name is a formal domain name. In subsequent domain name searches, the numbers are compared to improve search efficiency.
关于将IP地址转换为数字,作为其中一种转换方式,所述将IP地址转换为数字可以包括:Regarding converting an IP address into a number, as one of the conversion methods, the converting an IP address into a number may include:
将IP地址中每个字节的十进制数转换为十六进制数;Convert the decimal number to hexadecimal number of each byte in the IP address;
将各字节转换获得的十六进制数按IP地址中字节顺序进行组合,获得一个十六进制数;Combine the hexadecimal numbers obtained by converting each byte in the order of bytes in the IP address to obtain a hexadecimal number;
将组合获得的十六进制数转换为十进制数,即实现将IP地址转换为数字。Convert the hexadecimal number obtained by the combination to a decimal number, that is, to convert the IP address to a number.
其中,每个字节的十进制数相当于每组十进制数,即将IP地址中每组十进制数转换为十六进制数,将每组转换获得的十六进制数按IP地址中数组顺序进行组合,组合获得一个十六进制数,将组合获得的十六进制数转换为十进制,即实现将IP地址转换为数字。以IP地址(a.b.c.d)包括a、b、c、d四组(字节)数为例,将十进制的a、b、c、d分别转换为十六进制的a′、b′、c′、d′,将a′、b′、c′、d′按IP地址中字节顺序进行组合,获得一个十六进制数:a′b′c′d′,将组合获得的a′b′c′d′转换为十进制数,获得所述IP地址对应的数字。Among them, the decimal number of each byte is equivalent to each group of decimal numbers, that is, each group of decimal numbers in the IP address is converted into hexadecimal numbers, and the hexadecimal numbers obtained by each group of conversion are in the order of the array in the IP address. Combining, combining to obtain a hexadecimal number, and converting the hexadecimal number obtained by combining to decimal, that is, converting the IP address into a number. Taking the IP address (a.b.c.d) including four groups (bytes) of a, b, c, and d as an example, convert the decimal a, b, c, and d to hexadecimal a', b', c' respectively , d', combine a', b', c', d' in the byte order of the IP address to obtain a hexadecimal number: a'b'c'd', combine the obtained a'b Convert 'c'd' to a decimal number to obtain the number corresponding to the IP address.
例如,针对1.23.74.255,可以将第一个字节的十进制数1转换为十六进制数01,将第二字节的十进制数23转换为十六进制数17,将第三字节的十进制数据74转换为十六进制数4A,将第四字节的十进制数255转换为十六进制数FF,按字节顺序将获得的十六进制数组合获得1174AFF,再将1174AFF转换为十进制,获得一串数字18303743,该数字即为1.23.74.255对应的数字。For example, for 1.23.74.255, the decimal number 1 in the first byte can be converted to hexadecimal number 01, the decimal number 23 in the second byte can be converted into hexadecimal number 17, and the third byte Convert the decimal data 74 to hexadecimal number 4A, convert the decimal number 255 of the fourth byte to hexadecimal number FF, combine the obtained hexadecimal numbers in byte order to obtain 1174AFF, and then convert 1174AFF Convert to decimal to get a string of numbers 18303743, which is the number corresponding to 1.23.74.255.
又如,针对1.23.75.8,可以将第一个字节的十进制数1转换为十六进制数01,将第二字节的十进制数23转换为十六进制数17,将第三字节的十进制数据75转换为十六进制数4B,将第四字节的十进制数8转换为十六进制数08,按字节顺序将获得的十六进制数组合获得1174B08,将1174B08转换为十进制,获得一串数字18303752,该数字即为1.23.75.8对应的数字。For another example, for 1.23.75.8, the decimal number 1 of the first byte can be converted to hexadecimal number 01, the decimal number 23 of the second byte can be converted to hexadecimal number 17, and the third byte can be converted to hexadecimal number 17. Convert the decimal data 75 of the section to hexadecimal number 4B, convert the decimal number 8 of the fourth byte to hexadecimal number 08, combine the obtained hexadecimal numbers in byte order to obtain 1174B08, and convert 1174B08 Convert to decimal to get a string of numbers 18303752, which is the number corresponding to 1.23.75.8.
关于预设顶级域,顶级域(或顶级域名;英语:Top-level Domain;英文缩写:TLD)是互联网DNS等级之中的最高级的域,它保存于DNS根域的名字空间中。顶级域名是域名的最后一个部分,例如在example.com这个域名中,顶级域是.com(或.COM),大小写视为相同。Regarding the default top-level domain, the top-level domain (or top-level domain name; English: Top-level Domain; English abbreviation: TLD) is the highest-level domain in the Internet DNS hierarchy, which is stored in the namespace of the DNS root domain. The top-level domain is the last part of the domain name. For example, in the domain name of example.com, the top-level domain is .com (or .COM), and the case is considered the same.
关于将数字与预设顶级域结合,在一个例子中,可以将数字放入预设顶级域作为一级域名。例如,假设顶级域为.com域,IP地址转换获得的数字为18303743,则组合获得目标域名:18303743.com。Regarding the combination of numbers with the default top-level domain, in one example, numbers can be put into the default top-level domain as a first-level domain name. For example, assuming that the top-level domain is the .com domain, and the number obtained by IP address translation is 18303743, the combination obtains the target domain name: 18303743.com.
在查询服务端中,将用户终端的IP地址转换为目标域名后,可以将携带有目标域名的查询请求发送至DNS服务端。所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。In the query server, after converting the IP address of the user terminal into the target domain name, a query request carrying the target domain name can be sent to the DNS server. The query request instructs the DNS server to query the reference domain name corresponding to the target domain name, where the reference domain name is used to identify the IP address range to which the IP address belongs.
在DNS服务端中,接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名;基于所述查询请求查询与所述目标域名对应的基准域名。由于所述基准域名用于标识所述IP地址归属的IP地址范围,而基于IP地址范围又可以确定归属地,因此,在DNS服务端将基准域名发送至查询服务端后,查询服务端可以基于预设对应关系查找与基准域名对应的归属地,从而实现IP地址归属地查询。In the DNS server, a query request sent by the query server is received, and the query request carries a target domain name corresponding to the IP address; the reference domain name corresponding to the target domain name is queried based on the query request. Since the reference domain name is used to identify the IP address range to which the IP address belongs, and the attribution can be determined based on the IP address range, after the DNS server sends the reference domain name to the query server, the query server can The preset correspondence relationship searches for the attribution corresponding to the reference domain name, so as to realize the IP address attribution query.
关于基于查询请求查询与目标域名对应的基准域名,在一个例子中,可以从区文件中查询与所述目标域名对应的基准域名,所述区文件是利用DNSSEC协议将DNS中基准域名签名后获得,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。Regarding the query of the reference domain name corresponding to the target domain name based on the query request, in one example, the reference domain name corresponding to the target domain name may be queried from a zone file obtained by using the DNSSEC protocol to sign the reference domain name in the DNS , the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs.
由于基准域名基于将IP地址归属的IP地址范围中的上限IP地址进行域名转换获得,因此,可以根据基准域名确定一个IP地址范围,而该IP地址范围即为所述用户终端的IP地址归属的IP地址范围。由此可见,通过查询目标域名对应基准域名的方式,即可确定IP地址归属的IP地址范围,提高查询效率。Since the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs, an IP address range can be determined according to the reference domain name, and the IP address range is the IP address of the user terminal to which the IP address belongs. IP address range. It can be seen that, by querying the target domain name corresponding to the reference domain name, the IP address range to which the IP address belongs can be determined, thereby improving the query efficiency.
在一个实施例中,在DNS服务端可以预先生成区文件。如图4所示,图4是本公开根据一示例性实施例示出的一种区文件生成过程的流程图,包括以下步骤401和步骤402:In one embodiment, the zone file may be pre-generated on the DNS server. As shown in FIG. 4 , FIG. 4 is a flowchart of a zone file generation process shown in the present disclosure according to an exemplary embodiment, including the following
在步骤401中,将各个IP地址范围中的上限IP地址进行域名转换,获得基准域名。In
由于IP地址都是分段分配的,某一个连续范围内的IP地址集合被分配给一个省份、城市或者运营商。例如,归属于IP地址范围1.23.64.0~1.23.74.255的IP属于地区A,归属于IP地址范围1.23.75.0~1.23.79.255的IP属于地区B。Since IP addresses are allocated in segments, a set of IP addresses in a contiguous range is allocated to a province, city or operator. For example, IPs belonging to the IP address range 1.23.64.0 to 1.23.74.255 belong to region A, and IPs belonging to the IP address range 1.23.75.0 to 1.23.79.255 belong to region B.
由于相邻IP地址范围中,排列在前的IP地址范围的上限IP地址,与排列在后的IP地址范围的下限IP地址连续,没有间隔IP地址,因此,可以利用IP地址范围中上限IP地址或下限IP地址标识该IP地址范围。作为一种实现手段,本公开实施例可以利用IP地址范围中上限IP地址标识该IP地址范围。In the adjacent IP address range, the upper limit IP address of the preceding IP address range is continuous with the lower limit IP address of the following IP address range, and there is no interval IP address. Therefore, the upper limit IP address in the IP address range can be used. or the lower bound IP address identifies the IP address range. As an implementation means, the embodiment of the present disclosure may use the upper limit IP address in the IP address range to identify the IP address range.
所谓上限IP地址是IP地址范围中的最大IP地址。例如,IP地址范围为1.23.64.0~1.23.74.255时,上限IP地址是1.23.74.255,IP地址范围为:1.23.75.0~1.23.79.255时,上限IP地址是1.23.79.255。所谓下限IP地址是IP地址范围中的最小IP地址。例如,IP地址范围为1.23.64.0~1.23.74.255时,下限IP地址是1.23.64.0,IP地址范围为:1.23.75.0~1.23.79.255时,下限IP地址是1.23.75.0。The so-called upper limit IP address is the largest IP address in the IP address range. For example, when the IP address range is 1.23.64.0 to 1.23.74.255, the upper limit IP address is 1.23.74.255, and when the IP address range is: 1.23.75.0 to 1.23.79.255, the upper limit IP address is 1.23.79.255. The so-called lower limit IP address is the smallest IP address in the IP address range. For example, when the IP address range is 1.23.64.0 to 1.23.74.255, the lower limit IP address is 1.23.64.0, and when the IP address range is: 1.23.75.0 to 1.23.79.255, the lower limit IP address is 1.23.75.0.
将上限IP地址进行域名转换的转换策略可以采用上述提及的将IP地址转换为目标域名的转换策略,为了节约篇幅,在此不再一一赘述。The conversion strategy for converting the upper limit IP address to the domain name may adopt the above-mentioned conversion strategy for converting the IP address into the target domain name, which will not be repeated here in order to save space.
在步骤402中,将基准域名存储在DNS中,并利用DNSSEC协议将DNS中基准域名签名后获得区文件。In
其中,将基准域名存储在DNS中时,会产生原始区文件,利用DNSSEC协议将DNS中的原始区文件签名后,可以获得本公开所提及的区文件。本公开所提及的区文件中包括各个基准域名的记录集合,且各基准域名的记录集合按预设策略进行排序,即记录集合是顺序存在的。在一个例子中,预设策略可以是按字母顺序排序的策略等。Wherein, when the reference domain name is stored in the DNS, an original zone file will be generated, and after the original zone file in the DNS is signed by using the DNSSEC protocol, the zone file mentioned in the present disclosure can be obtained. The zone file mentioned in the present disclosure includes record sets of each reference domain name, and the record sets of each reference domain name are sorted according to a preset policy, that is, the record sets exist in sequence. In one example, the preset strategy may be an alphabetical order strategy or the like.
DNS服务端可以从区文件中查询与目标域名对应的基准域名,由于基准域名基于将IP地址归属的IP地址范围中的上限IP地址进行域名转换获得,上限IP地址仅为所有IP地址中的部分IP地址,因此,区文件中记录的基准域名仅为部分域名,区文件中记录的基准域名的数量少于所有IP地址获得的目标域名的数量。鉴于此,在区文件中存在与目标域名匹配的基准域名时,可以将该匹配的基准域名作为目标域名对应的基准域名;如果在区文件中不存在与目标域名匹配的基准域名,则需要查找与目标域相关联的基准域名,并将相关联的基准域名作为目标域名对应的基准域名,其中,该关联的基准域名标识目标域名对应的IP地址归属的IP地址范围。The DNS server can query the reference domain name corresponding to the target domain name from the zone file. Since the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs, the upper limit IP address is only a part of all IP addresses. Therefore, the base domain names recorded in the zone file are only partial domain names, and the number of base domain names recorded in the zone file is less than the number of target domain names obtained by all IP addresses. In view of this, when there is a benchmark domain name matching the target domain name in the zone file, the matching benchmark domain name can be used as the benchmark domain name corresponding to the target domain name; if there is no benchmark domain name matching the target domain name in the zone file, you need to find The reference domain name associated with the target domain, and the associated reference domain name is used as the reference domain name corresponding to the target domain name, wherein the associated reference domain name identifies the IP address range to which the IP address corresponding to the target domain name belongs.
在一个可选的实现方式中,基准域名的记录集合中至少包括NESC(Next Secure)记录,NSEC记录是为响应某个记录不存在而设计的记录。NESC记录中记录有下一条记录集合的基准域名的名称。因此,所述从区文件中查询与所述目标域名对应的基准域名,包括:In an optional implementation manner, the record set of the reference domain name includes at least NESC (Next Secure) records, and the NSEC records are records designed in response to the absence of a certain record. The name of the base domain name of the next record set is recorded in the NESC record. Therefore, querying the reference domain name corresponding to the target domain name from the zone file includes:
从区文件中查询所述目标域名,当所述目标域名在第一基准域名和第二基准域名之间时,将所述第一基准域名的记录集合中的NESC记录发送至所述查询服务端。Query the target domain name from the zone file, when the target domain name is between the first benchmark domain name and the second benchmark domain name, send the NESC record in the record set of the first benchmark domain name to the query server .
其中,发送的NESC记录中记录有第二基准域名的名称,所述第一基准域名和第二基准域名是所述区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前。第一基准域名的记录集合中的NESC记录中包括第二基准域名的名称。第一基准域名所标识的IP地址范围和第二基准域名所标识的IP地址范围是相邻IP地址范围,即排列在前的IP地址范围的上限IP地址,与排列在后的IP地址范围的下限IP地址是连续的,没有间隔IP地址的。The name of the second benchmark domain name is recorded in the sent NESC record, the first benchmark domain name and the second benchmark domain name are adjacent benchmark domain names in the zone file, and the first benchmark domain name is arranged before the second benchmark domain name . The NESC record in the record set of the first reference domain name includes the name of the second reference domain name. The IP address range identified by the first reference domain name and the IP address range identified by the second reference domain name are adjacent IP address ranges, that is, the upper limit IP address of the IP address range arranged in the front, and the IP address range of the IP address range arranged in the rear. The lower limit IP address is continuous, and there is no interval IP address.
由上述实施例可见,由于本实施例可以将包含有NESC记录的结果发送至查询服务端,且NESC记录中记录有下一条记录集合的基准域名名称,因此获得与目标域名对应的基准域名,进而推断出用户终端的IP地址在以第二基准域名(查询服务端接收DNS服务端返回的基准域名)对应的IP地址为上限IP地址的IP地址范围内,从而便于后续根据IP地址范围确定归属地。It can be seen from the above-mentioned embodiment that, because this embodiment can send the result containing the NESC record to the query server, and the NESC record records the benchmark domain name name of the next record set, the benchmark domain name corresponding to the target domain name is obtained, and then the benchmark domain name corresponding to the target domain name is obtained. It is inferred that the IP address of the user terminal is within the IP address range with the IP address corresponding to the second reference domain name (the reference domain name returned by the query server receiving the DNS server) as the upper limit IP address, so as to facilitate the subsequent determination of the attribution according to the IP address range .
查询服务端中预先存储有基准域名与归属地的对应关系。所述对应关系根据基准域名与IP地址范围的关系、IP地址范围与归属地的对应关系确定。例如,IP地址范围1.23.64.0~1.23.74.255对应归属地为地区A,IP地址范围1.23.75.0~1.23.79.255对应归属地为地区B,因此,由IP地址范围中的上限IP地址(1.23.74.255)进行域名转换获得的基准域名18303743.com,其对应的IP地址范围为1.23.64.0~1.23.74.255,而IP地址范围1.23.64.0~1.23.74.255对应归属地为地区A,则基准域名18303743.com对应地区A,同理,基准域名18305023.com(1.23.79.255转换后的域名)对应地区B。查询服务端存储的对应关系可以以映射表的形式存在。The corresponding relationship between the reference domain name and the attribution is pre-stored in the query server. The corresponding relationship is determined according to the relationship between the reference domain name and the IP address range, and the corresponding relationship between the IP address range and the attribution. For example, the IP address range 1.23.64.0~1.23.74.255 corresponds to the region A, and the IP address range 1.23.75.0~1.23.79.255 corresponds to the region B. Therefore, the upper limit IP address in the IP address range (1.23. 74.255) The benchmark domain name 18303743.com obtained by domain name conversion, its corresponding IP address range is 1.23.64.0~1.23.74.255, and the IP address range 1.23.64.0~1.23.74.255 corresponds to the region A, then the benchmark domain name is 18303743 .com corresponds to region A. Similarly, the benchmark domain name 18305023.com (the converted domain name of 1.23.79.255) corresponds to region B. The correspondence stored in the query server can exist in the form of a mapping table.
因此,当查询结果中包括有下一条记录集合的基准域名的名称,则可以根据基准域名的名称以及查询服务端中预存的对应关系,确定基准域名对应的归属地,将查找到的归属地确定为IP地址的归属地。Therefore, when the query result includes the name of the benchmark domain name of the next record set, the attribution corresponding to the benchmark domain name can be determined according to the name of the benchmark domain name and the corresponding relationship pre-stored in the query server, and the found attribution can be determined. The home of the IP address.
可以理解的是,记录集合中还可以包括其他类型的记录,例如,RRSIG、DNSKEY、DS等,在此不再一一列举。It can be understood that the record set may also include other types of records, for example, RRSIG, DNSKEY, DS, etc., which will not be listed one by one here.
以上实施方式中的各种技术特征可以任意进行组合,只要特征之间的组合不存在冲突或矛盾,但是限于篇幅,未进行一一描述,因此上述实施方式中的各种技术特征的任意进行组合也属于本说明书公开的范围。以下以一个交互实施例进行示例说明。Various technical features in the above embodiments can be combined arbitrarily, as long as there is no conflict or contradiction between the combinations of features, but due to space limitations, they are not described one by one, so the various technical features in the above embodiments can be combined arbitrarily It also belongs to the scope of the disclosure of this specification. The following is an example of an interactive embodiment.
如图5所示,图5是本公开根据一示例性实施例示出的一种IP地址归属地查询方法的交互示意图。在该示意图中,查询服务端将用户终端的IP地址转换为目标域名(步骤501)。查询服务端向DNS服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围(步骤502)。DNS服务端从区文件中查询与所述目标域名对应的基准域名(步骤503)。其中,所述区文件是利用DNSSEC协议将DNS中基准域名签名后获得,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。所述区文件中各基准域名的记录集合按预设策略进行排序,所述记录集合中至少包括NESC记录,所述NESC记录中记录有下一条记录集合的基准域名的名称。在一个例子中,所述从区文件中查询与所述目标域名对应的基准域名,包括:若区文件中存在与所述目标域名匹配的基准域名,则将匹配的基准域名作为目标域名对应的基准域名。在一个例子中,所述从区文件中查询与所述目标域名对应的基准域名,包括:从区文件中查询所述目标域名,当所述目标域名在第一基准域名和第二基准域名之间时,将所述第一基准域名的记录集合中的NESC记录发送至所述查询服务端;其中,发送的NESC记录中记录有第二基准域名的名称,所述第一基准域名和第二基准域名是所述区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前。DNS服务端向查询服务端发送基准域名(步骤504)。查询服务端接收DNS服务端返回的基准域名,并基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系(步骤505)。As shown in FIG. 5 , FIG. 5 is an interactive schematic diagram of a method for querying IP address attribution according to an exemplary embodiment of the present disclosure. In this schematic diagram, the query server converts the IP address of the user terminal into the target domain name (step 501). The query server sends a query request carrying the target domain name to the DNS server, the query request instructs the DNS server to query the reference domain name corresponding to the target domain name, and the reference domain name is used to identify the IP address to which the IP address belongs. IP address range (step 502). The DNS server queries the reference domain name corresponding to the target domain name from the zone file (step 503). The zone file is obtained by using the DNSSEC protocol to sign the reference domain name in the DNS, and the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs. The record sets of each reference domain name in the zone file are sorted according to a preset strategy, the record set includes at least NESC records, and the NESC records record the name of the reference domain name of the next record set. In one example, the querying the reference domain name corresponding to the target domain name from the zone file includes: if there is a reference domain name matching the target domain name in the zone file, taking the matched reference domain name as the target domain name corresponding to the target domain name Base domain name. In an example, the querying the reference domain name corresponding to the target domain name from the zone file includes: querying the target domain name from the zone file, when the target domain name is between the first reference domain name and the second reference domain name time, send the NESC record in the record set of the first benchmark domain name to the query server; wherein, the sent NESC record records the name of the second benchmark domain name, the first benchmark domain name and the second benchmark domain name The reference domain name is the adjacent reference domain name in the zone file, and the first reference domain name is arranged before the second reference domain name. The DNS server sends the reference domain name to the query server (step 504). The query server receives the reference domain name returned by the DNS server, searches for the attribution corresponding to the reference domain name based on the preset correspondence, and determines the found attribution as the attribution of the IP address, and the preset corresponding The relationship is the corresponding relationship between the pre-stored reference domain name and the attribution (step 505).
以下列举一个具体的应用实例进行说明。A specific application example is listed below for illustration.
以IP地址范围1.23.64.0~1.23.74.255和IP地址范围1.23.75.0~1.23.79.255进行说明。将各个IP地址范围的段尾(上限IP地址)表示的点分十进制转换为对应的数字放入某个顶级域下作为一级域名,如放入.com域下,则1.23.74.255存储变为18303743.com,则1.23.79.255存储变为18305023.com。The IP address range 1.23.64.0 to 1.23.74.255 and the IP address range 1.23.75.0 to 1.23.79.255 will be described. Convert the dotted decimal represented by the end of the segment (upper IP address) of each IP address range into the corresponding number and put it under a top-level domain as a first-level domain name. 18303743.com, then 1.23.79.255 storage becomes 18305023.com.
使用基于DNSSEC协议的方式将基准域名录入到DNS中,在完成签名后会获得一个签完名的、按照字母顺序排好序的区文件,DNS将该区文件加载到内存中,提供给DNS服务器进行域名查询。Use the DNSSEC protocol-based method to enter the reference domain name into the DNS. After completing the signature, a signed zone file in alphabetical order will be obtained. The DNS will load the zone file into the memory and provide it to the DNS server. Do a domain name lookup.
在DNSSEC签名后的区文件中,这两条记录是顺序存在的。In the zone file after DNSSEC signature, these two records exist sequentially.
18303743.com.10800 IN A 1.23.74.25518303743.com.10800 IN A 1.23.74.255
172800 NSEC 18305023.com.A RRSIG NSEC172800 NSEC 18305023.com.A RRSIG NSEC
172800 RRSIG NSEC 5 5 172800 20160611031416(201605120314165271com.Ujw/aq….15dV5tF7XgWSR78=)172800 RRSIG NSEC 5 5 172800 20160611031416 (201605120314165271com.Ujw/aq….15dV5tF7XgWSR78=)
18305023.com.10800 IN A 1.23.79.25518305023.com.10800 IN A 1.23.79.255
可见,在18303743.com的NSEC中记录有下一条记录集合的基准域名名称18305023.com。It can be seen that the base domain name 18305023.com of the next record set is recorded in the NSEC of 18303743.com.
当查询服务端接收到携带IP地址的请求时,将IP地址转换为数字+.com的形式,获得待查找的域名,并将域名发送至DNS服务端。假设IP地址为1.23.75.8,则实际去查的记录为18303752.com,因为DNS的区文件中不存在这条记录,所以就返回记录不存在,同时把18303743.com(也就是18303752.com最近的上一条记录)的NSEC记录返回,即NSEC的值为18305023.com。When the query server receives the request carrying the IP address, it converts the IP address into the form of number + .com, obtains the domain name to be searched, and sends the domain name to the DNS server. Assuming that the IP address is 1.23.75.8, the actual record to be checked is 18303752.com, because this record does not exist in the DNS zone file, so the return record does not exist, and 18303743.com (that is, 18303752.com recently The NSEC record of the previous record) is returned, that is, the value of NSEC is 18305023.com.
由于查询服务端中记录有基准域名与归属地的对应关系,因此可以查找出18305023.com对应的归属地为地区B。Since the correspondence between the reference domain name and the attribution is recorded in the query server, it can be found that the attribution corresponding to 18305023.com is region B.
可见,将原始地区信息的IP数据转化为域名的格式录入到DNS中,并对DNS的区文件进行DNSSEC签名。DNS是一个互联网基础协议,安全可靠,并且天然支持分布式部署,通过递归服务器和权威服务器配合可以加快查询速度,不用自建第三方架构,DNS是基础服务,成本低。It can be seen that the IP data of the original area information is converted into the format of the domain name and entered into the DNS, and the DNSSEC signature is performed on the area file of the DNS. DNS is a basic Internet protocol, which is safe and reliable, and naturally supports distributed deployment. Through the cooperation of recursive servers and authoritative servers, the query speed can be accelerated, and there is no need to build a third-party architecture. DNS is a basic service with low cost.
与前述IP地址归属地查询方法的实施例相对应,本公开还提供了IP地址归属地查询装置、系统、存储介质及其所应用的服务端的实施例。Corresponding to the foregoing embodiments of the IP address attribution query method, the present disclosure also provides embodiments of an IP address attribution query apparatus, system, storage medium, and a server to which it is applied.
如图6所示,图6是本公开根据一示例性实施例示出的一种IP地址归属地查询系统的框图,所述系统包括查询服务端61和DNS服务端62。As shown in FIG. 6 , FIG. 6 is a block diagram of an IP address attribution query system according to an exemplary embodiment of the present disclosure. The system includes a
所述查询服务端61将用户终端的IP地址转换为目标域名,并将携带所述目标域名的查询请求发送至所述DNS服务端62。The
所述DNS服务端62基于所述查询请求查询与所述目标域名对应的基准域名,并向所述查询服务端61发送所述基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。The
所述查询服务端61基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。The
由上述实施例可见,通过查询服务端将用户终端的IP地址转换为目标域名,并将目标域名发送至DNS服务端,DNS服务端基于查询请求查询与目标域名对应的基准域名,由于基准域名用于标识所述IP地址归属的IP地址范围,因此,在DNS服务端向查询服务端发送基准域名后,查询服务端可以基于预设对应关系查找与基准域名对应的归属地,从而将查找到的归属地确定为IP地址的归属地,实现快速查询IP地址的归属地。It can be seen from the above embodiment that the IP address of the user terminal is converted into the target domain name through the query server, and the target domain name is sent to the DNS server, and the DNS server queries the reference domain name corresponding to the target domain name based on the query request. In order to identify the IP address range to which the IP address belongs, after the DNS server sends the reference domain name to the query server, the query server can search for the attribution corresponding to the reference domain name based on the preset correspondence, so that the found The attribution is determined as the attribution of the IP address, so as to quickly query the attribution of the IP address.
在一个可选的实现方式中,所述将用户终端的IP地址转换为目标域名,包括:将IP地址转换为数字;将所述数字与预设顶级域结合,获得IP地址对应的目标域名。In an optional implementation manner, the converting the IP address of the user terminal into the target domain name includes: converting the IP address into a number; and combining the number with a preset top-level domain to obtain the target domain name corresponding to the IP address.
在一个可选的实现方式中,所述将IP地址转换为数字,包括:In an optional implementation manner, the converting the IP address into a number includes:
将IP地址中每个字节的十进制数转换为十六进制数;Convert the decimal number to hexadecimal number of each byte in the IP address;
将各字节转换获得的十六进制数按IP地址中字节顺序进行组合,获得一个十六进制数;Combine the hexadecimal numbers obtained by converting each byte in the order of bytes in the IP address to obtain a hexadecimal number;
将组合获得的十六进制数转换为十进制数,获得所述IP地址对应的数字。Convert the hexadecimal number obtained by the combination into a decimal number to obtain the number corresponding to the IP address.
在一个可选的实现方式中,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。In an optional implementation manner, the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs.
在一个可选的实现方式中,所述基于所述查询请求查询与所述目标域名对应的基准域名,包括:从区文件中查询与所述目标域名对应的基准域名,所述区文件是利用DNSSEC协议将DNS中基准域名签名后获得,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。In an optional implementation manner, the querying the reference domain name corresponding to the target domain name based on the query request includes: querying the reference domain name corresponding to the target domain name from a zone file, the zone file using The DNSSEC protocol is obtained by signing the reference domain name in the DNS, and the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs.
在一个可选的实现方式中,所述区文件中各基准域名的记录集合按预设策略进行排序,所述记录集合中至少包括NESC记录,所述NESC记录中记录有下一条记录集合的基准域名的名称;In an optional implementation manner, the record sets of each reference domain name in the zone file are sorted according to a preset policy, the record set includes at least NESC records, and the NESC records record the benchmark of the next record set the name of the domain name;
所述从区文件中查询与所述目标域名对应的基准域名,包括:从区文件中查询所述目标域名,当所述目标域名在第一基准域名和第二基准域名之间时,将所述第一基准域名的记录集合中的NESC记录发送至所述查询服务端;The querying the reference domain name corresponding to the target domain name from the zone file includes: querying the target domain name from the zone file, when the target domain name is between the first reference domain name and the second reference domain name, querying the target domain name. sending the NESC record in the record set of the first reference domain name to the query server;
其中,发送的NESC记录中记录有第二基准域名的名称,所述第一基准域名和第二基准域名是所述区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前。The name of the second benchmark domain name is recorded in the sent NESC record, the first benchmark domain name and the second benchmark domain name are adjacent benchmark domain names in the zone file, and the first benchmark domain name is arranged before the second benchmark domain name .
如图7所示,图7是本公开根据一示例性实施例示出的一种IP地址归属地查询装置的框图,所述装置包括:信息转换模块710、信息通信模块720和归属地确定模块730。As shown in FIG. 7 , FIG. 7 is a block diagram of an IP address attribution query apparatus according to an exemplary embodiment of the present disclosure, the apparatus includes: an
信息转换模块710,被配置为将用户终端的IP地址转换为目标域名。The
信息通信模块720,被配置为向DNS服务端发送携带有所述目标域名的查询请求,并接收DNS服务端返回的基准域名;所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。The
归属地确定模块730,被配置为基于预设对应关系查找所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。The
在一个可选的实现方式中,所述信息转换模块710,具体配置为:将IP地址转换为数字;将所述数字与预设顶级域结合,获得IP地址对应的目标域名。In an optional implementation manner, the
由上述实施例可见,将IP地址转换为数字,并将数字与预设顶级域结合,实现将用户终端的IP地址转换为目标域名,既提高了域名转换效率,又提高了后续域名查找时的查找效率。It can be seen from the above embodiment that the IP address is converted into a number, and the number is combined with the preset top-level domain to realize the conversion of the IP address of the user terminal into the target domain name, which not only improves the domain name conversion efficiency, but also improves the subsequent domain name lookup. Find efficiency.
在一个可选的实现方式中,所述信息转换模块710,具体配置为:In an optional implementation manner, the
将IP地址中每个字节的十进制数转换为十六进制数;Convert the decimal number to hexadecimal number of each byte in the IP address;
将各字节转换获得的十六进制数按IP地址中字节顺序进行组合,获得一个十六进制数;Combine the hexadecimal numbers obtained by converting each byte in the order of bytes in the IP address to obtain a hexadecimal number;
将组合获得的十六进制数转换为十进制数,获得所述IP地址对应的数字。在一个可选的实现方式中,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。Convert the hexadecimal number obtained by the combination into a decimal number to obtain the number corresponding to the IP address. In an optional implementation manner, the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs.
如图8所示,图8是本公开根据一示例性实施例示出的另一种IP地址归属地查询装置的框图,所述装置包括:As shown in FIG. 8, FIG. 8 is a block diagram of another IP address attribution query apparatus shown in the present disclosure according to an exemplary embodiment, and the apparatus includes:
信息通信模块810,被配置为接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名;The
域名查询模块820,被配置为基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;a domain
所述信息通信模块810,还被配置为向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。The
在一个可选的实现方式中,所述域名查询模块820,具体配置为:In an optional implementation manner, the domain
从区文件中查询与所述目标域名对应的基准域名,所述区文件是利用DNSSEC协议将DNS中基准域名签名后获得,所述基准域名基于将所述IP地址归属的IP地址范围中的上限IP地址进行域名转换获得。The reference domain name corresponding to the target domain name is queried from the zone file. The zone file is obtained by using the DNSSEC protocol to sign the reference domain name in the DNS. The reference domain name is based on the upper limit of the IP address range to which the IP address belongs. The IP address is obtained by domain name conversion.
由上述实施例可见,由于基准域名基于将IP地址归属的IP地址范围中的上限IP地址进行域名转换获得,因此,可以根据基准域名确定一个IP地址范围,而该IP地址范围即为所述用户终端的IP地址归属的IP地址范围。由此可见,通过查询目标域名对应基准域名的方式,即可确定IP地址归属的IP地址范围,提高查询效率。As can be seen from the above embodiment, since the reference domain name is obtained by domain name conversion based on the upper limit IP address in the IP address range to which the IP address belongs, an IP address range can be determined according to the reference domain name, and the IP address range is the user. The IP address range to which the terminal's IP address belongs. It can be seen that, by querying the target domain name corresponding to the reference domain name, the IP address range to which the IP address belongs can be determined, thereby improving the query efficiency.
在一个可选的实现方式中,所述区文件中各基准域名的记录集合按预设策略进行排序,所述记录集合中至少包括NESC记录,所述NESC记录中记录有下一条记录集合的基准域名的名称;所述域名查询模块820,具体配置为:In an optional implementation manner, the record sets of each reference domain name in the zone file are sorted according to a preset policy, the record set includes at least NESC records, and the NESC records record the benchmark of the next record set The name of the domain name; the domain
从区文件中查询所述目标域名,当所述目标域名在第一基准域名和第二基准域名之间时,将所述第一基准域名的记录集合中的NESC记录发送至所述查询服务端;Query the target domain name from the zone file, when the target domain name is between the first benchmark domain name and the second benchmark domain name, send the NESC record in the record set of the first benchmark domain name to the query server ;
其中,发送的NESC记录中记录有第二基准域名的名称,所述第一基准域名和第二基准域名是所述区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前。The name of the second benchmark domain name is recorded in the sent NESC record, the first benchmark domain name and the second benchmark domain name are adjacent benchmark domain names in the zone file, and the first benchmark domain name is arranged before the second benchmark domain name .
由上述实施例可见,DNS服务端从区文件中查询目标域名,当目标域名在第一基准域名和第二基准域名之间时,将第一基准域名的记录集合中的NESC记录返回至查询服务端,由于第一基准域名和第二基准域名是区文件中相邻基准域名,且第一基准域名排列在第二基准域名之前,第一基准域名的记录集合中NESC记录包括第二基准域名的名称,以便查询服务端获得与目标域名对应的基准域名,进而可以推断出用户终端的IP地址在以第二基准域名对应的IP地址为上限IP地址的IP地址范围内,进而确定出用户终端的IP地址的归属地,提高归属地查询效率。It can be seen from the above embodiment that the DNS server queries the target domain name from the zone file, and when the target domain name is between the first benchmark domain name and the second benchmark domain name, returns the NESC record in the record set of the first benchmark domain name to the query service. On the other hand, since the first benchmark domain name and the second benchmark domain name are adjacent benchmark domain names in the zone file, and the first benchmark domain name is arranged before the second benchmark domain name, the NESC record in the record set of the first benchmark domain name includes the data of the second benchmark domain name. In order to query the server to obtain the reference domain name corresponding to the target domain name, it can be inferred that the IP address of the user terminal is within the IP address range with the IP address corresponding to the second reference domain name as the upper limit IP address, and then determine the user terminal’s IP address. The attribution of the IP address improves the efficiency of attribution query.
相应的,本公开还提供一种IP地址归属地查询装置,所述装置包括有处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为:Correspondingly, the present disclosure also provides an IP address attribution query apparatus, the apparatus includes a processor; a memory for storing executable instructions of the processor; wherein the processor is configured to:
将用户终端的IP地址转换为目标域名;Convert the IP address of the user terminal to the target domain name;
向DNS服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;Send a query request carrying the target domain name to the DNS server, where the query request instructs the DNS server to query the reference domain name corresponding to the target domain name, and the reference domain name is used to identify the IP address range to which the IP address belongs ;
接收DNS服务端返回的基准域名;Receive the base domain name returned by the DNS server;
基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Based on a preset correspondence relationship, the attribution corresponding to the reference domain name is searched, and the found attribution is determined as the attribution of the IP address, and the preset correspondence is a pre-stored correspondence between the reference domain name and the attribution.
相应的,本公开还提供一种IP地址归属地查询装置,所述装置包括有处理器;用于存储处理器可执行指令的存储器;其中,所述处理器被配置为:Correspondingly, the present disclosure also provides an IP address attribution query apparatus, the apparatus includes a processor; a memory for storing executable instructions of the processor; wherein the processor is configured to:
接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名;receiving a query request sent by the query server, where the query request carries a target domain name corresponding to the IP address;
基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围;Query a reference domain name corresponding to the target domain name based on the query request, where the reference domain name is used to identify the IP address range to which the IP address belongs;
向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Send the reference domain name to the query server, so that the query server searches for the attribution corresponding to the reference domain name based on the preset correspondence, and determines the found attribution as the attribution of the IP address. The preset corresponding relationship is the corresponding relationship between the pre-stored reference domain name and the attribution.
上述装置中各个模块的功能和作用的实现过程具体详情见上述方法中对应步骤的实现过程,在此不再赘述。For the specific details of the implementation process of the functions and functions of each module in the above device, see the implementation process of the corresponding steps in the above method, which will not be repeated here.
对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本公开方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。For the apparatus embodiments, since they basically correspond to the method embodiments, reference may be made to the partial descriptions of the method embodiments for related parts. The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in One place, or it can be distributed over multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present disclosure. Those of ordinary skill in the art can understand and implement it without creative effort.
相应的,本公开还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述任一项应用在查询服务端中所述IP地址归属地查询方法的步骤。Correspondingly, the present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the steps of any of the above-mentioned IP address attribution query methods applied in the query server. .
相应的,本公开还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述任一项应用在DNS服务端中所述IP地址归属地查询方法的步骤。Correspondingly, the present disclosure also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the steps of any of the above-mentioned IP address attribution query methods applied in the DNS server. .
本公开可采用在一个或多个其中包含有程序代码的存储介质(包括但不限于磁盘存储器、CD-ROM(Compact Disc Read-Only Memory,只读光盘)、光学存储器等)上实施的计算机程序产品的形式。计算机可用存储介质包括永久性和非永久性、可移动和非可移动媒体,可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括但不限于:相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、CD-ROM、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。The present disclosure may employ a computer program implemented on one or more storage media (including, but not limited to, magnetic disk storage, CD-ROM (Compact Disc Read-Only Memory), optical storage, etc.) having program codes contained therein form of the product. Computer-usable storage media includes permanent and non-permanent, removable and non-removable media, and storage of information can be accomplished by any method or technology. Information may be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash Memory or other memory technology, CD-ROM, Digital Versatile Disc (DVD) or other optical storage, Magnetic Cassettes, Magnetic Magnetic Disks Storage or other magnetic storage device or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
如图9所示,图9是根据一示例性实施例示出的一种用于IP地址归属地查询的装置900的框图。As shown in FIG. 9, FIG. 9 is a block diagram of an
例如,装置900可以被提供为服务端设备。参照图9,系统900包括处理组件922,其进一步包括一个或多个处理器,以及由存储器932所代表的存储器资源,用于存储可由处理部件922的执行的指令,例如应用程序。存储器932中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件922被配置为执行指令,以执行上述IP地址归属地查询方法。For example, the
系统900还可以包括一个电源组件926被配置为执行系统900的电源管理,一个有线或无线网络接口950被配置为将系统900连接到网络,和一个输入输出(I/O)接口958。系统900可以操作基于存储在存储器932的操作系统。
其中,当所述存储器932中的指令由所述处理组件922执行时,使得系统900能够执行一种IP地址归属地查询方法,包括:Wherein, when the instructions in the
将用户终端的IP地址转换为目标域名。Convert the IP address of the user terminal to the target domain name.
向DNS服务端发送携带有所述目标域名的查询请求,所述查询请求指示DNS服务端查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。Send a query request carrying the target domain name to the DNS server, where the query request instructs the DNS server to query the reference domain name corresponding to the target domain name, and the reference domain name is used to identify the IP address range to which the IP address belongs .
接收DNS服务端返回的基准域名。Receive the base domain name returned by the DNS server.
基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Based on a preset correspondence relationship, the attribution corresponding to the reference domain name is searched, and the found attribution is determined as the attribution of the IP address, and the preset correspondence is a pre-stored correspondence between the reference domain name and the attribution.
如图10所示,图10是根据一示例性实施例示出的另一种用于IP地址归属地查询的装置1000的框图。As shown in FIG. 10 , FIG. 10 is a block diagram of another
例如,装置1000可以被提供为服务端设备。参照图10,系统1000包括处理组件1022,其进一步包括一个或多个处理器,以及由存储器1032所代表的存储器资源,用于存储可由处理部件1022的执行的指令,例如应用程序。存储器1032中存储的应用程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理组件1022被配置为执行指令,以执行上述IP地址归属地查询方法。For example, the
系统1000还可以包括一个电源组件1026被配置为执行系统1000的电源管理,一个有线或无线网络接口1050被配置为将系统1000连接到网络,和一个输入输出(I/O)接口1058。系统1000可以操作基于存储在存储器1032的操作系统。
其中,当所述存储器1032中的指令由所述处理组件1022执行时,使得系统1000能够执行一种IP地址归属地查询方法,包括:Wherein, when the instructions in the
接收查询服务端发送的查询请求,所述查询请求中携带有与IP地址对应的目标域名。A query request sent by the query server is received, where the query request carries a target domain name corresponding to the IP address.
基于所述查询请求查询与所述目标域名对应的基准域名,所述基准域名用于标识所述IP地址归属的IP地址范围。The reference domain name corresponding to the target domain name is queried based on the query request, where the reference domain name is used to identify the IP address range to which the IP address belongs.
向所述查询服务端发送所述基准域名,以使查询服务端基于预设对应关系查找与所述基准域名对应的归属地,将查找到的归属地确定为所述IP地址的归属地,所述预设对应关系是预存的基准域名与归属地的对应关系。Send the reference domain name to the query server, so that the query server searches for the attribution corresponding to the reference domain name based on the preset correspondence, and determines the found attribution as the attribution of the IP address. The preset corresponding relationship is the corresponding relationship between the pre-stored reference domain name and the attribution.
本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本公开的其它实施方案。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。Other embodiments of the present disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common general knowledge or techniques in the technical field not disclosed by this disclosure . The specification and examples are to be regarded as exemplary only, with the true scope and spirit of the disclosure being indicated by the following claims.
应当理解的是,本公开并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本公开的范围仅由所附的权利要求来限制。It is to be understood that the present disclosure is not limited to the precise structures described above and illustrated in the accompanying drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
以上所述仅为本公开的较佳实施例而已,并不用以限制本公开,凡在本公开的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本公开保护的范围之内。The above descriptions are only preferred embodiments of the present disclosure, and are not intended to limit the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure shall be included in the present disclosure. within the scope of protection.
Claims (17)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710851764.5A CN107613039B (en) | 2017-09-19 | 2017-09-19 | IP address attribution query method, device, system and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710851764.5A CN107613039B (en) | 2017-09-19 | 2017-09-19 | IP address attribution query method, device, system and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107613039A CN107613039A (en) | 2018-01-19 |
CN107613039B true CN107613039B (en) | 2020-11-20 |
Family
ID=61061377
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710851764.5A Active CN107613039B (en) | 2017-09-19 | 2017-09-19 | IP address attribution query method, device, system and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107613039B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108494891A (en) * | 2018-02-28 | 2018-09-04 | 网宿科技股份有限公司 | A kind of domain name analytic method, server and system |
CN108985759B (en) * | 2018-06-15 | 2020-10-23 | 杭州复杂美科技有限公司 | Address generating method, system, equipment and storage medium for cryptocurrency |
CN109684303B (en) * | 2018-12-10 | 2020-10-27 | 世纪龙信息网络有限责任公司 | Communication code attribution inquiry method and device, computer equipment and storage medium |
CN109558387B (en) * | 2018-12-11 | 2020-10-30 | 北京锐安科技有限公司 | Identification number processing method, device, storage medium and terminal |
CN112532414B (en) * | 2019-09-18 | 2023-05-02 | 中国移动通信集团河北有限公司 | Method, device, equipment and computer storage medium for determining ISP attribution |
CN116319661A (en) * | 2023-03-20 | 2023-06-23 | 湖南快乐阳光互动娱乐传媒有限公司 | A Method for Determining Attribution Information Based on IPv6 Address and Related Equipment |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101242426B (en) * | 2007-02-06 | 2010-12-08 | 华为技术有限公司 | Method, system and device for establishing transport layer security connection |
CN101902442B (en) * | 2009-05-25 | 2014-03-05 | 中国科学院计算机网络信息中心 | Method, system and location information server for obtaining IP geographic location information |
WO2013123392A1 (en) * | 2012-02-16 | 2013-08-22 | San Diego State University Research Foundation | Method and apparatus for visualizing geospatial fingerprints on web information landscapes |
-
2017
- 2017-09-19 CN CN201710851764.5A patent/CN107613039B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN107613039A (en) | 2018-01-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107613039B (en) | IP address attribution query method, device, system and storage medium | |
US11816161B2 (en) | Asset search and discovery system using graph data structures | |
US9231903B2 (en) | System and method for resolving a DNS request using metadata | |
JP6861219B2 (en) | Methods and Devices for Intelligent Domain Name System Transfer | |
CN112347377B (en) | IP address field searching method, service scheduling method, device and electronic equipment | |
US7467230B2 (en) | Global names zone | |
WO2021078281A1 (en) | Message forwarding and domain name address query | |
CN106797410A (en) | Domain name analytic method and device | |
CN102546854A (en) | Domain name analysis method for building hyper text transport protocol (HTTP) connection for domain name and server | |
US10498694B2 (en) | Mapping IPv4 knowledge to IPv6 | |
CN111726428B (en) | Authoritative server selection method, device, equipment and storage medium | |
CN115037720B (en) | Domain name resolution request processing method and device, electronic equipment and storage medium | |
CN108848205B (en) | CNAME domain name resolution method for distinguishing IPv4 and IPv6 | |
CN105282269B (en) | A kind of configuration method and method of servicing of local dns root server | |
CN110071986A (en) | A system for domain name resolution | |
CN114301874B (en) | IPv6 address positioning method based on IPv4 address geographical position information and electronic equipment | |
CN111416880A (en) | IP address addressing method and device, computer storage medium and electronic equipment | |
CN108471458A (en) | authoritative DNS service providing method and system | |
Blanchet | Finding the Authoritative Registration Data (RDAP) Service | |
CN112839113B (en) | Domain name storage and resolution method and device, electronic equipment and storage medium | |
EP3340582A1 (en) | Determining a top level domain from a domain name | |
CN103347036A (en) | ONS architecture with decentralized management-based EPC parsing method | |
CN110677512B (en) | Address resolution method and device | |
CN107231447A (en) | A kind of website spatial identification method and system | |
CN100355315C (en) | Method for implementing telephone number to uniform resource identifier mapping business |
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 |