Domain name analysis method and device, electronic equipment and readable storage medium
By receiving the client's domain name request and determining the address pool according to the query field or rule pattern for domain name resolution, it solves the problem in the existing technology that the domain name only corresponds to a fixed IP group and does not support domain name rule query, and realizes domain name self-adaptation and The query function improves the flexibility and ease of use of load balancing.
Patent Information
- Application Number
- CN202410892313.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-03
- Publication Date
- 2024-09-10
AI Technical Summary
In the existing domain name system, the domain name of each policy only corresponds to a fixed IP group. It is impossible to implement multiple groups of IPs to adopt different balancing strategies, and it does not support clients to query domain name rules from the domain name server.
By receiving the domain name request from the client, if there is a query field, the address and response identifier corresponding to the domain name are returned; if there is no query field, the address pool is determined based on the rule pattern of the domain name, domain name resolution is performed based on the preset policy, and the resolution result is sent to the client end.
It realizes the self-adaptation of different rule modes for setting a domain name, adapts to different business needs, supports the domain name query function, simplifies the configuration of multi-domain name scenario requirements, expands the multi-policy application scenarios of load balancing, and improves flexibility and ease of use. sex.
Smart Images

Figure CN118631779A
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a domain name resolution method, a domain name resolution device, an electronic device, and a computer-readable storage medium. Background Art
[0002] The current DNS (Domain Name System) domain name load balancing strategy provides a variety of balancing strategies, such as polling strategy, connection number strategy, CPU (Central Processing Unit) utilization strategy, bandwidth utilization strategy, etc. However, the domain name of each strategy only corresponds to a fixed IP group. If you want to use different strategies to balance multiple groups of IPs, you need to set up multiple domain names. Only by accessing different domain names can you resolve to the corresponding IP group. It is impossible to set up a domain name and automatically adapt to each balancing mode according to different preset needs.
[0003] At the same time, current domain name services do not support clients to query domain name rules to domain name servers. Summary of the invention
[0004] The embodiment of the present invention provides a domain name resolution method, device, electronic device and computer-readable storage medium to solve the problem in the prior art that the domain name of each strategy only corresponds to a fixed IP group and does not support the client to query the domain name rule to the domain name server.
[0005] The embodiment of the present invention discloses a domain name resolution method, comprising:
[0006] Receive a domain name request from a client; the domain name request includes a domain name;
[0007] If the domain name has a query field, determining return information corresponding to the domain name, and returning the return information to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier;
[0008] If the query field does not exist in the domain name, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on the preset strategy and the address pool corresponding to the domain name to obtain a resolution result;
[0009] The resolution result is sent to the client; and the client accesses the address corresponding to the domain name based on the resolution result.
[0010] Optionally, before receiving the domain name request from the client, the method further includes:
[0011] Parsing the configuration file corresponding to the domain name to obtain configuration information;
[0012] The configuration information is stored in a global variable; the global variable is used to ensure the reading of the configuration information so that the configuration file does not need to be repeatedly parsed.
[0013] Optionally, the response identifier includes a success identifier and a failure identifier; if the domain name has a query field, determining return information corresponding to the domain name, and returning the return information to the client, includes:
[0014] If the query field exists in the domain name, determining whether there is configuration information corresponding to the domain name;
[0015] If there is configuration information corresponding to the domain name, the configuration information corresponding to the domain name and the success identifier are filled into the response information to generate first return information; the response information is information for the domain name request;
[0016] If the configuration information corresponding to the domain name does not exist, filling the failure identifier into the response information to generate second return information;
[0017] The first return information or the second return information is returned to the client; wherein the return information is the first return information or the second return information.
[0018] Optionally, the rule mode includes an odd-even mode and a keyword matching mode, and the domain name request also includes the address of the client; if the domain name does not have the query field, determining the address pool corresponding to the domain name according to the rule mode corresponding to the domain name, and performing domain name resolution based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result, including:
[0019] Determine the rule mode corresponding to the domain name and the address pool group corresponding to the domain name according to the configuration information corresponding to the domain name;
[0020] When the rule mode corresponding to the domain name is the odd-even mode, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name according to the address of the client;
[0021] When the rule mode corresponding to the domain name is the keyword matching mode, the address pool corresponding to the domain name is determined in the address pool group corresponding to the domain name according to the keyword corresponding to the domain name; the keyword corresponding to the domain name is determined by the configuration information corresponding to the domain name, and one keyword corresponds to one address pool;
[0022] When the rule pattern corresponding to the domain name does not exist in the configuration information corresponding to the domain name, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name based on the preset strategy;
[0023] A domain name resolution is performed based on the preset policy and the address pool corresponding to the domain name to obtain the resolution result.
[0024] Optionally, when the rule mode corresponding to the domain name is the even-odd mode, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name according to the address of the client includes:
[0025] When the rule mode corresponding to the domain name is the even-odd mode, the address pool group corresponding to the domain name includes a first address pool and a second address pool;
[0026] When the last digit of the address of the client is an odd number, the first address pool is determined as the address pool corresponding to the domain name;
[0027] When the last digit of the address of the client is an even number, the second address pool is determined as the address pool corresponding to the domain name.
[0028] Optionally, if the query field does not exist in the domain name, determining the address pool corresponding to the domain name according to the rule pattern corresponding to the domain name, and performing domain name resolution based on a preset policy and the address pool corresponding to the domain name, after obtaining the resolution result, the method further includes:
[0029] Obtaining time attribute information of a configuration file corresponding to the domain name, and determining whether the configuration file corresponding to the domain name has been modified according to the time attribute information;
[0030] If the configuration file corresponding to the domain name is modified, reload the modified configuration file, and parse the modified configuration file to obtain configuration information corresponding to the modified configuration file;
[0031] The configuration information corresponding to the modified configuration file is stored in the global variable.
[0032] Optionally, one address is allowed to be shared among multiple domain names.
[0033] The embodiment of the present invention also discloses a domain name resolution device, including:
[0034] A receiving module, configured to receive a domain name request from a client; the domain name request includes a domain name;
[0035] A query module, configured to determine return information corresponding to the domain name if a query field exists in the domain name, and return the return information to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier;
[0036] A rule module, configured to determine the address pool corresponding to the domain name according to the rule mode corresponding to the domain name if the query field does not exist in the domain name, and perform domain name resolution based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result;
[0037] The sending module is used to send the resolution result to the client; the client accesses the address corresponding to the domain name based on the resolution result.
[0038] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0039] The memory is used to store computer programs;
[0040] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0041] The embodiment of the present invention further discloses a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the embodiment of the present invention.
[0042] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0043] The embodiments of the present invention include the following advantages:
[0044] In an embodiment of the present invention, a domain name request from a client is received; the domain name request includes a domain name; if the domain name has a query field, the return information corresponding to the domain name is determined, and the return information is returned to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier; if the domain name does not have the query field, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result; the resolution result is sent to the client; the client accesses the address corresponding to the domain name based on the resolution result. The embodiment of the present invention sets different rule modes for a domain name, and when the client performs domain name access, the IP corresponding to the domain name request resolution is determined according to different rule modes, so as to achieve the expected balancing strategy and better adapt to different business needs. At the same time, the embodiment of the present invention can realize the domain name query function by setting a query field in the domain name, which solves the limitation that the current domain name service does not support the client to perform domain name rule query to the domain name server. The embodiments of the present invention simplify the scenario requirement configuration of multiple domain names, expand the multi-strategy application scenarios of load balancing, and make the application of load balancing strategies more flexible and changeable for more complex application business scenarios, making the entire storage external entrance unique, making maintenance more convenient, and easier for customers to use. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a schematic diagram of an application environment provided in an embodiment of the present invention;
[0046] Figure 2 is a flowchart of a method for resolving a domain name provided in an embodiment of the present invention;
[0047] Figure 3 It is a schematic diagram of the resolution process of a multi-level domain name self-adaptation solution based on DNS load balancing provided in an embodiment of the present invention;
[0048] Figure 4 It is a structural block diagram of a domain name resolution device provided in an embodiment of the present invention;
[0049] Figure 5 is a schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention;
[0050] Figure 6 is a schematic diagram of a computer-readable medium provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0052] Reference Figure 1 , showing a schematic diagram of an application environment provided in an embodiment of the present invention, the client sends a domain name request to the DNS server, and the DNS server sends return information or resolution results to the client based on the domain name request.
[0053] Reference Figure 2 , shows a flowchart of a domain name resolution method provided in an embodiment of the present invention, which may specifically include the following steps:
[0054] Step 201: receiving a domain name request from a client; the domain name request includes a domain name;
[0055] IP addresses are not easy for users to remember, so domain names are used instead of IP addresses to identify site addresses, so that users only need to know the easy-to-remember domain name. Accordingly, domain name resolution is required to obtain the IP address corresponding to the domain name in order to access the website, and the DNS server can point the domain name to the IP address.
[0056] In the embodiment of the present invention, the DNS server selects a suitable node for the client to access based on the load balancing strategy corresponding to the domain name. The load balancing strategy includes a polling strategy, a strategy based on the available resources of the node, a random strategy, or a source address hash strategy. Therefore, the client sends a domain name request to the DNS server, and then the DNS server determines the IP address corresponding to the domain name according to the domain name request.
[0057] Step 202: If the domain name has a query field, determine the return information corresponding to the domain name, and return the return information to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier;
[0058] In the embodiment of the present invention, if the domain name contains a specific query field, the DNS server will search for configuration information related to the domain name. The DNS server will generate different return information based on whether the configuration information exists, and return the return information to the client.
[0059] For example, based on the domain name of the domain name request, determine whether the query field "-dnshelp" exists. If "-dnshelp" exists, read the configuration information of the corresponding domain name in the current memory. If the configuration information does not exist, an error will be returned to the client. If the configuration information exists, fill the corresponding configuration information into the DNS response information, generate the return information and return it to the client.
[0060] In an embodiment of the present invention, when a DNS server receives a domain name request with a query field in the domain name, it does not perform specific IP resolution on the domain name request, but returns the domain name configuration information of the current domain name server as a result to the client for reference. By setting the query field in the domain name, the function of the DNS server is easily extended, so that the DNS server can implement the domain name query function, which solves the limitation that current domain name services do not support clients to query domain name rules to domain name servers.
[0061] Step 203: If the query field does not exist in the domain name, determine the address pool corresponding to the domain name according to the rule mode corresponding to the domain name, and perform domain name resolution based on the preset strategy and the address pool corresponding to the domain name to obtain a resolution result;
[0062] In another embodiment of the present invention, if the domain name does not contain a specific query field, the DNS server will not search for configuration information related to the domain name and continue the subsequent domain name resolution process.
[0063] In an embodiment of the present invention, it is first necessary to determine the rule mode under the domain name. The rule mode includes an odd-even mode and a keyword matching mode. The load balancing strategy corresponding to the domain name request resolution is determined according to different rule modes, and then the IP pool (address pool) corresponding to the domain name request resolution is determined.
[0064] Step 204: Send the resolution result to the client; the client accesses the address corresponding to the domain name based on the resolution result.
[0065] In an embodiment of the present invention, after completing the domain name resolution process, different resolution results corresponding to different domain name requests will be obtained. The resolution results include the IP address corresponding to the domain name. After the DNS server obtains the resolution result, it will send the resolution result to the client so that the client can access the website through the IP address in the resolution result.
[0066] In an embodiment of the present invention, a domain name request from a client is received; the domain name request includes a domain name; if the domain name has a query field, the return information corresponding to the domain name is determined, and the return information is returned to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier; if the domain name does not have the query field, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result; the resolution result is sent to the client; the client accesses the address corresponding to the domain name based on the resolution result. The embodiment of the present invention sets different rule modes for a domain name, and when the client performs domain name access, the IP corresponding to the domain name request resolution is determined according to different rule modes, so as to achieve the expected balancing strategy and better adapt to different business needs. At the same time, the embodiment of the present invention can realize the domain name query function by setting a query field in the domain name, which solves the limitation that the current domain name service does not support the client to perform domain name rule query to the domain name server. The embodiments of the present invention simplify the scenario requirement configuration of multiple domain names, expand the multi-strategy application scenarios of load balancing, and make the application of load balancing strategies more flexible and changeable for more complex application business scenarios, making the entire storage external entrance unique, making maintenance more convenient, and easier for customers to use.
[0067] In an embodiment of the present invention, before step 101, receiving a domain name request from a client, the method further includes:
[0068] Parsing the configuration file corresponding to the domain name to obtain configuration information;
[0069] The configuration information is stored in a global variable; the global variable is used to ensure the reading of the configuration information so that the configuration file does not need to be repeatedly parsed.
[0070] In the embodiment of the present invention, the configuration file needs to be parsed in advance. Specifically, the load balancing configuration file still adopts the existing standard XML formatting and parsing method, and only the configuration file structure is expanded. The expanded content includes the rule description under the domain name, the domain name keyword matching field, and the domain name can contain multiple IP pool arrays. When the advanced load balancing service is started, the configuration file content is first loaded, and the structured parsing of the configuration file content is saved in the structure of the global variable. The configuration file attribute time is judged each time the domain name is resolved. If the attribute changes, the configuration file is reloaded.
[0071] In an optional embodiment of the present invention, a periodic check mechanism can be set up, such as checking the modification of the configuration file at regular intervals (such as every minute). Although this method is not real-time, it can ensure the timely update of the configuration to a certain extent. Alternatively, a timestamp or version number can be included in the configuration file, and the timestamp or version number is updated every time the file is modified. The timestamp or version number is checked before resolving the domain name. If it is found that it is inconsistent with the currently stored timestamp or version number, it is considered that the configuration file has been modified and needs to be reloaded. The timestamp or version number can accurately indicate the latest status of the configuration file, avoiding misjudgment or missed judgment due to unclear changes in the file content, and obtaining the timestamp or version number of the file is a simple operation, which is easy to integrate into the existing technical solutions.
[0072] Structured parsing refers to converting data from one format (usually unstructured or semi-structured) into another structured format that is easier to process. In an embodiment of the present invention, the configuration file is stored in XML format, and structured parsing means extracting the data in the XML file and converting it into an internal data structure so that the program can access and operate the data more conveniently. The structure itself is a structured data representation method. When the configuration file is parsed, its content is converted into a structure, and each member variable of this structure corresponds to a specific data point in the configuration file. In this way, the structured content of the configuration file is mapped to a structure, so that the program can access and use the configuration information in an organized manner.
[0073] Global variables are variables that can be accessed throughout the entire program. Unlike local variables that can only be accessed within the function or code block in which they are defined, global variables can be accessed and modified anywhere in the program. In an embodiment of the present invention, configuration information is stored in the structure of global variables, that is, any code that needs this configuration information can directly access these global variables without having to reparse the configuration file each time.
[0074] Repeated file parsing processes consume system resources. By pre-parsing the configuration file and storing the configuration information in global variables, it is possible to avoid the need to re-read and parse the configuration file each time the domain name is resolved, thereby significantly improving the efficiency of domain name resolution. By monitoring changes in configuration file attributes, the system can reload the configuration file when the attributes change, ensuring the real-time and accuracy of the configuration information.
[0075] In an embodiment of the present invention, the response identifier includes a success identifier and a failure identifier; the step 102, if the domain name has a query field, determining the return information corresponding to the domain name, and returning the return information to the client, includes:
[0076] If the query field exists in the domain name, determining whether there is configuration information corresponding to the domain name;
[0077] If there is configuration information corresponding to the domain name, the configuration information corresponding to the domain name and the success identifier are filled into the response information to generate first return information; the response information is information for the domain name request;
[0078] If the configuration information corresponding to the domain name does not exist, filling the failure identifier into the response information to generate second return information;
[0079] The first return information or the second return information is returned to the client; wherein the return information is the first return information or the second return information.
[0080] In the embodiment of the present invention, if the domain name contains a specific query field, the DNS server will search for configuration information related to the domain name. The DNS server will generate different return information based on whether the configuration information exists, and return the return information to the client.
[0081] Specifically, if the configuration information corresponding to the domain name exists in the memory, it means that the query is successful, and the corresponding configuration information and the success mark representing the successful query are filled in the response information, and the return information corresponding to the successful query (first return information) is generated, and the return information is returned to the client. If the configuration information corresponding to the domain name does not exist in the memory, it means that the query fails, and the failure mark representing the failed query is filled in the response information, and the return information corresponding to the failed query (second return information) is generated, and the return information is returned to the client.
[0082] In an embodiment of the present invention, when a DNS server receives a domain name request with a query field in the domain name, it does not perform specific IP resolution on the domain name request, but returns the domain name configuration information of the current domain name server as a result to the client for reference. By setting the query field in the domain name, the function of the DNS server is easily extended, so that the DNS server can implement the domain name query function, which solves the limitation that current domain name services do not support clients to query domain name rules to domain name servers.
[0083] In an embodiment of the present invention, the rule mode includes an odd-even mode and a keyword matching mode, and the domain name request also includes the address of the client; in step 103, if the query field does not exist in the domain name, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result, including:
[0084] Determine the rule mode corresponding to the domain name and the address pool group corresponding to the domain name according to the configuration information corresponding to the domain name;
[0085] When the rule mode corresponding to the domain name is the odd-even mode, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name according to the address of the client;
[0086] When the rule mode corresponding to the domain name is the keyword matching mode, the address pool corresponding to the domain name is determined in the address pool group corresponding to the domain name according to the keyword corresponding to the domain name; the keyword corresponding to the domain name is determined by the configuration information corresponding to the domain name, and one keyword corresponds to one address pool;
[0087] When the rule pattern corresponding to the domain name does not exist in the configuration information corresponding to the domain name, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name based on the preset strategy;
[0088] A domain name resolution is performed based on the preset policy and the address pool corresponding to the domain name to obtain the resolution result.
[0089] In an embodiment of the present invention, one address can be shared among multiple domain names.
[0090] In an embodiment of the present invention, if the rule mode is the odd-even mode, an IP pool is directly selected for domain name load balancing resolution based on the client IP (client address), and the subsequent load balancing resolution strategy still uses the existing polling, connection number and other strategies. After the resolution is completed, the result is returned to the client.
[0091] If the rule is a keyword matching mode, the corresponding IP pool is selected as the load balancing address pool for domain name resolution according to the rule settings in the configuration file, and the load balancing strategy still uses the existing polling, connection number and other balancing strategies.
[0092] If the rule pattern under the domain name is null (that is, there is no corresponding rule pattern), the existing resolution scheme is used by default and the resolution is completed directly according to the configured balancing strategy.
[0093] In one embodiment of the present invention, load balancing configuration needs to be performed in advance. Specifically, a domain name is set, and a corresponding rule mode is set for domain name matching: odd-even mode and keyword matching mode, only one of which can be selected for setting; when setting the odd-even mode, only two IP pools can be set under the domain name, and the odd-even of the IP pool must be specified; when setting the keyword matching mode, multiple keywords can be set, and one keyword corresponds to one IP pool.
[0094] Through the setting method of the rule pattern corresponding to the above domain name, multi-level domain name self-adaptation can be achieved, which is still compatible with the traditional multiple domain name scenarios, that is, each domain name corresponds to an IP pool mode. Under the multi-level domain name self-adaptation solution, an IP under a domain name can belong to multiple IP pools, that is, a domain name can belong to multiple IP pools of multiple domain names, which provides greater flexibility and adaptability.
[0095] The above-mentioned domain name, rule mode, and IP pool configuration information are all stored in a standard XML file (ie, configuration file). The client can add, delete, modify, and query the content in the configuration file.
[0096] In an embodiment of the present invention, when the rule mode corresponding to the domain name is the odd-even mode, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name according to the address of the client includes:
[0097] When the rule mode corresponding to the domain name is the even-odd mode, the address pool group corresponding to the domain name includes a first address pool and a second address pool;
[0098] When the last digit of the address of the client is an odd number, the first address pool is determined as the address pool corresponding to the domain name;
[0099] When the last digit of the address of the client is an even number, the second address pool is determined as the address pool corresponding to the domain name.
[0100] In an embodiment of the present invention, if the rule mode is the parity mode, the parity of the last digit of the client IP is directly determined. Based on the parity, an IP pool is selected for domain name load balancing resolution. The subsequent load balancing resolution strategy still uses the existing polling, connection number and other strategies. After the resolution is completed, the result is returned to the client.
[0101] Through parity mode, the DNS server can distribute traffic to different address pools based on the parity of the client IP address. This refined control helps to distribute the load more evenly and improve the availability and performance of the service. Parity mode is a simple and intuitive load balancing strategy that does not require complex algorithms or configurations. It can make decisions quickly based on the last digit of the IP address, which improves the system's response speed and processing efficiency. In parity mode, subsequent load balancing resolution strategies can still use existing polling, connection number and other strategies, which means that the system can be seamlessly integrated into the existing load balancing architecture without large-scale changes to the existing system.
[0102] Reference Figure 3, shows a schematic diagram of the resolution process of a multi-level domain name self-adaptation solution based on DNS load balancing provided in an embodiment of the present invention, 1. Receive a domain name request from a client, the request includes a domain name and a client IP. 2. According to the domain name of the domain name request, determine whether there is a keyword "-dnshelp". If it exists, read the configuration information of the corresponding domain name in the current memory. If the configuration information does not exist, return error (second return information) to the client. If the configuration information exists, fill the corresponding configuration information with the DNS response information, obtain the return information (first return information) and return it to the client. If the "-dnshelp" keyword does not exist, continue the subsequent resolution process. 3. Determine the rule mode under the domain name: (1) If the rule is an odd-even mode, directly determine the odd-even of the last digit of the client IP, and select an IP pool for domain name load balancing resolution based on the odd-even. The subsequent load balancing resolution strategy still uses the existing polling, connection number and other strategies. After the resolution is completed, the result is returned to the client. (2) If the rule is a keyword matching mode, according to the rule setting of the configuration file, select the corresponding IP pool as the load balancing address pool for domain name resolution, and the load balancing strategy still uses the existing polling, connection number and other balancing strategies. (3) If the rule mode under the domain name is null (no rule mode), the existing resolution scheme is used by default and the resolution is completed directly according to the configured balancing strategy.
[0103] The different rule modes can be understood through the following examples:
[0104] When the rule mode is odd-even mode, different IP pools are selected for resolution according to the odd or even number of the client IP. The client IPs of the domain name request are 192.168.1.1 and 192.168.1.2. The odd client IPs correspond to IP pool A: [192.168.10.1; 192.168.10.2; 192.168.10.3], and the even client IPs correspond to IP pool B: [192.168.10.11; 192.168.10.12; 192.168.10.13]. When the domain name request comes from client 192.168.1.1, the load balancing resolution uses IP pool A; when the domain name request comes from client 192.168.1.2, the load balancing resolution uses IP pool B.
[0105] When the rule mode is keyword matching mode, different address pools are selected for resolution according to the corresponding keywords in the domain name format of the domain name request. The set domain name is www.yuming.com, the keyword "yanfabu" corresponds to IP pool C: [192.168.10.21; 192.168.10.22; 192.168.10.23], and the keyword "caigoubu" corresponds to IP pool D: [192.168.10.31; 192.168.10.32; 192.168.10.33]; if the domain name request contains the keyword "yanfabu" www.yuming yanfabu.com, the domain name load balancing resolution uses IP pool C, and if the domain name request contains the keyword "caigoubu" www.yumingcaigoubu.com, the domain name load balancing resolution uses IP pool D.
[0106] In an embodiment of the present invention, if the domain name does not have the query field, the address pool corresponding to the domain name is determined according to the rule pattern corresponding to the domain name, and the domain name is resolved based on the preset strategy and the address pool corresponding to the domain name, and after obtaining the resolution result, the method further includes:
[0107] Obtaining time attribute information of a configuration file corresponding to the domain name, and determining whether the configuration file corresponding to the domain name has been modified according to the time attribute information;
[0108] If the configuration file corresponding to the domain name is modified, reload the modified configuration file, and parse the modified configuration file to obtain configuration information corresponding to the modified configuration file;
[0109] The configuration information corresponding to the modified configuration file is stored in the global variable.
[0110] In the domain name resolution process of the embodiment of the present invention, if the configuration file corresponding to the domain name is modified, the DNS server will obtain the time attribute information of the configuration file corresponding to the domain name, which can be the last modification time of the file. By comparing the time attribute information, the DNS server can determine whether the configuration file has been modified. If the configuration file is modified, the DNS server will reload the modified configuration file and perform file resolution on the modified configuration file to obtain the latest configuration information. Finally, the latest configuration information is stored in a global variable for use in the subsequent domain name resolution process.
[0111] By real-time monitoring of configuration file modifications and timely updating of configuration information in global variables, the system can ensure that the latest configuration data is used during domain name resolution, which not only improves the flexibility and adaptability of the DNS server, but also ensures the accuracy and real-time nature of domain name resolution, thereby improving the quality of the entire network service and user experience. At the same time, this mechanism also reduces service interruptions or errors caused by outdated configuration information, and enhances the stability and reliability of the DNS server.
[0112] In an embodiment of the present invention, a domain name request from a client is received; the domain name request includes a domain name; if the domain name has a query field, the return information corresponding to the domain name is determined, and the return information is returned to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier; if the domain name does not have the query field, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result; the resolution result is sent to the client; the client accesses the address corresponding to the domain name based on the resolution result. The embodiment of the present invention sets different rule modes for a domain name, and when the client performs domain name access, the IP corresponding to the domain name request resolution is determined according to different rule modes, so as to achieve the expected balancing strategy and better adapt to different business needs. At the same time, the embodiment of the present invention can realize the domain name query function by setting a query field in the domain name, which solves the limitation that the current domain name service does not support the client to perform domain name rule query to the domain name server. The embodiments of the present invention simplify the scenario requirement configuration of multiple domain names, expand the multi-strategy application scenarios of load balancing, and make the application of load balancing strategies more flexible and changeable for more complex application business scenarios, making the entire storage external entrance unique, making maintenance more convenient, and easier for customers to use.
[0113] The embodiments of the present invention make the use scenarios of advanced load balancing more complete, especially when customers in multiple departments and multiple scenarios need to configure multiple domain names. The configuration process is simplified, and one domain name entrance is maintained, so that the domain name application is more in line with the user's actual business scenario. At the same time, it is also easier to achieve physical isolation of different businesses of customers, so that different departments and different businesses use their own IP pools. On the premise of enriching the product load balancing scenarios, deployment and maintenance are simpler, and the usability and competitiveness of the product are also improved.
[0114] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0115] Reference Figure 4 , shows a structural block diagram of a domain name resolution device provided in an embodiment of the present invention, which may specifically include the following modules:
[0116] The receiving module 401 is used to receive a domain name request from a client; the domain name request includes a domain name;
[0117] A query module 402 is used to determine the return information corresponding to the domain name if the domain name has a query field, and return the return information to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier;
[0118] A rule module 403 is used to determine the address pool corresponding to the domain name according to the rule mode corresponding to the domain name if the query field does not exist in the domain name, and perform domain name resolution based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result;
[0119] The sending module 404 is used to send the resolution result to the client; the client accesses the address corresponding to the domain name based on the resolution result.
[0120] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0121] In addition, an embodiment of the present invention further provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned domain name resolution method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0122] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned domain name resolution method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0123] An embodiment of the present invention further provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the various processes of the domain name resolution method embodiment described above, and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0124] Figure 5 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0125] The electronic device 500 includes but is not limited to: a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, a processor 510, and a power supply 511. Those skilled in the art will appreciate that Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0126] It should be understood that in the embodiment of the present invention, the radio frequency unit 501 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 510 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 501 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 501 can also communicate with the network and other devices through a wireless communication system.
[0127] The electronic device provides users with wireless broadband Internet access through the network module 502, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0128] The audio output unit 503 can convert the audio data received by the RF unit 501 or the network module 502 or stored in the memory 509 into an audio signal and output it as sound. Moreover, the audio output unit 503 can also provide audio output related to a specific function performed by the electronic device 500 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, a receiver, etc.
[0129] The input unit 504 is used to receive audio or video signals. The input unit 504 may include a graphics processor (GPU) 5041 and a microphone 5042. The graphics processor 5041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 506. The image frame processed by the graphics processor 5041 can be stored in the memory 509 (or other storage medium) or sent via the radio frequency unit 501 or the network module 502. The microphone 5042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 501 in the case of a telephone call mode.
[0130] The electronic device 500 also includes at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 5061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 5061 and / or the backlight when the electronic device 500 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 505 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0131] The display unit 506 is used to display information input by the user or information provided to the user. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0132] The user input unit 507 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 507 includes a touch panel 5071 and other input devices 5072. The touch panel 5071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 5071 or near the touch panel 5071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 5071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 510, receives the command sent by the processor 510 and executes it. In addition, the touch panel 5071 can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 5071, the user input unit 507 may also include other input devices 5072. Specifically, other input devices 5072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail here.
[0133] Furthermore, the touch panel 5071 may be overlaid on the display panel 5061. When the touch panel 5071 detects a touch operation on or near it, it transmits the information to the processor 510 to determine the type of the touch event. Then, the processor 510 provides a corresponding visual output on the display panel 5061 according to the type of the touch event. Figure 5 In the figure, the touch panel 5071 and the display panel 5061 are used as two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 5071 and the display panel 5061 can be integrated to realize the input and output functions of the electronic device, which is not limited here.
[0134] The interface unit 508 is an interface for connecting an external device to the electronic device 500. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 508 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 500 or may be used to transmit data between the electronic device 500 and an external device.
[0135] The memory 509 can be used to store software programs and various data. The memory 509 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 509 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0136] The processor 510 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 509 and calling data stored in the memory 509, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 510.
[0137] The electronic device 500 may also include a power source 511 (such as a battery) for supplying power to various components. Preferably, the power source 511 may be logically connected to the processor 510 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0138] In addition, the electronic device 500 includes some functional modules not shown, which will not be described in detail here.
[0139] like Figure 6 As shown, in another embodiment provided by the present invention, a computer-readable storage medium 601 is further provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the domain name resolution method described in the above embodiment.
[0140] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0141] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0142] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0143] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0144] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0145] In the 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.
[0146] 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.
[0147] In addition, each functional unit in each embodiment of the present invention 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.
[0148] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0149] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A domain name resolution method, characterized in that: include: Receive the client's domain name request; The domain name request includes a domain name; If the domain name has a query field, determining return information corresponding to the domain name, and returning the return information to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier; If the query field does not exist in the domain name, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on the preset strategy and the address pool corresponding to the domain name to obtain a resolution result; Sending the analysis result to the client; The client accesses the address corresponding to the domain name based on the resolution result.
2. The method according to claim 1, characterized in that: Before receiving the domain name request from the client, the method further includes: Parsing the configuration file corresponding to the domain name to obtain configuration information; The configuration information is stored in a global variable; the global variable is used to ensure the reading of the configuration information so that the configuration file does not need to be repeatedly parsed.
3. The method according to claim 2, characterized in that The response identifier includes a success identifier and a failure identifier; if the domain name has a query field, determining the return information corresponding to the domain name, and returning the return information to the client, including: If the query field exists in the domain name, determining whether there is configuration information corresponding to the domain name; If there is configuration information corresponding to the domain name, the configuration information corresponding to the domain name and the success identifier are filled into the response information to generate first return information; the response information is information for the domain name request; If the configuration information corresponding to the domain name does not exist, filling the failure identifier into the response information to generate second return information; The first return information or the second return information is returned to the client; wherein the return information is the first return information or the second return information.
4. The method according to claim 2, characterized in that: The rule mode includes an odd-even mode and a keyword matching mode, and the domain name request also includes the address of the client; if the domain name does not have the query field, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result, including: Determine the rule mode corresponding to the domain name and the address pool group corresponding to the domain name according to the configuration information corresponding to the domain name; When the rule mode corresponding to the domain name is the odd-even mode, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name according to the address of the client; When the rule mode corresponding to the domain name is the keyword matching mode, the address pool corresponding to the domain name is determined in the address pool group corresponding to the domain name according to the keyword corresponding to the domain name; the keyword corresponding to the domain name is determined by the configuration information corresponding to the domain name, and one keyword corresponds to one address pool; When the rule pattern corresponding to the domain name does not exist in the configuration information corresponding to the domain name, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name based on the preset strategy; A domain name resolution is performed based on the preset policy and the address pool corresponding to the domain name to obtain the resolution result.
5. The method according to claim 4, characterized in that When the rule mode corresponding to the domain name is the even-odd mode, determining the address pool corresponding to the domain name in the address pool group corresponding to the domain name according to the address of the client includes: When the rule mode corresponding to the domain name is the even-odd mode, the address pool group corresponding to the domain name includes a first address pool and a second address pool; When the last digit of the address of the client is an odd number, the first address pool is determined as the address pool corresponding to the domain name; When the last digit of the address of the client is an even number, the second address pool is determined as the address pool corresponding to the domain name.
6. The method according to claim 2, characterized in that If the query field does not exist in the domain name, the address pool corresponding to the domain name is determined according to the rule mode corresponding to the domain name, and the domain name is resolved based on the preset strategy and the address pool corresponding to the domain name. After obtaining the resolution result, the method further includes: Obtaining time attribute information of a configuration file corresponding to the domain name, and determining whether the configuration file corresponding to the domain name has been modified according to the time attribute information; If the configuration file corresponding to the domain name is modified, reload the modified configuration file, and parse the modified configuration file to obtain configuration information corresponding to the modified configuration file; The configuration information corresponding to the modified configuration file is stored in the global variable.
7. The method according to claim 1, characterized in that One said address allows to be shared among multiple said domain names.
8. A domain name resolution device, characterized in that: include: A receiving module, used for receiving a domain name request from a client; The domain name request includes a domain name; A query module, configured to determine return information corresponding to the domain name if a query field exists in the domain name, and return the return information to the client; the return information includes at least one of an address corresponding to the domain name and a response identifier; A rule module, configured to determine the address pool corresponding to the domain name according to the rule mode corresponding to the domain name if the query field does not exist in the domain name, and perform domain name resolution based on a preset strategy and the address pool corresponding to the domain name to obtain a resolution result; A sending module, used for sending the analysis result to the client; The client accesses the address corresponding to the domain name based on the resolution result.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 7.
