Domain name resolution method and device, domain name server and computer program product
By implementing a domain name resolution method on the domain name server, the target test environment is determined based on the source network address, and the network address is determined based on the configuration information of the test environment, the problem of container domain name resolution in the kubernetes test environment is solved, and domain name resolution is realized effectiveness and independence.
Patent Information
- Application Number
- CN202510027947.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-08
- Publication Date
- 2025-02-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In a test environment deployed using kubernetes technology, the container cannot adopt the host network mode, resulting in the host configuration file being unable to be mounted into the container, and the container's domain name access request cannot perform valid domain name resolution.
By implementing a domain name resolution method on the domain name server, in response to the domain name access request generated by the host container, the source network address and access domain name are obtained, the target test environment is determined based on the source network address, and the resolution network is determined based on the configuration information of the test environment. address.
It realizes accurate resolution of domain name access requests generated by containers in the test environment deployed by kubernetes technology, avoids dependence on host configuration files, and ensures the effectiveness of domain name resolution.
Smart Images

Figure CN119484478A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of network technology, and in particular, relates to a domain name resolution method, device, domain name server and computer program product. Background Art
[0002] In order to meet the needs of different business development of enterprises, the network service system of enterprises usually manages multiple test environments at the same time to perform daily tests on various businesses. Different test environments are independent of each other, and each test environment has its own set of basic services. Business services of hosts in the test environment usually need to access these basic services through domain names, for example: accessing the database through the domain name "dev.xiaoying.work". However, for different test environments, different resolution addresses often need to be resolved. In order to meet the domain name resolution requirements of different test environments, the commonly used method is to modify the host configuration file on all hosts in each test environment and write domain name conversion rules. However, for the test environment deployed using kubernetes (k8s) technology, since the container cannot use the host network mode, the host configuration file cannot be mounted to the container, and the domain name access request of the container cannot be resolved according to the host configuration file, resulting in this domain name resolution method cannot be effectively implemented. Summary of the invention
[0003] The embodiments of the present application provide a domain name resolution method, device, domain name server and computer program product, which can implement domain name resolution in a test environment deployed using k8s technology.
[0004] A first aspect of an embodiment of the present application provides a domain name resolution method, which is applied to a domain name server. The domain name resolution method includes: in response to a domain name access request generated by a container within a host, obtaining a source network address and an access domain name of the domain name access request; determining a target test environment to which the host belongs based on the source network address; determining a resolution network address of the access domain name based on first configuration information corresponding to the target test environment, wherein the first configuration information corresponding to the target test environment represents a mapping relationship between the domain name and the network address.
[0005] In some embodiments of the first aspect, determining the target test environment to which the host belongs based on the source network address includes: obtaining an address list of each preset test environment in multiple preset test environments; and determining the preset test environment with the source network address in the address list as the target test environment.
[0006] In some implementations of the first aspect, if the source network address does not exist in the address list of all preset test environments, the domain name resolution method further includes: matching the source network address with each container network segment, wherein the container network segment is a network segment assigned to each container associated with the domain name server; and determining the preset test environment to which the container corresponding to the successfully matched container network segment belongs as the target test environment.
[0007] In some embodiments of the first aspect, before determining the resolved network address of the access domain name according to the first configuration information corresponding to the target test environment, the domain name resolution method also includes: determining a query keyword according to the environment identifier of the target test environment and the access domain name; if there is a result value corresponding to the query keyword in the cache information of the domain name server, determining the result value as the resolved network address.
[0008] In some embodiments of the first aspect, before determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment, the domain name resolution method further includes: obtaining second configuration information from a database, the database being used to store information written by a user device; updating the first configuration information cached by the domain name server according to the second configuration information; determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment includes: determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment cached by the domain name server.
[0009] In some embodiments of the first aspect, if the mapping relationship of the access domain name does not exist in the first configuration information corresponding to the target test environment, the domain name resolution method also includes: uploading the domain name access request to the parent server of the domain name server; and receiving the resolved network address of the access domain name fed back by the parent server.
[0010] In some implementations of the first aspect, obtaining the source network address and access domain name of the domain name access request includes: performing field parsing on messages of the domain name access request and the access domain name to obtain the source network address and the access domain name.
[0011] A second aspect of an embodiment of the present application provides a domain name resolution device, which is configured on a domain name server, and the domain name resolution device includes: a request response unit, used to respond to a domain name access request of a host, and obtain a source network address and an access domain name of the domain name access request; a test environment determination unit, used to determine a target test environment corresponding to the source network address in multiple preset test environments, each of the multiple preset test environments corresponds to a first configuration information, and the first configuration information records a mapping relationship between the domain name and the network address; a domain name resolution unit, used to determine the resolution network address of the access domain name according to the first configuration information corresponding to the target test environment.
[0012] A third aspect of an embodiment of the present application provides a domain name server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned domain name resolution method when executing the computer program.
[0013] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned domain name resolution method are implemented.
[0014] A fifth aspect of the embodiments of the present application provides a computer program product, which enables the above-mentioned domain name resolution method to be executed when the computer program is run.
[0015] In an embodiment of the present application, the domain name server responds to a domain name access request generated by a container in a host, determines the target test environment to which the host belongs according to the source network address of the domain name access request, and determines the resolved network address of the access domain name of the domain name access request according to the mapping relationship between the domain name and the network address recorded in the first configuration information corresponding to the target test environment. In this way, the domain name access request generated by the container does not need to be resolved according to the host configuration file on the host, but is accurately mapped to the resolved network address by the domain name server that takes over the container according to the test environment to which the host belongs, and domain name resolution can be achieved in a test environment deployed using k8s technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0017] Figure 1 It is a schematic diagram of an implementation flow of a domain name resolution method provided in an embodiment of the present application; Figure 2 It is a schematic diagram of a TCP message provided in an embodiment of the present application; Figure 3 It is a schematic diagram of a UDP message provided in an embodiment of the present application; Figure 4 It is a structural diagram of a network service system provided by an embodiment of the present application; Figure 5 It is a schematic diagram of a specific process of domain name resolution provided by an embodiment of the present application; Figure 6 It is a structural diagram of a domain name resolution device provided in an embodiment of the present application; Figure 7 It is a schematic diagram of the structure of the domain name server provided in the embodiment of the present application. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work are protected by the present application.
[0019] For the test environment deployed using k8s technology, since the container cannot adopt the host network mode, the host configuration file cannot be mounted into the container, and the domain name access request of the container cannot be resolved according to the host configuration file, resulting in the existing domain name resolution method cannot be effectively implemented.
[0020] In view of this, the present application proposes a domain name resolution method, so that the domain name access request generated by the container does not need to be resolved according to the host configuration file on the host, but is accurately mapped to the resolution network address by the domain name server that takes over the container according to the test environment to which the host belongs, and domain name resolution can be realized in a test environment deployed using k8s technology.
[0021] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0022] For ease of understanding, some terms involved in this application are first explained: 1. Domain Name Server (DNS) is a device in the network service system that is used to communicate with the host and convert the domain name (domain name) and the corresponding network address (IP address).
[0023] 2. Internet Data Center (IDC), also known as a computer room, is equipped with one or more hosts.
[0024] 3. Test environment refers to the platform for testing and running software and hardware. Each test environment can correspond to a cluster, and a cluster can contain one or more hosts.
[0025] 4. Host is a network communication device in the network service system, which can refer to smart devices such as computers and mobile phones. Each host can contain one or more containers.
[0026] 5. A container is a software unit formed by packaging an application and its dependencies together. In the implementation of this application, it may refer to a k8s container using k8s technology. Each container can be used to run a service instance of a business service. A service instance can be a program, a process, etc.
[0027] Figure 1 A schematic diagram of the implementation flow of a domain name resolution method provided in an embodiment of the present application is shown, and the method can be applied to a domain name server.
[0028] Specifically, the above domain name resolution method may include the following steps S101 to S103.
[0029] Step S101, in response to a domain name access request generated by a container in a host, obtain a source network address and an access domain name of the domain name access request.
[0030] Specifically, when the business service running in the container of the host needs to access a specific basic service (such as a database, message queue service, etc.), the container in the host can generate a domain name access request and send the domain name access request to the domain name server communicating with the host. In response to the domain name access request, the domain name server can parse the domain name access request to obtain the source network address of the domain name access request and the access domain name.
[0031] The source network address refers to the network address of the host from which the domain name access request comes. The access domain name refers to the domain name that the container expects to access, that is, the domain name used to access a specific basic service.
[0032] Step S102, determining the target test environment to which the host belongs according to the source network address.
[0033] In an embodiment of the present application, the network service system may be configured with one or more preset test environments, each of which corresponds to a first configuration information. The first configuration information may characterize the mapping relationship between the domain name and the network address. In other words, each preset test environment may correspond to a set of conversion rules between the domain name and the network address.
[0034] The first configuration information between different preset test environments can be the same or different. For example, the first configuration information of preset test environment A and preset test environment B is the same, and the network address converted from the domain name "dev.xiaoying.work" is 10.80.77.20; the first configuration information of preset test environment A and preset test environment C is different. For preset test environment C, the network address converted from the domain name "dev.xiaoying.work" is 10.80.77.90. In order to ensure the accuracy of domain name resolution, the target test environment to which the host belongs can be determined based on the source network address in multiple preset test environments.
[0035] Step S103: Determine the resolved network address of the access domain name according to the first configuration information corresponding to the target test environment.
[0036] The resolved network address is the network address of the basic service accessed by the domain name access request. According to the mapping relationship between the domain name and the network address represented by the first configuration information corresponding to the target test environment, the network address mapped to the access domain name can be determined, and the network address is the resolved network address.
[0037] In an embodiment of the present application, the domain name server responds to a domain name access request generated by a container in a host, determines the target test environment to which the host belongs according to the source network address of the domain name access request, and determines the resolved network address of the access domain name of the domain name access request according to the mapping relationship between the domain name and the network address recorded in the first configuration information corresponding to the target test environment. In this way, the domain name access request generated by the container does not need to be resolved according to the host configuration file on the host, but is accurately mapped to the resolved network address by the domain name server that takes over the container according to the test environment to which the host belongs, and domain name resolution can be achieved in a test environment deployed using k8s technology.
[0038] In some implementations of the present application, obtaining the source network address and access domain name of the domain name access request may include: performing field parsing on the domain name access request and access domain name messages to obtain the source network address and access domain name.
[0039] Specifically, the above message may refer to a Transmission Control Protocol (TCP) message or a User Datagram Protocol (UDP) message. Figure 2 The TCP message diagram and Figure 3As shown in the UDP message diagram, since the host and the domain name server use network communication, the network protocol used in the fourth layer (transport layer) of the seventh layer (application layer) in the Open Systems Interconnection (OSI) model is TCP / UDP. Whether it is a TCP protocol message or a UDP protocol message, the message header field contains the source port number, which can be used to determine the source network address and port. The access domain name is carried in the data part of the message. Therefore, in response to the domain name access request, the domain name server can obtain the source network address and access domain name in the socket by field resolution.
[0040] In some embodiments of the present application, determining the target test environment to which the host belongs based on the source network address may include: obtaining an address list of each preset test environment in multiple preset test environments; and determining the preset test environment with the source network address in the address list as the target test environment.
[0041] Specifically, an address list may be maintained for each preset test environment. The address list stores the network addresses of all hosts in the corresponding preset test environment. For any preset test environment, if the source network address exists in the address list, it means that the host from which the domain name access request comes belongs to the preset test environment, and the preset test environment may be determined as the target test environment.
[0042] Accordingly, in some embodiments of the present application, if the source network address does not exist in the address list of all preset test environments, the domain name resolution method also includes: matching the source network address with each container network segment, wherein the container network segment is the network segment assigned to each container associated with the domain name server; and determining the preset test environment to which the container corresponding to the successfully matched container network segment belongs as the target test environment.
[0043] Specifically, as mentioned above, each business service can run in a container, and each container can be assigned a container network segment according to Classless Inter-Domain Routing (CIDR), and the container network segments of different containers are different. For the domain name server, the container network segments assigned to the containers contained in all hosts communicating with it are a priori information. Match the source network address with the container network segment of each container. If the source network address successfully matches a container network segment, it means that the source network address belongs to the container network segment of the container, and the domain name access request comes from the container. At this time, the preset test environment to which the container belongs can be determined as the target test environment.
[0044] In order to improve timeliness and reliability, in some embodiments of the present application, before determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment, the domain name resolution method may also include: determining the query keyword according to the environment identifier of the target test environment and the accessed domain name, and if there is a result value corresponding to the query keyword in the cache information of the domain name server, determining the result value as the resolved network address.
[0045] The above-mentioned environment identifier may be information such as an identification number, a name, etc. that can uniquely identify the target test environment.
[0046] As mentioned above, the first configuration information corresponding to different preset test environments may be different. When the relevant technology uses the access domain name as the keyword to store cache information, query errors are very likely to occur. For example, the host of the preset test environment A queries the domain name "dev.xiaoying.work", and the resolved network address returned is 10.90.78.135. When stored as cache information, the keyword key is "dev.xiaoying.work" and the result value value is 10.90.78.135. When the host of the preset test environment C queries the same domain name "dev.xiaoying.work", the accurate resolved network address should be 10.90.78.138, but the result value in the cache information is 10.90.78.135. At this time, the domain name server directly returns the result value 10.90.78.135 in the cache information to the host of the preset test environment C, causing a serious problem of returning erroneous data.
[0047] In order to avoid this problem, in some embodiments of the present application, the keyword of the cache information can be generated based on the environment identifier and the access domain name. For example, the keyword of the cache information can be obtained by concatenating the environment identifier and the access domain name. Accordingly, when resolving the domain name, the query keyword can be determined based on the environment identifier and the access domain name of the target test environment. If there is a result value corresponding to the query keyword in the cache information of the domain name server, the result value is determined as the resolved network address.
[0048] For example, host 10.90.78.136 requests the domain name "dev.xiaoying.work". The domain name server finds that the environment identifier of the target test environment to which 10.90.78.136 belongs is 1. The query keyword key obtained by concatenation is "1#dev.xiaoying.work". At this time, the result value of the cache information queried according to the query keyword is 10.90.78.135 and returned to the host. Since the query keyword carries the environment identifier of the target test environment, its result value complies with the conversion rules of the target test environment, thus ensuring the reliability of domain name resolution.
[0049] It is understandable that when querying using cache information, if there is a result value corresponding to the query keyword in the cache information, the backend plug-in does not need to determine the resolution network address according to the first configuration information, which can reduce the load of the backend plug-in and improve query efficiency.
[0050] Correspondingly, if there is no result value corresponding to the query keyword in the cache information of the domain name server, the resolved network address of the accessed domain name can be determined according to the first configuration information corresponding to the target test environment.
[0051] In order to further ensure the reliability and timeliness of domain name resolution, before determining the resolved network address of the accessed domain name based on the first configuration information corresponding to the target test environment, the domain name resolution method may also include: obtaining second configuration information from a database; and updating the first configuration information cached by the domain name server based on the second configuration information.
[0052] The database is used to store information written by the user device. Figure 4 In the structural diagram of the network service system shown in FIG. 1 , the user can write the latest configuration information to the database through the user device. The domain name server can periodically (the frequency can be selected by the user, for example, 3 seconds / time) obtain the latest second configuration information from the database. In this way, the configuration information updated by the user can take effect in seconds.
[0053] If the first configuration information and the second configuration information cached by the domain name server are different, the domain name server can update the first configuration information cached by itself so that the updated first configuration information is consistent with the second configuration information. If the first configuration information and the second configuration information cached by the domain name server are the same, the original first configuration information can be retained.
[0054] Specifically, in some implementations of the present application, the hash value of the configuration information may be calculated to check whether the first configuration information and the second configuration information are different. If the hash values are inconsistent, the first configuration information cached by the server may be updated.
[0055] Correspondingly, determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment may include: determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment cached by the domain name server.
[0056] That is to say, the resolution network address of the accessed domain name can be determined based on the first configuration information cached locally in the domain name server. In this way, all query operations are implemented in the local memory of the domain name server, which can ensure the timeliness of domain name resolution compared to real-time access to an external database.
[0057] In some embodiments of the present application, the domain name server can implement a two-layer cache architecture design, where the first layer of cache uses cache information to find out whether there is a result value corresponding to the query keyword, and if the result value is found, the result value is determined as the resolved network address. If the result value is not found, the second layer of cache uses the first configuration information of the local cache of the domain name server to determine the resolved network address of the accessed domain name, so that most domain name query requests can be hit by the cache information, reducing the number of requests processed by the back-end plug-in by an order of magnitude, and all query operations of the back-end plug-in are in the local memory of the domain name server, which is also more efficient.
[0058] In other embodiments of the present application, if there is no mapping relationship for accessing the domain name in the first configuration information corresponding to the target test environment, the domain name resolution method may further include: uploading the domain name access request to an upper-level server of the domain name server, and receiving the resolved network address of the access domain name fed back by the upper-level server.
[0059] Specifically, if the mapping relationship of the access domain name does not exist in the first configuration information corresponding to the target test environment, it means that the domain name server cannot map the access domain name to a specific network address according to the first configuration information. At this time, it is necessary to upload the domain name access request to the parent server of the domain name server and receive the resolved network address of the access domain name fed back by the parent server. Figure 4 As shown, the upper server can be a root domain name server of the domain name server, which is used to manage all domain name servers of the network service system. The upper server can query the target test environment to which the host belongs and determine the resolution network address according to the network address allocation of the entire network service system.
[0060] Specifically, in some embodiments of the present application, the domain name server may support A record query and AAA record query. Among them, the A record is used to resolve the access domain name to the IPV4 network address, and the AAAA record is used to resolve the access domain name to the IPV6 network address. For these two queries, when determining the resolved network address of the access domain name according to the first configuration information corresponding to the target test environment, the lookupStaticHost function can be called to implement it. The lookupStaticHost function can call the IpToEnvId method to query the environment identifier of the target test environment where the host is located according to the source network address. If the environment identifier is queried, the mapping relationship between the domain name and the network address in the first configuration information corresponding to the environment identifier can be queried, and the resolved network address mapped to the access domain name is returned. If the environment identifier is not queried, the query failure is returned, and the upper server of the domain name server traverses the network address allocation list cidrenvidmap of the entire network service system, matches the source network address with each container network segment, and determines the environment identifier of the target test environment, so that the resolved network address mapped to the access domain name can be returned.
[0061] In some implementations of the present application, after determining the resolved network address of the accessed domain name, the method may further include: feeding back the resolved network address to the host.
[0062] In some embodiments of the present application, after determining the resolved network address of the accessed domain name, it may also include: storing the query keyword and the resolved network address as cache information, so that the next time the host or other hosts in the same test environment query the same domain name, the correct resolved network address can be fed back based on the cache information.
[0063] In some embodiments of the present application, a domain name server may be configured with multiple processing nodes. After the domain name server receives a domain name access request, the domain name server may select a target processing node to respond to the domain name access request based on the current load of each processing node, and the target processing node determines the resolution network address of the access domain name according to the domain name resolution method described above. In this way, it is possible to avoid the same processing node from having to process too many domain name access requests, thereby achieving load balancing.
[0064] In some embodiments of the present application, the domain name resolution method also includes: responding to a domain name query request, obtaining a source network address and a network address to be queried of the domain name query request, determining a target test environment to which the host belongs based on the source network address, and determining a target domain name of the network address to be queried based on first configuration information corresponding to the target test environment.
[0065] Specifically, in some implementations of the present application, the domain name server may support reverse DNS query (PTR) to convert the network address to be queried into a target domain name.
[0066] In some embodiments of the present application, the above-mentioned domain name server may refer to CoreDNS. Since CoreDNS supports the function of inserting custom plug-ins, the above-mentioned domain name resolution method may be encapsulated as a plug-in xyhosts and inserted into the plug-in list of CoreDNS.
[0067] For ease of understanding, Figure 5 The complete process of domain name resolution implemented by the network service system is shown.
[0068] S1. The user writes configuration information through the user device and saves it in the database as the second configuration information; S2. The domain name server periodically obtains the second configuration information, the address list of each preset test environment, and the container network segment assigned to each container associated with the domain name server from the database; S3. The domain name server checks whether the cached first configuration information is consistent with the second configuration information by calculating the hash value, and updates the first configuration information if they are inconsistent; S4. When the domain name server receives a domain name access request, the xyhosts plug-in first determines whether the source network address of the domain name access request is in the address list or container network segment; S5. If the source network address of the domain name access request is not in the address list or the container network segment, skip to the next plug-in, and the next plug-in can upload the domain name access request to the parent server of the domain name server, and receive the resolved network address of the access domain name fed back by the parent server; S6. If the source network address of the domain name access request is in the address list or the container network segment, query and resolve the network address from the cache information; S7. If there is a result value corresponding to the query keyword in the cache information of the domain name server, determine the result value as the resolved network address; S8. If the result value corresponding to the query keyword does not exist in the cache information of the domain name server, determine the resolution network address of the access domain name according to the first configuration information corresponding to the target test environment; S9, feedback the resolved network address; S10: Store the query keyword and the resolved network address as cache information.
[0069] It should be noted that, for the sake of simplicity of description, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited to the described order of actions, because according to the present application, certain steps can be performed in other orders.
[0070] like Figure 6 The diagram is a schematic diagram of the structure of a domain name resolution device 600 provided in an embodiment of the present application, wherein the domain name resolution device 600 is configured on a domain name server.
[0071] Specifically, the domain name resolution device 600 may include: The request response unit 601 is used to respond to the domain name access request of the host and obtain the source network address and access domain name of the domain name access request; A test environment determination unit 602 is used to determine a target test environment corresponding to the source network address in a plurality of preset test environments, each of the plurality of preset test environments corresponding to a first configuration information, the first configuration information recording a mapping relationship between a domain name and a network address; The domain name resolution unit 603 is used to determine the resolution network address of the access domain name according to the first configuration information corresponding to the target test environment.
[0072] In some embodiments of the present application, the test environment determination unit 602 may be specifically used to: obtain an address list of each preset test environment in a plurality of preset test environments; and determine the preset test environment having the source network address in the address list as the target test environment.
[0073] In some embodiments of the present application, if the source network address does not exist in the address list of all preset test environments, the test environment determination unit 602 can be specifically used to: match the source network address with each container network segment, wherein the container network segment is the network segment assigned to each container associated with the domain name server; and determine the preset test environment to which the container corresponding to the successfully matched container network segment belongs as the target test environment.
[0074] In some embodiments of the present application, before determining the resolved network address of the access domain name according to the first configuration information corresponding to the target test environment, the domain name resolution unit 603 can be specifically used to: determine the query keyword according to the environment identifier of the target test environment and the access domain name; if there is a result value corresponding to the query keyword in the cache information of the domain name server, determine the result value as the resolved network address.
[0075] In some embodiments of the present application, before determining the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment, the domain name resolution unit 603 may be specifically used to: obtain second configuration information from a database, the database being used to store information written by a user device; and update the first configuration information cached by the domain name server according to the second configuration information; the domain name resolution unit 603 may be specifically used to: determine the resolved network address of the accessed domain name according to the first configuration information corresponding to the target test environment cached by the domain name server.
[0076] In some embodiments of the present application, if the mapping relationship of the access domain name does not exist in the first configuration information corresponding to the target test environment, the domain name resolution unit 603 can be specifically used to: upload the domain name access request to the parent server of the domain name server; and receive the resolved network address of the access domain name fed back by the parent server.
[0077] In some implementations of the present application, the request response unit 601 may be specifically used to: perform field parsing on the domain name access request and the access domain name message to obtain the source network address and the access domain name.
[0078] It should be noted that, for the convenience and simplicity of description, the specific working process of the above-mentioned domain name resolution device 600 can be referred to Figures 1 to 5 The corresponding process of the method will not be repeated here.
[0079] like Figure 7 , which is a schematic diagram of a domain name server provided in an embodiment of the present application. Specifically, the domain name server 7 may include: a processor 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70, such as a domain name resolution program. When the processor 70 executes the computer program 72, the steps in the above-mentioned domain name resolution method embodiments are implemented, such as Figure 1 Alternatively, when the processor 70 executes the computer program 72, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 6 The functions of the request response unit 601, the test environment determination unit 602 and the domain name resolution unit 603 are shown.
[0080] The computer program may be divided into one or more modules / units, which are stored in the memory 71 and executed by the processor 70 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the domain name server.
[0081] For example, the computer program can be divided into: a request response unit, a test environment determination unit, and a domain name resolution unit. The specific functions of each unit are as follows: a request response unit, used to respond to a domain name access request of a host, and obtain a source network address and an access domain name of the domain name access request; a test environment determination unit, used to determine a target test environment corresponding to the source network address in a plurality of preset test environments, wherein each of the plurality of preset test environments corresponds to a first configuration information, and the first configuration information records a mapping relationship between a domain name and a network address; a domain name resolution unit, used to determine the resolution network address of the access domain name according to the first configuration information corresponding to the target test environment.
[0082] The domain name server may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will appreciate that Figure 7 It is only an example of a domain name server and does not constitute a limitation of the domain name server. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the domain name server may also include input and output devices, network access devices, buses, etc.
[0083] The processor 70 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0084] The memory 71 may be an internal storage unit of the domain name server, such as a hard disk or memory of the domain name server. The memory 71 may also be an external storage device of the domain name server, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the domain name server. Furthermore, the memory 71 may include both an internal storage unit and an external storage device of the domain name server. The memory 71 is used to store the computer program and other programs and data required by the domain name server. The memory 71 may also be used to temporarily store data that has been output or is to be output.
[0085] It should be noted that, for the convenience and brevity of description, the structure of the above-mentioned domain name server can also refer to the specific description of the structure in the method embodiment, which will not be repeated here.
[0086] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0087] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0088] 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 herein 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 this application.
[0089] In the embodiments provided in the present application, it should be understood that the disclosed device / domain name server and method can be implemented in other ways. For example, the device / domain name server embodiments described above are merely schematic. For example, the division of the modules or 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.
[0090] 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.
[0091] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0092] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0093] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A domain name resolution method, characterized in that: Applied to a domain name server, the domain name resolution method includes: In response to a domain name access request generated by a container in a host, obtaining a source network address and an access domain name of the domain name access request; Determine the target test environment to which the host belongs according to the source network address; The resolved network address of the accessed domain name is determined according to the first configuration information corresponding to the target test environment, wherein the first configuration information corresponding to the target test environment represents a mapping relationship between a domain name and a network address.
2. The domain name resolution method according to claim 1, characterized in that: Determining the target test environment to which the host belongs according to the source network address includes: Obtain an address list of each preset test environment in a plurality of preset test environments; The preset test environment of the source network address in the address list is determined as the target test environment.
3. The domain name resolution method according to claim 2, characterized in that: If the source network address does not exist in the address lists of all preset test environments, the domain name resolution method further includes: Matching the source network address with each container network segment, wherein the container network segment is a network segment allocated to each container associated with the domain name server; The preset test environment to which the container corresponding to the successfully matched container network segment belongs is determined as the target test environment.
4. The domain name resolution method according to claim 1, characterized in that: Before determining the resolved network address of the access domain name according to the first configuration information corresponding to the target test environment, the domain name resolution method further includes: Determine a query keyword according to the environment identifier of the target test environment and the access domain name; If a result value corresponding to the query keyword exists in the cache information of the domain name server, the result value is determined as the resolved network address.
5. The domain name resolution method according to any one of claims 1 to 4, characterized in that: Before determining the resolved network address of the access domain name according to the first configuration information corresponding to the target test environment, the domain name resolution method further includes: Acquire second configuration information from a database, where the database is used to store information written by a user device; updating the first configuration information cached by the domain name server according to the second configuration information; The determining, according to the first configuration information corresponding to the target test environment, the resolved network address of the access domain name includes: The resolved network address of the access domain name is determined according to the first configuration information corresponding to the target test environment cached by the domain name server.
6. The domain name resolution method according to any one of claims 1 to 4, characterized in that: If the mapping relationship of the access domain name does not exist in the first configuration information corresponding to the target test environment, the domain name resolution method further includes: Uploading the domain name access request to the upper-level server of the domain name server; Receive the resolved network address of the access domain name fed back by the upper-level server.
7. The domain name resolution method according to any one of claims 1 to 4, characterized in that: The obtaining of the source network address and the access domain name of the domain name access request includes: Field parsing is performed on the domain name access request and the access domain name message to obtain the source network address and the access domain name.
8. A domain name resolution device, characterized in that: Configured in a domain name server, the domain name resolution device includes: A request response unit, configured to respond to a domain name access request from a host and obtain a source network address and an access domain name of the domain name access request; A test environment determination unit, used to determine a target test environment corresponding to the source network address in a plurality of preset test environments, each of the plurality of preset test environments corresponding to a first configuration information, the first configuration information recording a mapping relationship between a domain name and a network address; The domain name resolution unit is used to determine the resolution network address of the access domain name according to the first configuration information corresponding to the target test environment.
9. A domain name server, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the domain name resolution method according to any one of claims 1 to 7 are implemented.
10. A computer program product, characterized in that It comprises a computer program, and when the computer program is executed, the domain name resolution method according to any one of claims 1 to 7 is executed.
Citation Information
Patent Citations
Buffer processing method and device for domain name resolution
CN104935683A
DNS analysis method and system based on test environment standing book
CN111447299A
Test resource access method and device, electronic equipment and storage medium
CN114070883A
Test environment construction method and device, electronic equipment and storage medium
CN115422044A
Domain name resolution method and device
CN116112466A