Method and device for selecting local cache DNS
Technical Field
The invention relates to the technical field of internet, in particular to a method and a device for selecting a local cache DNS.
Background
In an existing internet service system, in order to improve access quality of a client, an intelligent scheduling technology is generally used to guide access of a user to a node closest to the user for service. Namely, the network area where the client is located is positioned, the nearest and optimal node of the network area where the service client is located is selected, and network access service is carried out. The accurate determination of the network area of the client IP is a core issue.
At present, a common way to realize intelligent scheduling is to realize an intelligent scheduling function through a DNS partition resolution function.
As shown in figure 1 of the drawings, in which,
1. and the client requests to access the IP corresponding to the domain name from the local cache DNS.
2. The local cache DNS (8.8.8.8) queries the local cache if the content is not cached, and requests the DNS authority server of the CDN intelligent scheduling system for access to the IP of the domain name.
3. A DNS authoritative server of the CDN intelligent scheduling system acquires a recursive outlet IP (IP2) of a local cache DNS, matches a local IP library to determine a network region of the IP, and intelligently schedules according to the network region to select the IP with the best service for service.
The authoritative server in FIG. 1 can only obtain the information of IP2, IP3 and IP4, and perform intelligent analysis according to IP 2.
In order to solve the problem, the local cache DNS realizes a DNS extension protocol function, namely a function of allowing a domain name resolution device to transmit an IP address of a user to an authoritative DNS server, namely an DNS-client-subnet function, so that the local cache DNS can carry the IP of the client to transmit to the DNS authoritative server of the intelligent scheduling system, the authoritative server of the DNS can carry the IP of the client to carry out network area positioning according to the IP of the client carried by the local cache DNS, and intelligent scheduling is carried out according to the IP of the client to select the IP with the best service for service.
As shown in figure 2 of the drawings, in which,
1. client requests local cache DNS for accessing IP corresponding to domain name
2. The local cache DNS (8.8.8.8) queries the local cache if the content is not cached, and requests the DNS authority server of the CDN intelligent scheduling system for access to the IP of the domain name. The request packet carries the client IP (IP1) accessed.
3. The DNS authoritative server of the CDN intelligent scheduling system acquires a client IP (IP1) carried by a local cache DNS, matches with a local IP library to determine a network area of the IP, and intelligently schedules according to the network area to select the IP with the best service for service.
In practical implementation, in order to hide an IP of a real client and reduce resolution pressure of a local cache DNS (two types of local cache DNS), a public DNS or an operator DNS (a local cache DNS) may mask a client IP into a CIDR according to a certain mask bit and send the CIDR to a DNS authority server when carrying the client IP, and at this time, when a host IP and the client IP in the CIDR are not in a unified area, inaccurate network area positioning may be caused, and accuracy of intelligent scheduling may be affected. The patent judges whether the local cache DNS with the DNS-client-subnet function can cause inaccurate positioning by reasonably evaluating the network regional relationship between the client IP and the host IP in the CIDR, determines whether the client IP can use the designated local cache DNS server, and solves the problem of inaccurate positioning
CIDR: category-free inter-domain routing, referred to herein as bit-formats of subnet masks, e.g., 192.168.0.0/24, 192.168.1.8/32, etc
Mask bits: the number of bits of the subnet mask, e.g. 24 and 32 in the above example
For example, if the client IP is 192.168.1.8, the local cache DNS gets CIDR as per mask bit of 24: 192.168.1.0/24, a DNS authoritative server of the CDN intelligent scheduling system obtains 192.168.1.0/24 and uses 192.168.1.0 to perform network area location of the client, and location abnormality can be caused once the network areas of the client IP192.168.1.8 and the host IP192.168.1.0 of the CIDR are different. Therefore, the local cache DNS service can be used only when the host IP network areas of the client IP and CIDR need to be guaranteed to be consistent.
In the prior art, when a client selects a local cache DNS with an DNS-client-subnet function, the consistency of the host IP network areas of the client IP and the CIDR is not considered, so that the intelligent scheduling system does not accurately determine the client IP network area, and the final service quality is affected.
Disclosure of Invention
In order to solve the technical problem, the invention provides a method and a device for selecting a local cache DNS.
The invention provides a method for selecting a local cache DNS, which comprises the following steps:
determining a mask bit for a DNS expansion protocol function under a combination pair of a local cache DNS IP and a network region;
acquiring a CIDR host IP corresponding to a client IP under the use condition of mask bits of different local cache DNS IPs and combination pairs of network areas;
and determining a network area where the client IP and each CIDR host IP belong to the same, and selecting a local cache DNS from the network area.
Further, the method also has the following characteristics:
selecting a local caching DNS from the network region comprises: when a plurality of local cache DNS servers are available in the network area, each local cache DNS IP in the network area is obtained, and the local cache DNS IP corresponding to the maximum mask bit in the corresponding mask bits is selected.
Further, the method also has the following characteristics:
determining a combination of a local cache DNS IP and a network region for a mask bit for DNS extension protocol functionality under the pair comprises:
determining a local cache DNS IP list for a DNS extension protocol function;
setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNS IP by using the test domain name, acquiring a log of the test domain name, and acquiring mask bits for a DNS extension protocol function under the combination pair of the local cache DNS IP and a network region from the log.
Further, the method also has the following characteristics:
determining a combination of a local cache DNS IP and a network region for a mask bit for DNS extension protocol functionality under the pair comprises:
determining a local cache DNS IP list for a DNS extension protocol function;
setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNS IP by using the test domain name, capturing the analysis request and a response message of the test domain name, and extracting mask bits from the optsunnet field of the message.
Further, the method also has the following characteristics:
acquiring a CIDR host IP corresponding to a client IP under the mask bit use condition of different local cache DNS IPs and network area combination pairs comprises the following steps:
and generating a CIDR format by the client IP according to the mask bit under the combination pair of the local cache DNS IP and the network area, and extracting the CIDR host IP from the CIDR format.
Further, the method also has the following characteristics:
when the network areas of the client IP and the CIDR host IPs belong to the same network area are determined, the network area of the client IP is obtained according to the IP library of the scheduling system, the network area of the CIDR host IP is obtained according to the IP library of the scheduling system, and when the network areas of the client IP and the CIDR host IP are the same, the network area is used as the network area of the client IP and the CIDR host IP which belong to the same network area.
The invention also provides a device for selecting the local cache DNS, which comprises the following steps:
the mask bit determining module is used for determining mask bits for DNS expansion protocol functions under the combination pair of the local cache DNS IP and the network region;
the CIDR host IP determining module is used for acquiring the corresponding CIDR host IP under the condition that the client IP uses mask bits of different local cache DNS IPs and combination pairs of network areas;
the network area determining module is used for determining the network area where the client IP and each CIDR host IP belong to the same;
and the selection module is used for selecting the local cache DNS from the network area selected by the network area determination module.
Further, the device also has the following characteristics:
and the selecting module is used for acquiring each local cache DNS IP in the network region when a plurality of available local cache DNS servers exist in the network region, and selecting the local cache DNS IP corresponding to the maximum mask bit in the corresponding mask bits.
Further, the device also has the following characteristics:
a mask bit determination module, configured to determine mask bits for DNS extension protocol functions for a combination of a local cache DNS IP and a network region, using the following method:
determining a local cache DNS IP list for a DNS extension protocol function;
setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNS IP by using the test domain name, acquiring a log of the test domain name, and acquiring mask bits for a DNS extension protocol function under the combination pair of the local cache DNS IP and a network region from the log.
Further, the device also has the following characteristics:
a mask bit determination module, configured to determine mask bits for DNS extension protocol functions for a combination of a local cache DNS IP and a network region, using the following method: determining a local cache DNS IP list used for a DNS extension protocol function, setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNS IP by using the test domain name, capturing the analysis request and a response message of the test domain name, and extracting mask bits from an optsunnet field of the message.
Further, the device also has the following characteristics:
the CIDR host IP determining module is used for acquiring the corresponding CIDR host IP under the use condition of mask bits of different combination pairs of local cache DNSIP and network areas of the client IP by using the following method: and generating a CIDR format for the client IP according to the mask bits under the combination pair of the local cache DNS IP and the network area, and extracting the CIDR host IP from the CIDR format.
Further, the device also has the following characteristics:
a network area determining module, configured to determine a network area to which the client IP and each CIDR host IP belong using the following method: and acquiring the network area to which the client IP belongs according to the IP library of the scheduling system, acquiring the network area to which the CIDR host IP belongs according to the IP library of the scheduling system, and taking the network area as the network area to which the client IP and each CIDR host IP belong when the network areas to which the client IP and the CIDR host IP belong are the same.
When the local cache DNS with the DNS extension protocol function is used, the consistency of the network areas of the host IP of the client IP and the CIDR is referred, and the local cache DNS with the DNS extension protocol function can accurately transmit the network area information of the client IP.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate an embodiment of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a diagram of a DNS zone resolution function in the prior art;
FIG. 2 is a schematic diagram of another DNS zone resolution function in the prior art;
FIG. 3 is a flow diagram of a method of selecting a local cache DNS in an embodiment;
fig. 4 is a flowchart of an apparatus for selecting a local cache DNS in an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
FIG. 3 is a flow diagram of a method of selecting a local cache DNS in an embodiment; the method comprises the following steps:
step 1, determining a mask bit for a DNS expansion protocol function under a combination pair of a local cache DNS IP and a network region;
step 2, acquiring a CIDR host IP corresponding to the client IP under the use condition of mask bits of different local cache DNS IPs and combination pairs of network areas;
and 3, determining the network area where the client IP and each CIDR host IP belong to the same, and selecting a local cache DNS from the network area.
By the method, the local cache DNS can be selected in the network area where the client IP and each CIDR host IP belong to the same domain, and when the local cache DNS with the DNS extension protocol function is used, the consistency of the network areas of the client IP and the host IP of the CIDR is referred to, so that the local cache DNS with the DNS extension protocol function can accurately transmit the network area information of the client IP.
Wherein the content of the first and second substances,
in step 1, the DNS extension protocol function refers to a function that allows the domain name resolution device to transmit the ip address of the user to the authoritative DNS server, and is called an DNS-client-subnet function.
In step 1, determining the combination of the local cache DNS IP and the network area for the following mask bits for the DNS-client-subnet function includes the following two ways:
the first method is as follows:
step 101, determining a local cache DNS IP list for the DNS-client-subnet function.
For example:
the local cache DNS IP list includes: 1.1.1.1, 2.2.2.2.
Step 102, setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNS IP by using the test domain name, obtaining a log of the test domain name, and obtaining a mask bit for the edge-client-subnet function of the combination pair of the local cache DNS IP and the network region from the log. Specifically, each network area is provided with a detection server, and a detection program and a local cache DNSIP list are arranged in the detection server. After the detection program is started, the detection server constructs a test domain name for each IP in the local cache DNS IP list (when the test domain name is constructed, each test domain name can be a DNS IP plus a fixed domain name to ensure that each domain name is only corresponding to one local cache DNS), and sends an analysis domain name to each IP in the local cache DNS IP list at intervals of a time period to be the pre-constructed test domain name.
For example: the probing domain name set for 1.1.1.1 in the local caching DNS IP list in the above example is 1.1.1.1.test.com, and the probing domain name set for 2.2.2.2 in the local caching DNS IP list in the above example is 2.2.2.2. test.com. And sending a detection request with a detection domain name of 1.1.1.1.test.com to 1.1.1.1 and sending a detection request with a detection domain name of 2.2.2.2.test.com to 2.2.2.2 at intervals.
The content of the CIDR field obtained from the log is as follows:
TABLE 1
Detecting domain names
|
Network area
|
CIDR field
|
1.1.1.1.test.com
|
Unicom Beijing
|
192.168.1.1/32
|
1.1.1.1.test.com
|
Telecommunication Shanghai
|
192.168.1.0/24
|
2.2.2.2.test.com
|
Unicom Beijing
|
192.168.0.0/16
|
2.2.2.2.test.com
|
Telecommunication Shanghai
|
192.168.2.0/24 |
Finally, the combination of the local cache DNS IP and the network area is obtained as follows for the following mask bits for the DNS-client-subnet function:
TABLE 2
Local cacheStoring DNS IP
|
Network area
|
Masking bit
|
1.1.1.1
|
Unicom Beijing
|
32
|
1.1.1.1
|
Telecommunication Shanghai
|
24
|
2.2.2.2
|
Unicom Beijing
|
16
|
2.2.2.2
|
Telecommunication Shanghai
|
24 |
The second method comprises the following steps:
determining a local cache DNS IP list for a DNS extension protocol function; setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNS IP by using the test domain name, capturing the analysis request and a response message of the test domain name, and extracting mask bits from an optsunnet field of the message.
The step 2 of obtaining the CIDR host IP corresponding to the client IP under the mask bit use condition of different local cache DNS IP and network area combination pairs comprises: and generating a CIDR format for the client IP according to the mask bit under the combination pair of the local cache DNS IP and the network area, and extracting the CIDR host IP from the CIDR format.
For example:
the IP of the Unicom Beijing netizen is 172.16.1.1, and the IP of the telecom Shanghai netizen is 172.16.2.1. The client IP is 172.16.1.1 and the mask bitmap is shown in table 2.
TABLE 3
In step 3, when the network areas of the client IP and the CIDR host IPs belong to the same network area are determined, the network area of the client IP is obtained according to the IP library of the scheduling system, the network area of the CIDR host IP is obtained according to the IP library of the scheduling system, and when the network areas of the client IP and the CIDR host IP are the same, the network area is used as the network area of the client IP and the CIDR host IP which belong to the same network area.
For example:
the network area corresponding to the CIDR host IP in the IP library of the dispatching system is as follows:
TABLE 4
CIDR host IP
|
Network area
|
172.16.1.1
|
Unicom Beijing
|
172.16.2.1
|
Shanghai telecommunication
|
172.16.2.0
|
Shanghai telecommunication
|
172.16.0.0
|
United states of America |
If the network areas of the client IP and the CIDR host IP are consistent, the local cache DNS is in the network area and can provide service for the client IP; if not, the service can not be provided for the client IP.
After the network area of the client IP is obtained, table 5 is obtained:
after the network area of the CIDR host IP is obtained, table 6 is obtained:
as can be seen from Table 6, the Unicom Beijing netizen 1.1.1 is the same and usable, and the Unicom Beijing netizen 2.2.2 is different and unusable, so the Unicom Beijing netizen 172.16.1.1 can use 1.1.1.1. The telecom shanghai netizen is the same at 1.1.1.1 and 2.2.2.2, so telecom shanghai netizen 172.16.2.1 can use 1.1.1.1 and 2.2.2.2.
Selecting a local caching DNS from the network region comprises: and obtaining each local cache DNSIP in the network area, and selecting the local cache DNS IP corresponding to the maximum mask bit in the corresponding mask bits. And if the mask bits corresponding to the local cache DNS IPs in the network area are the same, randomly selecting a local cache DNS IP. For example, in the area of the network in the Shanghai of telecommunications, the mask bits are all the same, and a local cache DNS IP can be arbitrarily selected.
Fig. 4 is a block diagram of an apparatus for selecting a local cache DNS according to an embodiment, the apparatus includes:
the mask bit determining module is used for determining mask bits for DNS expansion protocol functions under the combination pair of the local cache DNS IP and the network region;
the CIDR host IP determining module is used for acquiring the corresponding CIDR host IP under the condition that the client IP uses mask bits of different local cache DNS IPs and combination pairs of network areas;
the network area determining module is used for determining the network area where the client IP and each CIDR host IP belong to the same;
and the selection module is used for selecting the local cache DNS from the network area selected by the network area determination module.
Wherein the content of the first and second substances,
the selection module is used for acquiring each local cache DNS IP in the network region when a plurality of available local cache DNS servers exist in the network region, and selecting the local cache DNS IP corresponding to the maximum mask bit in the corresponding mask bits.
The mask bit determining module is used for determining mask bits for DNS extension protocol functions under the combination pair of the local cache DNS IP and the network region by using the following method one or method two:
the method comprises the steps of determining a local cache DNS IP list for a DNS extension protocol function; setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to the corresponding local cache DNSIP by using the test domain name, acquiring a log of the test domain name, and acquiring a mask bit for a DNS extension protocol function under the combination pair of the local cache DNS IP and a network region from the log.
Determining a local cache DNS IP list used for the DNS extension protocol function, setting a unique test domain name for each local cache DNS IP in the local cache DNS IP list, sending an analysis request to a corresponding local cache DNSIP by using the test domain name, capturing the analysis request and a response message of the test domain name, and extracting mask bits from an optsunnet field of the message.
The CIDR host IP determining module is used for acquiring the corresponding CIDR host IP of the client IP under the mask bit use condition of different local cache DNS IP and network area combination pairs by using the following method: and generating a CIDR format by the client IP according to the mask bit under the combination pair of the local cache DNS IP and the network area, and extracting the CIDR host IP from the CIDR format.
The network area determining module is used for determining the network area of the client IP and each CIDR host IP which belong to the same domain by using the following method: and acquiring the network area to which the client IP belongs according to the IP library of the scheduling system, acquiring the network area to which the CIDR host IP belongs according to the IP library of the scheduling system, and taking the network area as the network area to which the client IP and each CIDR host IP belong when the network areas to which the client IP and the CIDR host IP belong are the same.
The above-described aspects may be implemented individually or in various combinations, and such variations are within the scope of the present invention.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by associated hardware through a program, and the program may be stored in a computer readable storage medium, such as a read-only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the foregoing embodiments may also be implemented by using one or more integrated circuits, and accordingly, each module/unit in the foregoing embodiments may be implemented in the form of hardware, and may also be implemented in the form of a software functional module. The present invention is not limited to any specific form of combination of hardware and software.
It is noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an article or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of additional like elements in the article or device in which the element is included.
The above embodiments are merely to illustrate the technical solutions of the present invention and not to limit the present invention, and the present invention has been described in detail with reference to the preferred embodiments. It will be understood by those skilled in the art that various modifications and equivalent arrangements may be made without departing from the spirit and scope of the present invention and it should be understood that the present invention is to be covered by the appended claims.