Home gateway equipment and DNS (Domain Name Server) anti-pollution method thereof

By designing DNS anti-pollution configuration and pre-diversion mechanism on the home gateway device, using the DoH mechanism to resolve specific types of domain names and using regular DNS to query non-specific types or unmatched domain names, the DNS anti-pollution and resolution efficiency in the home network are solved. problem, achieving both security and speed.

CN118555098APending Publication Date: 2024-08-27四川长虹新网科技有限责任公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410602220.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-15
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Devices in home networks have incomplete support for DNS over HTTPS (DoH), making it difficult to ensure DNS anti-pollution while taking into account domain name resolution efficiency.

Method used

Design a home gateway device, including DNS anti-pollution configuration module, DNS request capture module, DoH cache module, DNS request pre-diversion module, DNS query module, domain name matching module, DoH query module and feedback module, to prevent DNS pollution through user configuration The domain name list is pre-divided according to the query type. Domain names of specific types are resolved using the DoH mechanism, and domain names of non-specific types or that have not been successfully matched use regular DNS queries.

Benefits of technology

It achieves the security of the domain name resolution process that needs to be prevented from pollution, while taking into account the speed and efficiency of the overall domain name resolution, and improves the efficiency of repeated resolution through local DoH caching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118555098A
    Figure CN118555098A
Patent Text Reader

Abstract

The invention relates to the field of network security, and discloses home gateway equipment and a DNS (Domain Name Server) anti-pollution method thereof, which are used for realizing anti-pollution in an analysis process for a domain name needing anti-pollution and supporting conventional DNS analysis for a domain name which does not need anti-pollution, so that the overall domain name analysis efficiency is considered while the terminal network communication security is ensured. According to the method, the DNS anti-pollution domain name list is configured in advance according to user requirements, the domain names needing anti-pollution analysis are recorded in the list, all conventional DNS requests are monitored on the gateway during application, the target domain name and the query type are analyzed, and then pre-shunting is performed according to the query type, that is, conventional DNS query is directly performed aiming at DNS requests of non-specific types, so that the DNS anti-pollution analysis efficiency is improved. For a specific type of DNS requests, shunting is carried out again according to the DNS anti-pollution domain name list, if the target domain name is successfully matched with the DNS anti-pollution domain name list, the domain name IP is analyzed through a DoH mechanism to achieve the anti-pollution purpose, for the target domain name which is not successfully matched, it is regarded that anti-pollution is not needed, and the domain name IP is directly analyzed through conventional DNS query to achieve the anti-pollution purpose. Therefore, the analysis efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security, and in particular to a home gateway device and a DNS pollution prevention method thereof. Background Art

[0002] DNS provides a very important domain name resolution service on the Internet. When a user enters a domain name (such as example.com), the operating system sends a query request to the DNS server to obtain the IP address corresponding to the domain name. This IP address is used to locate the server and establish a connection to achieve the purpose of accessing websites, sending emails, etc. The domain name of most websites has at least one IP address associated with it, which can be obtained through DNS queries. Whether it is a large e-commerce website or a personal blog, DNS is needed to resolve its domain name and point users to the correct server.

[0003] Conventional DNS uses port 53 of the UDP protocol for communication. In most cases, DNS queries and responses are transmitted using UDP, because UDP is a connectionless, lightweight protocol that is suitable for short-term communications and fast responses. However, due to this feature, DNS is obviously transmitted in plain text, and data packets may be hijacked and tampered when passing through a complex network environment, which is often called DNS pollution. In order to solve this problem, the strategy of encrypting DNS requests came into being, using some secure protocols to carry DNS, such as DoT (DNS over TLS) and DoH (DNS overHTTPS).

[0004] DoH (DNS over HTTPS) is a protocol for encrypting DNS query traffic, see RFC8484 for details. It encrypts traditional DNS query traffic over HTTPS, thereby enhancing privacy and security. Conventional DNS queries are often vulnerable to attacks such as DNS hijacking and DNS pollution, causing users to be redirected to malicious websites or receive forged DNS responses. DoH prevents these types of attacks and enhances the security and integrity of communications by using HTTPS to encrypt communications. Some Internet Service Providers (ISPs) may censor, filter, or interfere with DNS queries, affecting users' access to specific websites. Using DoH can bypass these types of ISP interventions and ensure that users can freely access all resources on the Internet.

[0005] Since DoH is based on HTTPS, its underlying layer is naturally TCP port 443. Compared with regular DNS based on UDP, it is inferior in resolution speed. In addition, the support of DoH by devices in home networks is not very complete. Therefore, how to enable devices in home networks to use DoH to achieve DNS anti-pollution and take into account the overall domain name resolution efficiency when implementing DoH is an urgent problem to be solved. Summary of the invention

[0006] The technical problem to be solved by the present invention is: to propose a home gateway device and its DNS anti-pollution method, to realize anti-pollution in the resolution process for domain names that need anti-pollution, and at the same time support conventional DNS resolution for domain names that do not need anti-pollution, so as to ensure the security of terminal network communication while taking into account the overall domain name resolution efficiency.

[0007] The technical solution adopted by the present invention to solve the above technical problems is:

[0008] In one aspect, the present invention provides a home gateway device, comprising:

[0009] DNS anti-pollution configuration module, used for users to configure DNS anti-pollution, and construct a DNS anti-pollution domain name list according to the user's DNS anti-pollution configuration;

[0010] A DNS request capture module, used to capture the DNS requests of terminal devices;

[0011] DoH cache module, used to cache the IP address of the target domain name fed back to the DoH query;

[0012] The DNS request pre-diversion module is used to parse the DNS request, obtain the target domain name and query type, and pre-divert according to the query type: if the query type is a specific type, the domain name matching module is notified; if the query type is not a specific type, the DNS query module is notified;

[0013] The DNS query module is used to perform regular DNS queries on target domain names with non-specific query types or domain name matching failures, obtain the IP address of the corresponding target domain name, and notify the feedback module;

[0014] The domain name matching module is used to match the target domain name of a specific query type in the DNS anti-pollution domain name list. If the match fails, the DNS query module is notified; if the match is successful, the DoH cache module is queried first. If the valid IP corresponding to the target domain name is obtained, the feedback module is notified; if the valid IP corresponding to the target domain name is not obtained, the DoH query module is notified;

[0015] The DoH query module is used to initiate a DoH request to the target domain name, obtain the IP address of the corresponding target domain name, submit it to the feedback module, and notify the DoH cache module to cache it;

[0016] The feedback module is used to feed back the acquired target domain name IP to the corresponding terminal device that initiated the DNS request.

[0017] Furthermore, the specific query type is a Class A query or a Class AAAA query, wherein Class A represents the IPv4 address of the queried domain name, and Class AAAA represents the IPv6 address of the queried domain name.

[0018] Furthermore, a valid IP in the DoH cache module means that the cache time of the IP has not expired.

[0019] On the other hand, the present invention also provides a DNS anti-pollution method for a home gateway device, which is applied to the above-mentioned home gateway device and comprises the following steps:

[0020] S1. Construct a DNS anti-pollution domain name list based on the user's DNS anti-pollution configuration;

[0021] S2, capture the DNS request of the terminal device;

[0022] S3, parse the DNS request to obtain the target domain name and query type;

[0023] S4, determining the query type of the target domain name, if the query type is a specific type, proceeding to step S6, if the query type is not a specific type, proceeding to step S5;

[0024] S5, perform a regular DNS query on the target domain name to obtain the IP corresponding to the target domain name, and proceed to step S9;

[0025] S6, matching the target domain name in the DNS anti-pollution domain name list, if the match is successful, proceed to step S7, if the match fails, proceed to step S5;

[0026] S7, query the local DoH cache to determine whether there is a valid IP corresponding to the target domain name, if so, obtain the IP of the target domain name and proceed to step S9, otherwise, proceed to step S8;

[0027] S8. Initiate a DoH request to the target domain name, obtain the IP address of the target domain name, and cache it in the local DoH cache, and proceed to step S9.

[0028] S9. Feedback the acquired target domain name IP to the corresponding terminal device that initiated the DNS request.

[0029] Furthermore, in step S1, according to the user's DNS anti-pollution configuration, a DNS anti-pollution domain name list is constructed, including:

[0030] The user configures the home gateway device through its management page by manually adding or deleting domain name entries or importing an anti-pollution domain name file, and writes the configuration content into the database and stores it as an anti-pollution domain name list;

[0031] The home gateway device reads the anti-pollution domain name list in the database, traverses each domain name string, flips it and uses it as input to construct a hash table.

[0032] Furthermore, in step S6, the target domain name is matched in the DNS anti-pollution domain name list, including:

[0033] Flip the target domain name string, calculate the hash value of the target domain name string through a preset hash algorithm, and then match it with the hash table constructed based on the anti-pollution domain name list in the database.

[0034] Furthermore, in step S7, the local DoH cache is organized in the form of a hash table. When performing a local DoH cache query, the hash value of the target domain name string is used to query whether there is a corresponding DoH cache node in the local DoH cache. If the cache node exists, then the validity of the cache node is determined based on the query type and the current timestamp; if the cache node is valid, the IP address corresponding to the domain name is directly taken out from the node to complete the query process. If the cache node is expired, the node is deleted and step S8 is entered.

[0035] Furthermore, in step S9, after the target domain name IP is obtained, a response message is constructed according to the conventional DNS protocol and fed back to the corresponding terminal device that initiated the DNS request.

[0036] The beneficial effects of the present invention are:

[0037] The present invention can pre-configure a DNS anti-pollution domain name list according to user needs, in which the domain names that need to be resolved with anti-pollution are recorded. After capturing the DNS request of the terminal device, the target domain name and the query type are resolved, and then pre-diverting is performed according to the query type, that is, a regular DNS query is directly performed for non-specific types of DNS requests, and for specific types of DNS requests, diverting is performed again according to the DNS anti-pollution domain name list, that is, if the target domain name matches the anti-pollution domain name list successfully, it means that the domain name resolution needs to be prevented from pollution, and the DoH mechanism is used to resolve the domain name IP. If the match is unsuccessful, it means that the domain name resolution does not need to be prevented from pollution, and the regular DNS query is used to resolve the domain name IP. Through the above-mentioned DNS diversion, the security of DoH and the speed of regular DNS can be fully utilized. While preventing pollution in the resolution process for the domain names in the anti-pollution domain name list, the overall domain name resolution speed is also taken into account.

[0038] In addition, after resolving the target domain name IP that needs to be protected from pollution through the DoH mechanism, the present invention caches it in the local DoH cache. During the next validity period of the domain name IP, the domain name IP can be directly obtained by querying the local DoH cache, thereby further improving the efficiency of domain name resolution. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 A network topology diagram applicable to the DNS anti-pollution method of the present invention;

[0040] Figure 2 This is a structural block diagram of a home gateway device in the present invention;

[0041] Figure 3 Flow chart of the DNS anti-pollution method in an embodiment of the present invention;

[0042] Figure 4 An example diagram of a DoH cache node. DETAILED DESCRIPTION

[0043] The present invention aims to propose a home gateway device and a DNS anti-pollution method thereof, which realizes anti-pollution in the resolution process for domain names that need to be anti-pollution, and supports conventional DNS resolution for domain names that do not need to be anti-pollution, so as to ensure the security of terminal network communication while taking into account the overall domain name resolution efficiency. The core idea is: pre-configure a DNS anti-pollution domain name list according to user needs, and the table records the domain names that need to be anti-pollution resolved. When applied, the gateway listens to all conventional DNS requests, and resolves the target domain name and query type, and then performs pre-diversion according to the query type, that is, directly performs conventional DNS queries for non-specific types of DNS requests, and for specific types of DNS requests, it is again diverted according to the DNS anti-pollution domain name list. If the target domain name matches the DNS anti-pollution domain name list successfully, the domain name IP is resolved through the DoH mechanism to achieve the purpose of anti-pollution. For the target domain name that does not match successfully, it is deemed that anti-pollution is not required, and the domain name IP is directly resolved through conventional DNS queries, thereby improving the resolution efficiency. Based on the above-mentioned diversion means of the present invention, the overall domain name resolution efficiency can be taken into account while ensuring the security of terminal network communication.

[0044] In specific implementation, the main body of the DNS anti-pollution implementation of the present invention is a home gateway device, which is usually a network device working in routing mode, such as a gateway or router device with data forwarding capability and providing DHCP services in the network. Figure 1 As shown, one side of the home gateway device is connected to the internal network to receive data packets from internal terminal devices, and the other side is connected to the external network to provide external network access capabilities, thereby serving as a bridge for internal terminal devices to access the external network.

[0045] Among them, internal terminal devices refer to devices that run the TCP / IP protocol stack and are connected to the home gateway via wired or wireless methods. Common IoT devices include mobile phones, computers, smart speakers, etc.

[0046] The structure of the home gateway device in the present invention is shown in Figure 2 It includes DNS anti-pollution configuration module, DNS request capture module, DoH cache module, DNS request pre-diversion module, DNS query module, domain name matching module, DoH query module and feedback module; the functions of each module are as follows:

[0047] DNS anti-pollution configuration module, used for users to configure DNS anti-pollution, and construct a DNS anti-pollution domain name list according to the user's DNS anti-pollution configuration;

[0048] A DNS request capture module, used to capture the DNS requests of terminal devices;

[0049] DoH cache module, used to cache the IP address of the target domain name fed back to DoH query;

[0050] The DNS request pre-diversion module is used to parse the DNS request, obtain the target domain name and query type, and pre-divert according to the query type: if the query type is a specific type, the domain name matching module is notified; if the query type is not a specific type, the DNS query module is notified;

[0051] The DNS query module is used to perform regular DNS queries on target domain names with non-specific query types or domain name matching failures, obtain the IP of the corresponding target domain name, and notify the feedback module;

[0052] The domain name matching module is used to match the target domain name of a specific query type in the DNS anti-pollution domain name list. If the match fails, the DNS query module is notified; if the match is successful, the DoH cache module is queried first. If the valid IP corresponding to the target domain name is obtained, the feedback module is notified; if the valid IP corresponding to the target domain name is not obtained, the DoH query module is notified;

[0053] The DoH query module is used to initiate a DoH request to the target domain name, obtain the IP address of the corresponding target domain name, submit it to the feedback module, and notify the DoH cache module to cache it;

[0054] The feedback module is used to feed back the acquired target domain name IP to the corresponding terminal device that initiated the DNS request.

[0055] The home gateway device based on the above structure can pre-divert traffic according to the query type of the target domain name in the regular DNS request. For non-specific type (non-A / AAAA type) DNS requests, regular DNS queries are directly performed. For specific types of DNS requests, traffic is diverted again according to the DNS anti-pollution domain name list. If the target domain name matches the DNS anti-pollution domain name list successfully, the domain name IP is resolved through the DoH mechanism to achieve the purpose of anti-pollution. For the target domain name that does not match successfully, it is deemed that anti-pollution is not required, and the domain name IP is directly resolved through regular DNS queries.

[0056] Example

[0057] This embodiment provides a DNS anti-pollution method applied to the above-mentioned home gateway device. Figure 3 , which includes the following implementation steps:

[0058] S101. Construct a DNS anti-pollution domain name list according to the user's DNS anti-pollution configuration;

[0059] In this step, the user configures the home gateway device through its management page by manually adding or deleting domain name entries or importing an anti-pollution domain name file, and writes the configuration content to the database;

[0060] The home gateway device reads the anti-pollution domain name list in the database, traverses each domain name string, flips it and uses it as input to construct a hash table. For example, the domain name "github.com" is actually constructed as "moc.buhtig". The purpose of this method is to achieve suffix matching.

[0061] S102, capturing a DNS request of a terminal device;

[0062] In this step, the DNS server address in the DHCP message is configured to capture the DNS request of the internal terminal device. DHCP (Dynamic Host Configuration Protocol) is a network protocol used to dynamically assign IP addresses and other network configuration parameters to devices in the network. When the terminal device in the internal network goes online, it usually interacts with the home gateway device through DHCP. The home gateway device can send its own IP address as the DNS server address in the DHCP response message to the terminal device, so that when the terminal device performs domain name resolution, it will send the DNS request message to the home gateway.

[0063] S103, parsing the DNS request to obtain the target domain name and query type;

[0064] In this step, the regular DNS request is a plaintext message of UDP protocol port 53. What needs to be paid attention to is the Querys field. A resolution request includes Name, Type and Class; Name is usually represented as a series of labels separated by dots, each label is a string, representing a part of the domain name, Type represents the type of query, and only the A / AAAA types are concerned here. A represents the IPv4 address of the queried domain name, and AAAA represents the IPv6 address of the queried domain name. Class represents the class of the query, and only the Internet resource record represented by IN is concerned here.

[0065] S104, determining the query type of the target domain name, if the query type is a specific type, proceeding to step S106, if the query type is not a specific type, proceeding to step S105;

[0066] In this step, pre-diversion is performed according to whether the query type is A / AAAA; if it is a non-A / AAAA query, such as PTR, CNAME and other query types, then turn to the regular DNS query process in step S105; if it is an A / AAAA query, then turn to the target domain name matching process in step S106.

[0067] S105, perform a regular DNS query on the target domain name to obtain the IP corresponding to the target domain name, and proceed to step S109;

[0068] In this step, for non-A / AAAA class queries or when the target domain name is not successfully matched in the DNS anti-pollution domain name list, a conventional plaintext DNS request can be directly used to query the IP corresponding to the target domain name.

[0069] S106, matching the target domain name in the DNS anti-pollution domain name list, if the match is successful, proceed to step S107, if the match fails, proceed to step S105;

[0070] In this step, the matching process is to flip the target domain name string, calculate the hash value of the target domain name string through a preset hash algorithm, and then match it with the hash table constructed based on the anti-pollution domain name list in the database.

[0071] Taking the A-type query of the domain name "www.github.com" as an example, the matching process is explained as follows:

[0072] First, the target domain name is flipped to get "moc.buhtig.www", and then the suffixes of different lengths are divided by the "." character to get the three suffixes "moc", "moc.buhtig" and "moc.buhtig.www". The hash algorithm is executed while scanning the string. Every time the "." character is encountered or the end of the string is reached, the hash table composed of the anti-pollution domain name list is queried according to the current hash result. If the query target exists, the complete hash value of the string is directly calculated, and the match success status is returned when exiting; if all suffix query results are non-existent, the match failure status is returned when exiting.

[0073] If the anti-pollution domain name matching fails, it is considered that the domain name does not need anti-pollution, and the process turns to the conventional DNS query process in step S105.

[0074] S107, query the local DoH cache to determine whether there is a valid IP corresponding to the target domain name, if so, obtain the IP of the target domain name and proceed to step S109, otherwise, proceed to step S108;

[0075] In this step, the DoH cache is also organized in the form of a hash table. The structure of an exemplary cache node is as follows: Figure 4 As shown;

[0076] The gateway device quickly queries whether there is a corresponding DoH cache node in the local DoH cache through the calculated hash value of the complete domain name string. If the cache node exists, it determines whether the cache node is valid based on the query type and the current timestamp; if the cache node is valid, the IP address corresponding to the domain name is directly taken out from the node to complete the query process; if the cache node is expired, the node is deleted and the DoH query process in step S108 is entered.

[0077] S108, initiate a DoH request to the target domain name, obtain the IP address of the corresponding target domain name, and cache it in the local DoH cache, and proceed to step S109;

[0078] In this step, two parameters, domain name and query type, are required when using DoH to request a query.

[0079] Taking the A query type of "www.github.com" as an example, the DoH query module needs to construct a query such as "https: / / 223.6.6.6 / resolve?name=www.github.com&type=A". The more complex HTTPS interaction process can be implemented by introducing the libcurl library; the response of the request is usually a text in JSON format, and the cJSON library can be used to parse the JSON content returned by the DoH server. The field that needs attention is Answer, which records the results of domain name resolution, such as the domain name string NAME, valid time TTL, return type Type, and the IP corresponding to the domain name; the DoH query module needs to parse the information in the Answer field, extract the IP address, and submit this information to the DoH cache module to construct a DoH cache node, so that when a request to resolve the domain name is received again in a short time, it can respond quickly instead of entering the relatively time-consuming DoH query process.

[0080] S109: Feedback the acquired target domain name IP to the corresponding terminal device that initiated the DNS request.

[0081] In this step, after obtaining the IP address of the target domain name through conventional DNS, DoH or some other method in the local cache, it is necessary to construct a response message according to the conventional DNS protocol and send it to the internal terminal device to complete the domain name resolution process.

[0082] Finally, although the embodiments of the present invention have been described above, it will be understood by those skilled in the art that various changes, modifications, substitutions and variations may be made to these embodiments without departing from the principle and spirit of the present invention, all without departing from the scope of protection of the present invention.

Claims

1. A home gateway device, It is characterized in that include: DNS anti-pollution configuration module, used for users to configure DNS anti-pollution, and construct a DNS anti-pollution domain name list according to the user's DNS anti-pollution configuration; A DNS request capture module, used to capture the DNS requests of terminal devices; DoH cache module, used to cache the IP address of the target domain name fed back to the DoH query; The DNS request pre-diversion module is used to parse the DNS request, obtain the target domain name and query type, and pre-divert according to the query type: if the query type is a specific type, the domain name matching module is notified; if the query type is not a specific type, the DNS query module is notified; The DNS query module is used to perform regular DNS queries on target domain names with non-specific query types or domain name matching failures, obtain the IP of the corresponding target domain name, and notify the feedback module; A domain name matching module is used to match the target domain name of a specific query type in the DNS anti-pollution domain name list. If the match fails, the DNS query module is notified; If the match is successful, the DoH cache module is queried first. If a valid IP corresponding to the target domain name is obtained, the feedback module is notified. If no valid IP corresponding to the target domain name is obtained, the DoH query module is notified. The DoH query module is used to initiate a DoH request to the target domain name, obtain the IP address of the corresponding target domain name, submit it to the feedback module, and notify the DoH cache module to cache it; The feedback module is used to feed back the acquired target domain name IP to the corresponding terminal device that initiated the DNS request.

2. A home gateway device as claimed in claim 1, It is characterized in that The specific query type is a Class A query or a Class AAAA query, wherein Class A represents the IPv4 address of the queried domain name, and Class AAAA represents the IPv6 address of the queried domain name.

3. A home gateway device as claimed in claim 1 or 2, It is characterized in that A valid IP in the DoH cache module means that the cache time of the IP has not expired.

4. A DNS anti-pollution method for a home gateway device, applied to the home gateway device as claimed in any one of claims 1 to 3, It is characterized in that The following steps are involved: S1. Construct a DNS anti-pollution domain name list based on the user's DNS anti-pollution configuration; S2, capture the DNS request of the terminal device; S3, parse the DNS request to obtain the target domain name and query type; S4, determining the query type of the target domain name, if the query type is a specific type, proceeding to step S6, if the query type is not a specific type, proceeding to step S5; S5, perform a regular DNS query on the target domain name to obtain the IP corresponding to the target domain name, and proceed to step S9; S6, matching the target domain name in the DNS anti-pollution domain name list, if the match is successful, proceed to step S7, if the match fails, proceed to step S5; S7, query the local DoH cache to determine whether there is a valid IP corresponding to the target domain name, if so, obtain the IP of the target domain name and proceed to step S9, otherwise, proceed to step S8; S8. Initiate a DoH request to the target domain name, obtain the IP address of the target domain name, and cache it in the local DoH cache, and proceed to step S9. S9. Feedback the acquired target domain name IP to the corresponding terminal device that initiated the DNS request.

5. A DNS anti-pollution method for a home gateway device as claimed in claim 4, It is characterized in that In step S1, according to the user's DNS anti-pollution configuration, a DNS anti-pollution domain name list is constructed, including: The user configures the home gateway device through its management page by manually adding or deleting domain name entries or importing an anti-pollution domain name file, and writes the configuration content into the database and stores it as an anti-pollution domain name list; The home gateway device reads the anti-pollution domain name list in the database, traverses each domain name string, flips it and uses it as input to construct a hash table.

6. A DNS anti-pollution method for a home gateway device as claimed in claim 5, It is characterized in that In step S6, the target domain name is matched in the DNS anti-pollution domain name list, including: Flip the target domain name string, calculate the hash value of the target domain name string through a preset hash algorithm, and then match it with the hash table constructed based on the anti-pollution domain name list in the database.

7. A DNS anti-pollution method for a home gateway device as claimed in claim 4, It is characterized in that In step S7, the local DoH cache is organized in the form of a hash table. When performing a local DoH cache query, the hash value of the target domain name string is used to query whether there is a corresponding DoH cache node in the local DoH cache. If the cache node exists, the validity of the cache node is determined based on the query type and the current timestamp. If the cache node is valid, the IP address corresponding to the domain name is directly taken out from the node to complete the query process. If the cache node is expired, the node is deleted and step S8 is entered.

8. A DNS anti-pollution method for a home gateway device according to any one of claims 4 to 7, It is characterized in that In step S9, after the target domain name IP is obtained, a response message is constructed according to the conventional DNS protocol and fed back to the corresponding terminal device that initiated the DNS request.