Domain name server resolution acceleration method and device
By loading the query keywords and response data of hot domain names in the kernel space and using hook nodes to process DNS query packets, the problem of poor versatility caused by relying on third-party code libraries and hardware environments in the existing technology is solved, and high efficiency of domain name servers is achieved. Parsing acceleration and support for complex protocol scenarios.
Patent Information
- Application Number
- CN202310020762.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-06
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2043-01-06
AI Technical Summary
Existing domain name server resolution acceleration methods rely on third-party code libraries and hardware environments, resulting in poor versatility and inability to effectively handle complex protocol scenarios such as TCP retransmissions.
By loading the query keywords and response data of hot domain names in the kernel space, hook nodes are used to detect the DNS query packets uploaded by the network card in the kernel space, and directly obtain and return the response data from the response database to achieve fast responses and avoid kernel/user mode switching. , supports TCP and UDP protocols.
It improves the resolution performance of the domain name server, achieves fast response to hot domain names, improves the overall performance, and does not rely on third-party code libraries and hardware environments, and has better versatility.
Smart Images

Figure CN116170408B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a method and device for accelerating domain name server resolution. Background Art
[0002] The domain name system is the entrance to Internet services. With the vigorous development of the Internet, massive edge and mobile devices have brought about massive connections and interactions, and the amount of domain name resolution has exploded exponentially. It is necessary to innovate the addressing and resolution architecture to improve the resolution performance of the domain name server (DNS) to meet the needs of high throughput and low latency. At present, the resolution performance of the DNS server is mainly limited by the system consumption (protocol stack processing, kernel / user mode switching, etc.) in the process of sending query requests to the application layer and the processing consumption of the application layer itself. Therefore, the key to achieving resolution acceleration of the DNS server lies in improving the processing performance of these two parts. At present, there are two more common solutions in the industry: Data Plane Development Kit (DPDK) and eXpress Data Path (XDP). The two solutions directly process data packets at the user layer and kernel layer respectively, avoiding the switching overhead of user and kernel modes.
[0003] The principle of DPDK's acceleration solution is to run in user space and use the data plane library it provides to send and receive data packets. DPDK bypasses the Linux kernel protocol stack and directly transfers data packets from the network card to the user state, relying on some special optimizations of Intel's own processors to process data packets at high speed. The high-performance DNS server implemented by DPDK can achieve a single-machine resolution performance of tens of millions. However, its biggest problem is that it needs to rely on third-party code libraries and licenses, and has high requirements for the hardware environment. In addition, since Docker shares the Linux kernel, it cannot be integrated with the application container engine (Docker) environment.
[0004] After the Extended Berkeley Packet Filter (eBPF) technology has attracted widespread attention in the industry, a new solution for high-performance parsing has been developed. The XDP solution uses eBPF technology to mount an event-based hook, which is located before the kernel network protocol stack. Therefore, after the UDP data packet enters the network card, it can bypass the protocol stack and be directly sent to the parsing software for processing, improving the parsing performance. Compared with DPDK, XDP does not require third-party code libraries and licenses. Currently, the open source parsing software Knot provided by CZNIC has released an official version that supports the XDP high-performance parsing mode, with a parsing performance of tens of millions.
[0005] Both DPDK and XDP bypass the Linux kernel's protocol stack to process data packets. Therefore, they do not have the universality of the network protocol stack and cannot handle many complex protocol scenarios, especially the TCP protocol, such as TCP retransmission, etc. Therefore, implementing a more universal parsing acceleration method that is not dependent on third-party code libraries and hardware environments is a technical problem that needs to be solved urgently. Summary of the invention
[0006] The present invention provides a domain name server resolution acceleration method and device, which are used to solve the problem of poor versatility caused by the need to rely on a third-party code library and hardware environment in the domain name server resolution acceleration method of the prior art.
[0007] The present invention provides a method for accelerating domain name server resolution, comprising:
[0008] Obtain a query keyword of a hot domain name, and load the query keyword and its corresponding response data from the DNS resolver in the user space into a response database in the kernel space, wherein the hot domain name is a domain name with a query volume exceeding a certain threshold;
[0009] The DNS query packet uploaded by the network card is detected in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card.
[0010] According to a domain name server resolution acceleration method provided by the present invention, a query keyword of a hotspot domain name is obtained, and the query keyword and its corresponding response data are loaded from a DNS resolver in a user space into a response database in a kernel space, including:
[0011] Read the preset hotspot domain name configuration table to obtain the query keyword of the hotspot domain name;
[0012] Obtaining response data corresponding to the query keyword of the hotspot domain name from the user space DNS resolver using the DNS query protocol;
[0013] The response data is encoded, and the query keyword of the hotspot domain name and the corresponding encoded response data are loaded into the response database for storage.
[0014] According to a domain name server resolution acceleration method provided by the present invention, a DNS query packet uploaded by a network card is detected in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card, including:
[0015] Detecting the data packets uploaded by the network card in the kernel space, and filtering out the DNS query packet from the data packets;
[0016] Matching the query keyword in the DNS query packet with the keyword stored in the response database;
[0017] In case of successful matching, the response data corresponding to the query keyword is obtained, and a response data packet is generated according to the response data and returned to the network card.
[0018] According to a method for accelerating domain name server resolution provided by the present invention, in the case of successful matching, the step of obtaining the response data corresponding to the query keyword, and generating a response data packet according to the response data and returning it to the network card, before generating the response data packet, it also includes:
[0019] The response data is encoded according to the query flags other than the query keyword in the DNS query packet.
[0020] According to a domain name server resolution acceleration method provided by the present invention, a DNS query packet uploaded by a network card is detected in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card, and further includes:
[0021] In the event of a match failure, the DNS query packet is sent to a DNS resolver in user space, and the DNS resolver responds to the query.
[0022] According to a domain name server resolution acceleration method provided by the present invention, a hook node is mounted in the kernel space to execute the DNS query packet uploaded by the network card in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card.
[0023] According to a method for accelerating domain name server resolution provided by the present invention, the hook node includes: a TCP hook node and a UDP hook node;
[0024] The TCP hook node is mounted between the socket layer and the protocol stack layer of the kernel space, and is used to filter out the DNS query packets of the TCP type that have been processed by the protocol stack layer, obtain corresponding response data from the response database according to the DNS query packets of the TCP type, and send the corresponding response data to the protocol stack layer for processing, and return the response data to the network card after being processed by the protocol stack layer;
[0025] The UDP hook node is mounted before the protocol stack layer of the kernel space, and is used to receive UDP data packets uploaded by the network card, filter out UDP type DNS query packets, obtain corresponding response data from the response database according to the UDP type DNS query packets, and modify the UDP packet header based on the corresponding response data before sending it to the network card.
[0026] The present invention also provides a domain name server resolution acceleration device, comprising:
[0027] A domain name information loading module, used to obtain a query keyword of a hot domain name, and load the query keyword and its corresponding response data from the DNS resolver in the user space to the response database in the kernel space, wherein the hot domain name is a domain name with a query volume exceeding a certain threshold;
[0028] The response acceleration return module is used to detect the DNS query packet uploaded by the network card in the kernel space, obtain the corresponding response data from the response database through the query keyword in the DNS query packet, and return the obtained response data to the network card.
[0029] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a domain name server resolution acceleration method as described in any one of the above is implemented.
[0030] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the domain name server resolution acceleration method as described in any one of the above is implemented.
[0031] The domain name server resolution acceleration method and device provided by the present invention loads the query keywords and corresponding response data of the hotspot domain name from the DNS resolver in the user space into the kernel space in advance and stores them in the response database, detects the DNS query packet uploaded by the network card in the kernel space, obtains the corresponding response data from the response database through the query keywords in the DNS query packet, and returns the obtained response data to the network card, that is, the DNS query packet of the hotspot domain name is quickly responded to using the response data pre-stored in the kernel space. The hotspot domain name is a domain name with a query volume exceeding a certain threshold. According to Zipf's law, a large number of queries are concentrated on a few hotspot domain names. Therefore, the overall performance of the resolution server can be improved by quickly responding to the DNS query packets of a small number of hotspot domain names, thereby realizing resolution acceleration. Moreover, the present invention does not rely on a third-party code block library and other hardware, but only adds a corresponding response database for hotspot domain names in the kernel space, so it has better versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 It is a flowchart of the method for accelerating domain name server resolution provided by the present invention;
[0034] Figure 2 It is a resolution network topology diagram in the domain name server resolution acceleration method provided by the present invention;
[0035] Figure 3 It is a structural schematic diagram of the domain name server resolution acceleration device provided by the present invention;
[0036] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] Combination Figure 1 and 2 The domain name server resolution acceleration method provided by the first embodiment of the present invention is described as follows: Figure 1 As shown, the method includes:
[0039] Step S110: Obtain the query keyword of the hotspot domain name, and load the query keyword and its corresponding response data from the DNS resolver in the user space into the response database in the kernel space. Figure 2As shown, in this step, before parsing the DNS query packet, the query keywords and corresponding response data of all hot domain names are obtained from the user space, and the query keywords and corresponding response data of all hot domain names are stored in the response database of the kernel space, so that there is no need to request response data from the DNS resolver in the user space every time a DNS query packet of a hot domain name is received in the kernel space, saving the time consumed by kernel / user mode switching. Among them, the hot domain name is a domain name whose query volume exceeds a certain threshold, for example: the domain name www.sina.com.cn. The query keywords include: query domain name (hotname domain), query type (type) and DNS security extension information (dnssec), for example:<hotname domain="www.sina.com.cn"type="A"dnssec="1" / > . The above thresholds are configured according to the server situation. For example, you may only need to accelerate the TOP 10,000 domain names. Then, through log analysis, you can find out the lowest query volume of the TOP 10,000 domain names and set this lowest query volume as the threshold. It should be noted that in theory, all domain names can be considered hot domain names, that is, the threshold is set to 0, and the response data of all domain names are loaded into the response database of the kernel space. In fact, it is impossible to cover all domain names. In addition, the more hot domain names there are, the more storage capacity of the kernel space is consumed. Therefore, it is necessary to select a suitable threshold and set the hot domain names in an appropriate range.
[0040] Step S120, detect the DNS query packet uploaded by the network card in the kernel space, obtain the corresponding response data from the response database through the query keyword in the DNS query packet, and return the obtained response data to the network card. In this step, for the DNS query packet detected by the kernel space, the query keyword can be obtained from the DNS query packet. If the DNS query packet is a DNS query packet for a hot domain name, the obtained query keyword will search for the corresponding response data in the response database. It can be seen that for the DNS query packet of the hot domain name, a quick response can be made in the kernel space without switching to the user space, thereby achieving accelerated resolution.
[0041] The domain name server resolution acceleration method provided in this embodiment uses the response data pre-stored in the kernel space to quickly respond to the DNS query packets of hot domain names through the above steps. According to Zipf's law, a large number of queries are concentrated on a small number of hot domain names. Therefore, the overall performance of the resolution server can be improved by quickly responding to the DNS query packets of a small number of hot domain names, thereby achieving resolution acceleration. Moreover, the present invention only adds a corresponding response database for hot domain names in the kernel space, and does not rely on a third-party code block library and other hardware, so it has better versatility.
[0042] In this embodiment, step S110 is performed in the user space and includes:
[0043] Read the preset hotspot domain name configuration table to obtain the query keyword of the hotspot domain name. The hotspot domain name configuration table contains the configuration information of each hotspot domain name, for example:<hotname domain="www.sina.com.cn"type="AAAA"dnssec="0" / > , the hotspot domain name configuration table can be pre-configured by the administrator.
[0044] The DNS query protocol is used to obtain response data corresponding to the query keyword of the hotspot domain name from the user space DNS resolver.
[0045] The response data is encoded, and the query keyword of the hot domain name and the corresponding encoded response data are loaded into the response database for storage. The purpose of encoding is to make the query keyword and the response data conform to the storage format of the kernel database.
[0046] In this embodiment, step S120 includes:
[0047] The data packets uploaded by the network card are detected in the kernel space, and the DNS query packets are filtered out from the data packets. Since the resolution performance of the DNS server is mainly limited by the system consumption (protocol stack processing, kernel / user mode switching, etc.) in the process of sending the query request to the application layer and the processing consumption of the application layer itself, therefore, in this embodiment, the DNS query packets need to be filtered out after the data packets uploaded by the network card are detected in the kernel space.
[0048] Match the query keyword in the DNS query packet with the keyword stored in the response database. Specifically, traverse the keywords stored in the response database and compare the currently traversed keyword with the query keyword in the DNS query packet. If the comparison is consistent, the filtered DNS query packet is the DNS query packet of the hotspot domain name.
[0049] In the case of a successful match, it means that the DNS query packet is a DNS query packet for a hotspot domain name, then the response data corresponding to the query keyword is obtained, and a response data packet is generated based on the response data and returned to the network card. Furthermore, before generating the response data packet, it also includes: encoding the response data according to the query flags in the DNS query packet other than the query keyword to obtain more accurate response data. For example: depending on whether the DNS query contains the edns0 field, the response data is added, deleted, or modified accordingly.
[0050] In the case of a match failure, it indicates that the DNS query packet is a DNS query packet of a non-hotspot domain name, and the DNS query packet is sent to a DNS resolver in the user space, which performs a query response.
[0051] In this embodiment, step S120 is performed by mounting a hook node in the kernel space. Specifically, after the network card uploads a data packet to the kernel space, it will be intercepted by the hook node. After interception, the DNS query packet is filtered out from the data packet, and then the query keyword in the DNS query packet is matched with the keyword stored in the response database. If the match is successful, the response data corresponding to the query keyword is obtained, and the response data packet is generated and returned to the network card. Setting a hook node in the kernel space facilitates the cooperation with the response database to quickly respond to the DNS query packet of the hot domain name in the kernel space.
[0052] For non-DNS query packets and other data packets, they are sent to the user space after passing through the protocol stack layer and socket layer of the kernel space. That is, the hook node processes the DNS query packets of non-hotspot domain names according to the query response method of the prior art. Therefore, the method of this embodiment has the advantage of zero intrusion and is applicable to various DNS resolvers.
[0053] like Figure 2 As shown, the hook node includes: a TCP hook node and a UDP hook node. The TCP hook node is mounted between the socket layer and the protocol stack layer of the kernel space, and is used to filter out the DNS query packets of the TCP type processed by the protocol stack layer, obtain the corresponding response data from the response database according to the DNS query packets of the TCP type, and send the corresponding response data to the protocol stack layer for processing, and then return the response data to the network card after being processed by the protocol stack layer.
[0054] The UDP hook node is mounted before the protocol stack layer of the kernel space, and is used to receive UDP data packets uploaded by the network card, filter out UDP type DNS query packets, obtain corresponding response data from the response database according to the UDP type DNS query packets, and modify the UDP packet header based on the corresponding response data before sending it to the network card
[0055] Specifically, the TC hook node and the sk_skb hook node can be mounted in the kernel space by loading the eBPF program. The TC hook node is located before the protocol stack layer and is used for UDP resolution acceleration, that is, for a DNS query packet based on UDP, the specific steps of step S120 are executed. At this time, the DNS query packet has not been processed by the protocol stack layer, and the TC hook node is required to complete the UDP packet assembly. The sk_skb hook node is located after the protocol stack layer and is used for TCP resolution acceleration, that is, for a DNS query packet based on TCP, the specific steps of step S120 are executed. The TCP query can be processed by the Linux protocol stack layer, and the sk_skb hook node only processes DNS-related data. It can be seen that the method of this embodiment has no dependence on a third-party library or hardware environment, has the versatility of the network protocol stack layer, and is applicable to UDP and TCP queries.
[0056] Combination Figure 2 This embodiment is tested in Linux environment with kernel version 5.11. BIND is selected as open source software (i.e. DNS resolver) for resolution acceleration, and a DNS resolution acceleration method based on eBPF is implemented. The specific steps are as follows:
[0057] (1) Start the BIND program and listen to port 53.
[0058] (2) Read and configure the hotspot domain name. The configuration is as follows:
[0059] <hotname domain="www.sina.com.cn"type="A"dnssec="1" / >
[0060] <hotname domain="www.sina.com.cn"type="AAAA"dnssec="0" / >
[0061] <hotname domain="music.sina.com.cn"type="A"dnssec="1" / >
[0062] <hotname domain="baidu.com"type="NS"dnssec="0" / >
[0063] (3) The domain name information loading module obtains relevant response data from BIND in turn according to the hotspot domain name configuration.
[0064] (4) The response data is encoded and stored in the response database in the kernel space.
[0065] (5) Start the eBPF program and mount the hook nodes (tc and sk_skb).
[0066] (6) Construct test traffic (udp / tcp).
[0067] (7) After the traffic enters the network card, it is processed separately in tc / sk_skb, filtering the DNS query packet and matching the hot domain name according to the query keyword.
[0068] (8) Non-hotspot domain name queries are sent to the application layer, where BIND responds to the query.
[0069] (9) The hot domain name query is re-encoded according to the response data of the response database query in the kernel space, and a response packet is constructed and sent back to the network card to complete the query response. For example, according to whether the DNS query contains the edns0 field, the response data is added, deleted, or modified accordingly.
[0070] After testing, the method of this embodiment can improve the resolution performance to a maximum of tens of millions. The higher the proportion of hot domain name queries, the more significant the performance improvement. In theory, when all domain names are considered to be hot domain names, the performance improvement is the highest.
[0071] The domain name server resolution acceleration device provided by the present invention is described below. The domain name server resolution acceleration device described below and the domain name server resolution acceleration method described above can be referenced to each other.
[0072] The second embodiment of the present invention provides a domain name server resolution acceleration device, such as Figure 3 As shown, including:
[0073] The domain name information loading module 310 is used to obtain the query keyword of the hot domain name, and load the query keyword and its corresponding response data from the DNS resolver in the user space to the response database in the kernel space, wherein the hot domain name is a domain name whose query volume exceeds a certain threshold.
[0074] The response acceleration return module 320 is used to detect the DNS query packet uploaded by the network card in the kernel space, obtain the corresponding response data from the response database through the query keyword in the DNS query packet, and return the obtained response data to the network card.
[0075] The domain name server resolution acceleration device provided in this embodiment uses the above module to quickly respond to the DNS query packets of hot domain names using the response data pre-stored in the kernel space. According to Zipf's law, a large number of queries are concentrated on a small number of hot domain names. Therefore, quickly responding to the DNS query packets of a small number of hot domain names can improve the overall performance of the resolution server, thereby achieving resolution acceleration. Moreover, the present invention does not rely on third-party code block libraries and other hardware, but only adds a corresponding response database for hot domain names in the kernel space, so it has better versatility.
[0076] Optionally, the domain name information loading module 310 includes:
[0077] The configuration table reading module is used to read the preset hotspot domain name configuration table to obtain the query keyword of the hotspot domain name.
[0078] The response data query module is used to obtain the response data corresponding to the query keyword of the hotspot domain name from the user space DNS resolver using the DNS query protocol.
[0079] The loading module is used to encode the response data and load the query keyword of the hotspot domain name and the corresponding encoded response data into the response database for storage.
[0080] Optionally, the response acceleration return module 320 includes:
[0081] The DNS query packet screening module is used to detect the data packets uploaded by the network card in the kernel space and screen out the DNS query packets from the data packets.
[0082] The keyword matching module is used to match the query keyword in the DNS query packet with the keyword stored in the response database.
[0083] The return module is used to obtain the response data corresponding to the query keyword when the match is successful, and generate a response data packet based on the response data and return it to the network card.
[0084] Optionally, the returning module is further used to encode the response data according to the query flag other than the query keyword in the DNS query packet before generating the response data packet.
[0085] Optionally, the response acceleration returning module 320 further includes:
[0086] The sending module is used to send the DNS query packet to the DNS resolver in the user space when the match fails, and the DNS resolver responds to the query.
[0087] Optionally, the response acceleration return module 320 is implemented by mounting a hook node in the kernel space.
[0088] Optionally, the hook node includes: a TCP hook node and a UDP hook node.
[0089] The TCP hook node is mounted between the socket layer and the protocol stack layer of the kernel space, and is used to filter out the TCP type DNS query packets processed by the protocol stack layer, obtain corresponding response data from the response database according to the TCP type DNS query packets, and send the corresponding response data to the protocol stack layer for processing, which is returned to the network card after being processed by the protocol stack layer.
[0090] The UDP hook node is mounted before the protocol stack layer of the kernel space, and is used to receive UDP data packets uploaded by the network card, filter out UDP type DNS query packets, obtain corresponding response data from the response database according to the UDP type DNS query packets, and modify the UDP packet header based on the corresponding response data before sending it to the network card.
[0091] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the domain name server resolution acceleration method, which includes:
[0092] Obtain query keywords of hot domain names, and load the query keywords and their corresponding response data from the DNS resolver in the user space into the response database in the kernel space, wherein the hot domain names are domain names whose query volume exceeds a certain threshold.
[0093] The DNS query packet uploaded by the network card is detected in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card.
[0094] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0095] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the domain name server resolution acceleration method provided by the above methods, the method includes:
[0096] Obtain query keywords of hot domain names, and load the query keywords and their corresponding response data from the DNS resolver in the user space into the response database in the kernel space, wherein the hot domain names are domain names whose query volume exceeds a certain threshold.
[0097] The DNS query packet uploaded by the network card is detected in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card.
[0098] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the domain name server resolution acceleration method provided by the above methods, the method comprising:
[0099] Obtain query keywords of hot domain names, and load the query keywords and their corresponding response data from the DNS resolver in the user space into the response database in the kernel space, wherein the hot domain names are domain names whose query volume exceeds a certain threshold.
[0100] The DNS query packet uploaded by the network card is detected in the kernel space, corresponding response data is obtained from the response database through the query keyword in the DNS query packet, and the obtained response data is returned to the network card.
[0101] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0102] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0103] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for accelerating domain name server resolution, characterized in that: include: Obtain a query keyword of a hot domain name, and load the query keyword and its corresponding response data from the DNS resolver in the user space into a response database in the kernel space, wherein the hot domain name is a domain name with a query volume exceeding a certain threshold; Detecting the DNS query packet uploaded by the network card in the kernel space, acquiring corresponding response data from the response database through the query keyword in the DNS query packet, and returning the acquired response data to the network card; The detecting the DNS query packet uploaded by the network card in the kernel space, acquiring corresponding response data from the response database through the query keyword in the DNS query packet, and returning the acquired response data to the network card includes: Detecting the data packets uploaded by the network card in the kernel space, and filtering out the DNS query packet from the data packets; Matching the query keyword in the DNS query packet with the keyword stored in the response database; In case of successful matching, the response data corresponding to the query keyword is obtained, and a response data packet is generated according to the response data and returned to the network card.
2. The method for accelerating domain name server resolution according to claim 1, characterized in that: Obtaining a query keyword of the hotspot domain name, and loading the query keyword and its corresponding response data from the DNS resolver in the user space into the response database in the kernel space, including: Read the preset hotspot domain name configuration table to obtain the query keyword of the hotspot domain name; Obtaining response data corresponding to the query keyword of the hotspot domain name from the user space DNS resolver using the DNS query protocol; The response data is encoded, and the query keyword of the hotspot domain name and the corresponding encoded response data are loaded into the response database for storage.
3. The method for accelerating domain name server resolution according to claim 1, characterized in that: In the case of a successful match, the step of obtaining the response data corresponding to the query keyword, and generating a response data packet according to the response data and returning it to the network card, before generating the response data packet, further includes: The response data is encoded according to the query flags other than the query keyword in the DNS query packet.
4. The method for accelerating domain name server resolution according to claim 1, characterized in that: The method further comprises: detecting the DNS query packet uploaded by the network card in the kernel space, acquiring corresponding response data from the response database through the query keyword in the DNS query packet, and returning the acquired response data to the network card; In the event of a match failure, the DNS query packet is sent to a DNS resolver in user space, and the DNS resolver responds to the query.
5. The method for accelerating domain name server resolution according to any one of claims 1 to 4, characterized in that: The hook node is mounted in the kernel space to execute the step of detecting the DNS query packet uploaded by the network card in the kernel space, obtaining corresponding response data from the response database through the query keyword in the DNS query packet, and returning the obtained response data to the network card.
6. The method for accelerating domain name server resolution according to claim 5, characterized in that: The hook nodes include: TCP hook nodes and UDP hook nodes; The TCP hook node is mounted between the socket layer and the protocol stack layer of the kernel space, and is used to filter out the DNS query packets of the TCP type that have been processed by the protocol stack layer, obtain corresponding response data from the response database according to the DNS query packets of the TCP type, and send the corresponding response data to the protocol stack layer for processing, and return the response data to the network card after being processed by the protocol stack layer; The UDP hook node is mounted before the protocol stack layer of the kernel space, and is used to receive UDP data packets uploaded by the network card, filter out UDP type DNS query packets, obtain corresponding response data from the response database according to the UDP type DNS query packets, and modify the UDP packet header based on the corresponding response data before sending it to the network card.
7. A domain name server resolution acceleration device, characterized in that: include: A domain name information loading module, used to obtain a query keyword of a hot domain name, and load the query keyword and its corresponding response data from the DNS resolver in the user space to the response database in the kernel space, wherein the hot domain name is a domain name with a query volume exceeding a certain threshold; The response acceleration return module is used to detect the DNS query packet uploaded by the network card in the kernel space, obtain the corresponding response data from the response database through the query keyword in the DNS query packet, and return the obtained response data to the network card; The response acceleration return module includes: A DNS query packet screening module is used to detect the data packets uploaded by the network card in the kernel space and screen out the DNS query packets from the data packets; A keyword matching module, used to match the query keyword in the DNS query packet with the keyword stored in the response database; The return module is used to obtain the response data corresponding to the query keyword when the match is successful, and generate a response data packet based on the response data and return it to the network card.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the domain name server resolution acceleration method as described in any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the domain name server resolution acceleration method as described in any one of claims 1 to 6 is implemented.
