A method for processing domain name system data, electronic device and storage medium

By mounting the kernel driver on the target network communication layer, intercepting and processing DNS requests in the kernel state, it solves the problem of switching between user state and kernel state affecting DNS request efficiency, and achieves more efficient DNS query performance.

CN118400352BActive Publication Date: 2024-09-03JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410832825.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-09-03
Estimated Expiration
2044-06-26

AI Technical Summary

Technical Problem

In the existing technology, switching between user mode and kernel mode results in low efficiency of DNS requests and the inability to quickly query the local DNS cache, which affects the client's DNS request performance.

Method used

By mounting the kernel driver on the target network communication layer, it intercepts the client's DNS request, completes the DNS cache query in the kernel state, and returns response data to avoid switching between the user state and the kernel state during system calls.

Benefits of technology

It improves the client's DNS request efficiency, reduces the switching overhead in system calls, and improves the performance of DNS queries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118400352B
    Figure CN118400352B
Patent Text Reader

Abstract

The present invention relates to the field of computer technology, and discloses a domain name system data processing method, electronic device and storage medium, the method comprising: intercepting a domain name system request initiated by a client at the target network communication layer based on a kernel driver mounted at the target network communication layer; accessing a domain name system request record stored in a kernel state data cache structure based on the kernel driver according to the domain name system request; determining request response data of the domain name system request according to the domain name system request record; and returning the request response data to the client to respond to the domain name system request. The method provided by the above scheme improves the DNS request efficiency of the client by mounting the kernel driver at the target network communication layer, completing the query of the DNS cache in the kernel state based on the kernel driver and returning it before entering the system call.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a domain name system data processing method, electronic device and storage medium. Background Art

[0002] The Domain Name System (DNS) is an Internet service that serves as a distributed database that maps domain names and IP addresses to each other.

[0003] In the related art, when initiating a DNS request, the client first queries the local DNS cache to see whether there is a DNS request record. If so, the corresponding IP address can be determined and accessed based on the record.

[0004] However, the client needs to query the local DNS cache through system calls, and the performance is limited by the switching between user mode and kernel mode, which is time-consuming and cannot guarantee the efficiency of the client's DNS request. Summary of the invention

[0005] The present application provides a domain name system data processing method, an electronic device and a storage medium to solve the defects of the related technology that the switching between user mode and kernel mode cannot guarantee the efficiency of the DNS request of the client.

[0006] The first aspect of the present application provides a method for processing domain name system data, comprising:

[0007] Based on the kernel driver mounted on the target network communication layer, the domain name system request initiated by the client is intercepted at the target network communication layer;

[0008] Based on the kernel driver, accessing the domain name system request record stored in the kernel state data cache structure according to the domain name system request;

[0009] Determining request response data of the domain name system request according to the domain name system request record;

[0010] The request response data is returned to the client in response to the domain name system request.

[0011] In an optional implementation, intercepting the domain name system request initiated by the client at the target network communication layer based on the kernel driver mounted at the target network communication layer includes:

[0012] Based on the kernel driver mounted on the target network communication layer, all service requests initiated by the client are intercepted at the target network communication layer;

[0013] Domain name system requests are screened in the service requests according to the destination port of each service request.

[0014] In an optional embodiment, the method further includes:

[0015] Obtaining mount point information of the kernel driver;

[0016] Filtering a target network communication layer from multiple network communication layers according to the mount point information of the kernel driver;

[0017] The kernel driver is mounted to the target network communication layer.

[0018] In an optional implementation, screening a target network communication layer from multiple network communication layers according to the mount point information of the kernel driver includes:

[0019] Obtaining a mount constraint condition according to the mount point information representation of the kernel driver, and screening a number of allowable mount layers that meet the mount constraint condition from multiple network communication layers;

[0020] A target network communication layer is screened from a plurality of the allowed mounting layers according to the request path length of each of the allowed mounting layers.

[0021] In an optional implementation, the accessing the domain name system request record stored in the kernel state data cache structure based on the kernel driver according to the domain name system request includes:

[0022] Based on the kernel driver, the domain name system request is parsed to obtain a request parsing result;

[0023] Determining a target domain name requested by the domain name system request according to the request parsing result;

[0024] According to the target domain name, a domain name system request record stored in a kernel state data cache structure is accessed to read target record content corresponding to the target domain name in the domain name system request record.

[0025] In an optional implementation, accessing a domain name system request record stored in a kernel-mode data cache structure according to the target domain name to read a target record content corresponding to the target domain name in the domain name system request record includes:

[0026] Using the target domain name as an index value, traversing the domain name system request record in the kernel state data cache structure;

[0027] The record content that matches the index value is used as the target record content corresponding to the target domain name.

[0028] In an optional embodiment, the method further includes:

[0029] When there is no record content matching the index value in the kernel state data cache structure, releasing the domain name system request at the target network communication layer;

[0030] The domain name system request is sent to a domain name system server to obtain domain name response data returned by the domain name system server in response to the domain name system request.

[0031] In an optional implementation manner, determining the request response data of the domain name system request according to the domain name system request record includes:

[0032] Determining whether the target record content has expired according to a timestamp carried by the target record content read from the domain name system request record;

[0033] When it is determined that the target record content is not expired, request response data of the domain name system request is determined according to the target record content.

[0034] In an optional embodiment, the method further includes:

[0035] When it is determined that the target record content has expired, releasing the domain name system request at the target network communication layer;

[0036] The domain name system request is sent to a domain name system server to obtain domain name response data returned by the domain name system server in response to the domain name system request.

[0037] In an optional embodiment, the method further includes:

[0038] Based on the kernel driver mounted on the target network communication layer, intercepting the domain name system server at the target network communication layer in response to the domain name system request to return the domain name answer data;

[0039] Generate a new domain name system request record according to the domain name answer data returned by the domain name system server in response to the domain name system request;

[0040] The newly added domain name system request record is added to the kernel state data cache structure.

[0041] In an optional implementation, the method of intercepting the domain name response data returned by the domain name system server in response to the domain name system request at the target network communication layer based on the kernel driver mounted at the target network communication layer includes:

[0042] Based on the kernel driver mounted on the target network communication layer, all response data returned to the client are intercepted at the target network communication layer;

[0043] The domain name answer data is filtered in the response data according to the source port of each response data.

[0044] In an optional embodiment, the method further includes:

[0045] The expired target record content is treated as content to be cleared;

[0046] The entire record corresponding to the content to be cleared is cleared in the kernel state data cache structure.

[0047] A second aspect of the present application provides a domain name system data processing device, including:

[0048] An interception module, for intercepting a domain name system request initiated by a client at a target network communication layer based on a kernel driver mounted at the target network communication layer;

[0049] An access module, configured to access a domain name system request record stored in a kernel state data cache structure based on the kernel driver and according to the domain name system request;

[0050] A determination module, configured to determine request response data of the domain name system request according to the domain name system request record;

[0051] The response module is used to return the request response data to the client to respond to the domain name system request.

[0052] In an optional implementation, the interception module is specifically used to:

[0053] Based on the kernel driver mounted on the target network communication layer, all service requests initiated by the client are intercepted at the target network communication layer;

[0054] Domain name system requests are screened in the service requests according to the destination port of each service request.

[0055] In an optional embodiment, the device further comprises:

[0056] A configuration module is used to obtain the mount point information of the kernel driver; select a target network communication layer from multiple network communication layers according to the mount point information of the kernel driver; and mount the kernel driver to the target network communication layer.

[0057] In an optional implementation manner, the configuration module is specifically used to:

[0058] Obtaining a mount constraint condition according to the mount point information representation of the kernel driver, and screening a number of allowable mount layers that meet the mount constraint condition from multiple network communication layers;

[0059] A target network communication layer is screened from a plurality of the allowed mounting layers according to the request path length of each of the allowed mounting layers.

[0060] In an optional implementation manner, the access module is specifically used to:

[0061] Based on the kernel driver, the domain name system request is parsed to obtain a request parsing result;

[0062] Determining a target domain name requested by the domain name system request according to the request parsing result;

[0063] According to the target domain name, a domain name system request record stored in a kernel state data cache structure is accessed to read target record content corresponding to the target domain name in the domain name system request record.

[0064] In an optional implementation manner, the access module is specifically used to:

[0065] Using the target domain name as an index value, traversing the domain name system request record in the kernel state data cache structure;

[0066] The record content that matches the index value is used as the target record content corresponding to the target domain name.

[0067] In an optional embodiment, the device further comprises:

[0068] A response module is used to release the domain name system request at the target network communication layer when there is no record content matching the index value in the kernel data cache structure; send the domain name system request to the domain name system server to obtain domain name response data returned by the domain name system server in response to the domain name system request.

[0069] In an optional implementation manner, the determining module is specifically configured to:

[0070] Determining whether the target record content has expired according to a timestamp carried by the target record content read from the domain name system request record;

[0071] When it is determined that the target record content is not expired, request response data of the domain name system request is determined according to the target record content.

[0072] In an optional embodiment, the device further comprises:

[0073] The response module is used to release the domain name system request at the target network communication layer when it is determined that the target record content has expired; send the domain name system request to the domain name system server to obtain domain name response data returned by the domain name system server in response to the domain name system request.

[0074] In an optional implementation manner, the response module is specifically used to:

[0075] Based on the kernel driver mounted on the target network communication layer, intercepting the domain name system server at the target network communication layer in response to the domain name system request to return the domain name answer data;

[0076] Generate a new domain name system request record according to the domain name answer data returned by the domain name system server in response to the domain name system request;

[0077] The newly added domain name system request record is added to the kernel state data cache structure.

[0078] In an optional implementation manner, the response module is specifically used to:

[0079] Based on the kernel driver mounted on the target network communication layer, all response data returned to the client are intercepted at the target network communication layer;

[0080] The domain name answer data is filtered in the response data according to the source port of each response data.

[0081] In an optional embodiment, the device further comprises:

[0082] The clearing module is used to take the expired target record content as the content to be cleared; and clear the entire record corresponding to the content to be cleared in the kernel state data cache structure.

[0083] A third aspect of the present application provides an electronic device, comprising: at least one processor and a memory;

[0084] The memory stores computer-executable instructions;

[0085] The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method described in the first aspect and various possible designs of the first aspect.

[0086] A fourth aspect of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When a processor executes the computer-executable instructions, the method described in the first aspect and various possible designs of the first aspect are implemented.

[0087] A fifth aspect of the present application provides a computer program product, including computer instructions, which are used to enable a computer to execute the method described in the first aspect and various possible designs of the first aspect.

[0088] The technical solution of this application has the following advantages:

[0089] The present application provides a method for processing domain name system data, an electronic device and a storage medium, the method comprising: intercepting a domain name system request initiated by a client at the target network communication layer based on a kernel driver mounted at the target network communication layer; accessing a domain name system request record stored in a kernel state data cache structure based on the kernel driver according to the domain name system request; determining request response data of the domain name system request according to the domain name system request record; returning the request response data to the client to respond to the domain name system request. The method provided by the above scheme improves the DNS request efficiency of the client by mounting the kernel driver at the target network communication layer and completing the query of the DNS cache in the kernel state based on the kernel driver before entering the system call and returning it. BRIEF DESCRIPTION OF THE DRAWINGS

[0090] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technical descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.

[0091] Figure 1 A schematic diagram of the structure of a domain name system data processing system based on an embodiment of the present application;

[0092] Figure 2 A flowchart of a method for processing domain name system data provided by an embodiment of the present application;

[0093] Figure 3 A schematic diagram of the overall process of the domain name system data processing method provided in an embodiment of the present application;

[0094] Figure 4 A schematic diagram of the structure of a domain name system data processing device provided in an embodiment of the present application;

[0095] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0096] The above drawings have shown clear embodiments of the present application, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0097] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0098] In addition, the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the following embodiments, the meaning of "multiple" is more than two, unless otherwise clearly and specifically defined.

[0099] In related technologies, with the development of the Internet and the popularization of applications, DNS, as a key network infrastructure, plays an important role in resolving domain names into IP addresses. When a client initiates access, it does not always turn to the DNS system for help, but first queries whether there are relevant records in the local DNS cache. If there are records, it will directly access the corresponding IP address. If there are no records, it will entrust the recursive server to perform upstream queries. When the request is made to the authoritative resolution server, an authoritative resolution record will be returned. This record will be temporarily stored in the system for direct use the next time it is accessed. The temporary record stored by the system is the DNS cache. In traditional implementations, querying the local DNS cache is generally implemented through system calls. The performance is limited by the switching between user mode and kernel mode and the overhead of data copying, which is usually time-consuming.

[0100] In view of the above problems, the embodiments of the present application provide a method for processing domain name system data, an electronic device and a storage medium, the method comprising: intercepting a domain name system request initiated by a client at the target network communication layer based on a kernel driver mounted at the target network communication layer; accessing a domain name system request record stored in a kernel state data cache structure based on the kernel driver according to the domain name system request; determining request response data of the domain name system request based on the domain name system request record; returning the request response data to the client to respond to the domain name system request. The method provided by the above scheme improves the DNS request efficiency of the client by mounting the kernel driver at the target network communication layer and completing the query of the DNS cache in the kernel state based on the kernel driver before entering the system call and returning it.

[0101] The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. The embodiments of the present invention will be described below in conjunction with the accompanying drawings.

[0102] First, the structure of the domain name system data processing system on which this application is based is described:

[0103] The domain name system data processing method, electronic device and storage medium provided in the embodiments of the present application are suitable for quickly accessing the DNS cache in the kernel state when the client initiates a DNS request. Figure 1 As shown, it is a schematic diagram of the structure of the domain name system data processing system based on the embodiment of the present application, which mainly includes a client, a DNS cache and a domain name system data processing device. The domain name system data processing device is used to intercept the domain name system request from the client to the DNS cache, and access the DNS cache instead of the client itself based on the kernel driver to improve the access efficiency of the DNS cache.

[0104] The embodiment of the present application provides a method for processing domain name system data, which is used to quickly access the DNS cache in kernel state when a client initiates a DNS request. The execution subject of the embodiment of the present application is an electronic device, such as a server, a desktop computer, a laptop computer, a tablet computer, and other electronic devices that can be used for processing domain name system data.

[0105] like Figure 2 FIG. 1 is a flow chart of a method for processing domain name system data provided by an embodiment of the present application, the method comprising:

[0106] Step 201, based on the kernel driver mounted on the target network communication layer, intercept the domain name system request initiated by the client at the target network communication layer.

[0107] It should be noted that the kernel driver can specifically be an eBPF program. The eBPF program is a program written by the user that can run in the Linux kernel. It is essentially a virtual machine running in kernel state, which allows users to load and run custom programs in the kernel. In addition, the user and the kernel can exchange data on demand and manage the kernel's behavior at any time.

[0108] Step 202: Based on the kernel driver and according to the domain name system request, access the domain name system request record stored in the kernel state data structure.

[0109] Specifically, based on a kernel driver running in kernel mode, in response to a domain name system request, a domain name system request record stored in a kernel mode data structure may be accessed.

[0110] The domain name system request record is the DNS cache, and the kernel state data structure can be determined according to the type of the kernel driver. When the kernel driver is an eBPF program, the kernel state data structure is an eBPF Map, that is, the kernel state data structure is a special data structure that the eBPF program can quickly access.

[0111] Step 203: Determine the request response data of the domain name system request according to the domain name system request record.

[0112] Specifically, the IP address requested by the domain name system request can be determined by accessing the domain name system request record, and then the IP address is used as the request response data.

[0113] Step 204, returning the request response data to the client in response to the domain name system request.

[0114] Specifically, after obtaining the request response data by accessing the domain name system request record in the kernel state, the request response data can be returned to the client through the target network communication layer to respond to the domain name system request.

[0115] On the basis of the above embodiments, in order to ensure that the domain name system request initiated by the client can be accurately intercepted, as an implementable method, in one embodiment, based on the kernel driver mounted on the target network communication layer, the domain name system request initiated by the client is intercepted at the target network communication layer, including:

[0116] Step 211, based on the kernel driver mounted on the target network communication layer, intercept all service requests initiated by the client at the target network communication layer;

[0117] Step 2012: Filter the domain name system requests in the service requests according to the destination port of each service request.

[0118] It should be noted that the domain name system request initiated by the client is a domain name system request to be sent to the DNS server.

[0119] Specifically, for all service requests intercepted by the kernel driver, when the destination port of any service request is a DNS server port, for example, the destination port of the service request is 53, the service request is determined to be a domain name system request.

[0120] On the basis of the above embodiment, since the mounting location of the kernel driver will affect the length of the domain name system request transmission path, in order to further improve the DNS request efficiency of the client, as an implementable method, in one embodiment, the method further includes:

[0121] Step 301, obtaining the mount point information of the kernel driver;

[0122] Step 302, screening a target network communication layer from a plurality of network communication layers according to the mount point information of the kernel driver;

[0123] Step 303, mounting the kernel driver to the target network communication layer.

[0124] Specifically, the kernel driver can be mounted on which network communication layers according to the mount point information of the kernel driver, and then the target network communication layer is selected according to the length of the request transmission path corresponding to each network communication layer.

[0125] Specifically, in one embodiment, the mount constraint condition can be obtained according to the mount point information representation of the kernel driver, and several allowed mount layers that meet the mount constraint condition are screened from multiple network communication layers; and the target network communication layer is screened from several allowed mount layers according to the request path length of each allowed mount layer.

[0126] Exemplarily, when the kernel driver is an eBPF program, its mounting constraint depends on the permission setting of the network communication. When the allowed mounting layers that meet the mounting constraint are the socket layer, the network layer, and the data link layer, respectively, the socket layer is the interface layer between the application layer and the transport layer. The request path of the socket layer is the shortest. Therefore, the socket layer can be used as the target network communication layer to shorten the transmission path of the domain name system request before being intercepted, thereby improving the DNS request efficiency of the client.

[0127] Based on the above embodiment, as an implementable manner, in one embodiment, based on the kernel driver, according to the domain name system request, accessing the domain name system request record stored in the kernel state data structure includes:

[0128] Step 221, based on the kernel driver, parse the domain name system request to obtain the request parsing result;

[0129] Step 2022, determining the target domain name requested by the domain name system request according to the request resolution result;

[0130] Step 2023: According to the target domain name, the domain name system request record stored in the kernel state data structure is accessed to read the target record content corresponding to the target domain name in the domain name system request record.

[0131] Specifically, based on the kernel driver, the DNS request data can be parsed to obtain the request parsing result, and then the target domain name requested by the DNS request can be determined according to the request parsing result, wherein the request parsing result at least includes the target domain name, protocol information and timestamp.

[0132] Specifically, in one embodiment, the target domain name may be used as an index value to traverse the domain name system request record in the kernel state data structure; and the record content matching the index value is used as the target record content corresponding to the target domain name.

[0133] It should be noted that the kernel state data structure may specifically use a key-value pair to store the domain name system request record.

[0134] Specifically, when accessing a domain name system request record, the target domain name can be used as an index value (key) to traverse the domain name system request record in the kernel state data structure. If the record content matching the index value can be found, it is determined that the domain name system access request hits the DNS cache, and the matching record content is used as the target record content corresponding to the target domain name. The target record content at least includes the IP address corresponding to the target domain name.

[0135] Specifically, in one embodiment, when there is no record content matching the index value in the kernel-mode data structure, the domain name system request is released at the target network communication layer; the domain name system request is sent to the domain name system server to obtain the domain name response data returned by the domain name system server in response to the domain name system request.

[0136] Specifically, when there is no record content matching the index value in the kernel state data structure, it is determined that the request to access the domain name system does not hit the DNS cache. At this time, the domain name system request is released at the target network communication layer to enter the regular DNS request process.

[0137] On the basis of the above embodiments, in order to ensure the reliability of the request response data, as an implementable method, in one embodiment, according to the domain name system request record, determining the request response data of the domain name system request includes:

[0138] Step 2031, judging whether the target record content has expired according to the timestamp carried by the target record content read from the domain name system request record;

[0139] Step 2032: When it is determined that the target record content is not expired, determine the request response data of the domain name system request according to the target record content.

[0140] Specifically, in one embodiment, when it is determined that the target record content has expired, the domain name system request is released at the target network communication layer; the domain name system request is sent to the domain name system server to obtain the domain name response data returned by the domain name system server in response to the domain name system request.

[0141] It should be noted that each record content in the domain name system request record carries a timestamp and validity period. The timestamp represents the time when the record content takes effect. If the time difference between the current time and the timestamp carried by the target record content exceeds its validity period, it is determined that the target record content has expired. Otherwise, it has not expired. If it has not expired, the subsequent request response data packaging process is carried out, that is, the request response data of the domain name system request is determined according to the target record content. If it has expired, the regular DNS request process is entered to request the domain name answer data from the domain name system server.

[0142] Specifically, the access domain name system request record is stored in the kernel data structure in the form of a key-value pair. The index value key is the requested domain name host, and the data item value is the record content, that is, the value is a string composed of the IP address corresponding to the domain name and the timestamp of the generated record. An example is: "www.example.com": "192.168.22.44-1716188565". "www.example.com" is the domain name, and the IP address (192.168.22.44) and the timestamp (1716188565) are separated by "-".

[0143] Specifically, in one embodiment, in order to release the storage space of the kernel state data structure in time, the expired target record content may be used as the content to be cleared; and the entire record corresponding to the content to be cleared is cleared in the kernel state data structure.

[0144] The entire record to be cleared includes the content to be cleared and the index value corresponding to the content to be cleared.

[0145] Furthermore, in one embodiment, in order to further expand the DNS cache so that most domain name system requests can hit the DNS cache and improve the DNS request efficiency of the client, the domain name system server can be intercepted at the target network communication layer in response to the domain name system request and the domain name reply data can be returned; based on the domain name system server responding to the domain name system request and the domain name reply data, a new domain name system request record is generated; and the new domain name system request record is added to the kernel state data structure.

[0146] Specifically, when the domain name response data returned by the domain name system server is sent to the client, a new domain name system request record is generated according to the domain name response data; and the new domain name system request record is added to the kernel state data structure. The new domain name system request record includes the new record content and its corresponding index value, that is, the corresponding relationship between the domain name and the IP address in the domain name response data is resolved, and then the corresponding key-value pair is established.

[0147] Among them, the newly added record content may actually include a timestamp and an expiration date. Since the domain name system requests initiated by the client originate from different applications, in order to make the validity period of the records in the DNS cache adapt to the actual application environment and improve the utilization rate of the DNS cache, after obtaining the domain name response data returned by the domain name system server, the validity period in the newly added domain name system request record corresponding to the domain name response data is determined based on the stability index of the requested domain name and / or the real-time requirement index of the DNS for the application that actually initiated the request.

[0148] It should be noted that for the stability index of the domain name, a larger stability index can be set when the IP address corresponding to the domain name does not change frequently. The larger the stability index, the longer the corresponding validity period, so as to reduce the number of DNS queries. For the real-time requirement index of the application for DNS, some applications may have higher real-time requirements for DNS resolution and need to update the DNS cache more frequently. In this case, a larger real-time requirement index can be set for it, and then a shorter validity period can be set.

[0149] Specifically, in actual applications, in order to facilitate the management of the DNS cache, the same validity period, such as 30 seconds, may be set for each record in the kernel state data structure.

[0150] Specifically, in one embodiment, all response data returned to the client can be intercepted at the target network communication layer based on a kernel driver mounted at the target network communication layer; domain name response data can be filtered in the response data according to the source port of each response data.

[0151] Specifically, after all response data returned to the client are intercepted, if the source port of any response data is a DNS server port, for example, the source port of the response data is 53, the response data is determined to be domain name response data.

[0152] For example, when the source port of the intercepted data packet (reply) is 53, the determiner is a DNS response data packet, and the specific information of the data packet is parsed to obtain the requested domain name and the corresponding IP address. For example, if the domain name is www.test.com and the corresponding IP is 123.123.11.22, the corresponding key-value data is created and inserted into the kernel state data structure to expand and update the DNS cache. If there is a subsequent request related to "www.test.com", the cache can be hit and the response is directly made at the target network communication layer. The content of the current DNS cache after the update is as follows:

[0153] {

[0154] "www.example.com": "192.168.22.44-1716188565",

[0155] "www.test.com": "123.123.11.22-1716190204"

[0156] }

[0157] For example, Figure 3 As shown, it is a schematic diagram of the overall process of the domain name system data processing method provided in the embodiment of the present application, such as Figure 3 The method shown is as follows Figure 2 An exemplary implementation of the method shown is shown, and the implementation principles of the two are the same and will not be repeated here.

[0158] The domain name system data processing method provided in the embodiment of the present application intercepts the domain name system request initiated by the client at the target network communication layer based on the kernel driver mounted on the target network communication layer; based on the kernel driver, accesses the domain name system request record stored in the kernel state data cache structure according to the domain name system request; determines the request response data of the domain name system request according to the domain name system request record; returns the request response data to the client to respond to the domain name system request. The method provided by the above scheme improves the DNS request efficiency of the client by mounting the kernel driver at the target network communication layer, completing the query of the DNS cache in the kernel state based on the kernel driver before entering the system call and returning it. Moreover, compared with the traditional method, the method provided in the embodiment of the present application is implemented in the kernel state, which is lightweight, high in performance, high in security, and implemented in pure software, without special hardware requirements, saving costs, and high in flexibility, and supporting dynamic loading and unloading.

[0159] The embodiment of the present application provides a domain name system data processing device, which is used to execute the domain name system data processing method provided by the above embodiment.

[0160] like Figure 4 FIG. 4 is a schematic diagram of the structure of a domain name system data processing device provided in an embodiment of the present application. The domain name system data processing device 40 comprises: an interception module 401 , an access module 402 , a determination module 403 and a response module 404 .

[0161] Among them, the interception module is used to intercept the domain name system request initiated by the client at the target network communication layer based on the kernel driver mounted on the target network communication layer; the access module is used to access the domain name system request record stored in the kernel state data cache structure according to the domain name system request based on the kernel driver; the determination module is used to determine the request response data of the domain name system request according to the domain name system request record; the response module is used to return the request response data to the client in response to the domain name system request.

[0162] Specifically, in one embodiment, the interception module is specifically used to:

[0163] Based on the kernel driver mounted on the target network communication layer, all service requests initiated by the client are intercepted at the target network communication layer;

[0164] Filter domain name system requests in service requests based on the destination port of each service request.

[0165] Specifically, in one embodiment, the device further includes:

[0166] The configuration module is used to obtain the mount point information of the kernel driver; select the target network communication layer from multiple network communication layers according to the mount point information of the kernel driver; and mount the kernel driver to the target network communication layer.

[0167] Specifically, in one embodiment, the configuration module is specifically used to:

[0168] Obtaining a mount constraint condition according to the mount point information representation of the kernel driver, and screening a number of allowable mount layers that meet the mount constraint condition in multiple network communication layers;

[0169] A target network communication layer is screened from a number of allowed mounting layers according to the request path length of each allowed mounting layer.

[0170] Specifically, in one embodiment, the access module is specifically used to:

[0171] Based on the kernel driver, parse the domain name system request and obtain the request resolution result;

[0172] Determine the target domain name requested by the domain name system request according to the request resolution result;

[0173] According to the target domain name, the domain name system request record stored in the kernel state data cache structure is accessed to read the target record content corresponding to the target domain name in the domain name system request record.

[0174] Specifically, in one embodiment, the access module is specifically used to:

[0175] Using the target domain name as an index value, traverse the domain name system request records in the kernel state data cache structure;

[0176] The record content that matches the index value is used as the target record content corresponding to the target domain name.

[0177] Specifically, in one embodiment, the device further includes:

[0178] The response module is used to release the domain name system request at the target network communication layer when there is no record content matching the index value in the kernel data cache structure; send the domain name system request to the domain name system server to obtain the domain name response data returned by the domain name system server in response to the domain name system request.

[0179] Specifically, in one embodiment, the determination module is specifically used to:

[0180] Determine whether the target record content has expired according to the timestamp carried in the target record content read from the domain name system request record;

[0181] When it is determined that the target record content is not expired, request response data of the domain name system request is determined according to the target record content.

[0182] Specifically, in one embodiment, the device further includes:

[0183] The response module is used to release the domain name system request at the target network communication layer when it is determined that the target record content has expired; send the domain name system request to the domain name system server to obtain the domain name response data returned by the domain name system server in response to the domain name system request.

[0184] Specifically, in one embodiment, the response module is specifically used to:

[0185] Based on the kernel driver mounted on the target network communication layer, intercepting the domain name system server in the target network communication layer in response to the domain name system request to return the domain name answer data;

[0186] Generate a new domain name system request record according to the domain name answer data returned by the domain name system server in response to the domain name system request;

[0187] Add new domain name system request records to the kernel data cache structure.

[0188] Specifically, in one embodiment, the response module is specifically used to:

[0189] Based on the kernel driver mounted on the target network communication layer, all response data returned to the client are intercepted at the target network communication layer;

[0190] According to the source port of each response data, the domain name answer data is filtered in the response data.

[0191] Specifically, in one embodiment, the device further includes:

[0192] The clearing module is used to take the expired target record content as the content to be cleared; and clear the entire record corresponding to the content to be cleared in the kernel state data cache structure.

[0193] Regarding the domain name system data processing device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0194] The domain name system data processing device provided in the embodiment of the present application is used to execute the domain name system data processing method provided in the above embodiment. Its implementation method and principle are the same and will not be repeated here.

[0195] An embodiment of the present application provides an electronic device for executing the domain name system data processing method provided in the above embodiment.

[0196] like Figure 5 FIG. 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 50 includes: at least one processor 51 and a memory 52.

[0197] The memory stores computer-executable instructions; at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the domain name system data processing method provided in the above embodiment.

[0198] The electronic device provided in the embodiment of the present application is used to execute the domain name system data processing method provided in the above embodiment. Its implementation method and principle are the same and will not be repeated here.

[0199] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, a domain name system data processing method provided in any of the above embodiments is implemented.

[0200] The storage medium containing computer executable instructions provided in the embodiments of the present application can be used to store computer executable instructions of the domain name system data processing method provided in the aforementioned embodiments. The implementation method and principle are the same and will not be repeated here.

[0201] An embodiment of the present application provides a computer program product, including computer instructions, which are used to enable a computer to execute the domain name system data processing method provided in the above-mentioned embodiment.

[0202] The embodiments of the present application provide a computer program product that can be used to execute computer instructions of the domain name system data processing method provided in the aforementioned embodiments. The implementation method and principle are the same and will not be repeated here.

[0203] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0204] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0205] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0206] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit 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.) or a processor to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.

[0207] A part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes, but is not limited to, source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0208] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example for illustration. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0209] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application 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 replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for processing domain name system data, characterized in that: include: Based on the kernel driver mounted on the target network communication layer, the domain name system request initiated by the client is intercepted at the target network communication layer; Based on the kernel driver, accessing the domain name system request record stored in the kernel state data cache structure according to the domain name system request; Determining request response data of the domain name system request according to the domain name system request record; Returning the request response data to the client to respond to the domain name system request; The method further comprises: Obtaining mount point information of the kernel driver; Filtering a target network communication layer from multiple network communication layers according to the mount point information of the kernel driver; Mounting the kernel driver to the target network communication layer; The step of screening a target network communication layer from a plurality of network communication layers according to the mount point information of the kernel driver comprises: Obtaining a mount constraint condition according to the mount point information representation of the kernel driver, and screening a number of allowable mount layers that meet the mount constraint condition from multiple network communication layers; A target network communication layer is screened from a plurality of the allowed mounting layers according to the request path length of each of the allowed mounting layers.

2. The method according to claim 1, characterized in that The method of intercepting a domain name system request initiated by a client at the target network communication layer based on a kernel driver mounted at the target network communication layer includes: Based on the kernel driver mounted on the target network communication layer, all service requests initiated by the client are intercepted at the target network communication layer; Domain name system requests are screened in the service requests according to the destination port of each service request.

3. The method according to claim 1, characterized in that The step of accessing the domain name system request record stored in the kernel state data cache structure based on the kernel driver and according to the domain name system request includes: Based on the kernel driver, the domain name system request is parsed to obtain a request parsing result; Determining a target domain name requested by the domain name system request according to the request parsing result; According to the target domain name, a domain name system request record stored in a kernel state data cache structure is accessed to read target record content corresponding to the target domain name in the domain name system request record.

4. The method according to claim 3, characterized in that The step of accessing a domain name system request record stored in a kernel state data cache structure according to the target domain name, so as to read target record content corresponding to the target domain name in the domain name system request record, includes: Using the target domain name as an index value, traversing the domain name system request record in the kernel state data cache structure; The record content that matches the index value is used as the target record content corresponding to the target domain name.

5. The method according to claim 4, characterized in that The method further comprises: When there is no record content matching the index value in the kernel state data cache structure, releasing the domain name system request at the target network communication layer; The domain name system request is sent to a domain name system server to obtain domain name response data returned by the domain name system server in response to the domain name system request.

6. The method according to claim 3, characterized in that: The step of determining the request response data of the domain name system request according to the domain name system request record includes: Determining whether the target record content has expired according to a timestamp carried by the target record content read from the domain name system request record; When it is determined that the target record content is not expired, request response data of the domain name system request is determined according to the target record content.

7. The method according to claim 6, characterized in that The method further comprises: When determining that the target record content has expired, releasing the domain name system request at the target network communication layer; The domain name system request is sent to a domain name system server to obtain domain name response data returned by the domain name system server in response to the domain name system request.

8. The method according to claim 5 or 7, characterized in that: The method further comprises: Based on the kernel driver mounted on the target network communication layer, intercepting the domain name system server at the target network communication layer in response to the domain name system request to return the domain name answer data; Generate a new domain name system request record according to the domain name answer data returned by the domain name system server in response to the domain name system request; The newly added domain name system request record is added to the kernel state data cache structure.

9. The method according to claim 8, characterized in that The method of intercepting the domain name system server returning the domain name answer data in response to the domain name system request at the target network communication layer based on the kernel driver mounted at the target network communication layer includes: Based on the kernel driver mounted on the target network communication layer, all response data returned to the client are intercepted at the target network communication layer; The domain name answer data is filtered in the response data according to the source port of each response data.

10. The method according to claim 7, characterized in that The method further comprises: The expired target record content is treated as content to be cleared; The entire record corresponding to the content to be cleared is cleared in the kernel state data cache structure.

11. An electronic device, characterized in that: include: at least one processor and memory; The memory stores computer-executable instructions; The at least one processor executes the computer-executable instructions stored in the memory, so that the at least one processor performs the method according to any one of claims 1 to 10.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method according to any one of claims 1 to 10 is implemented.

13. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method according to any one of claims 1 to 10.