A kind of method and device for selecting local cache DNS
Technical field
The present invention relates to Internet technical field, more particularly to a kind of method and device for selecting local cache DNS.
Background technology
Existing internet service system, in order to lift the access quality of client, typically it can use intelligent scheduling technology will
Access guiding to the node nearest from user of user is serviced.That is network area where location client end, service visitor is chosen
Nearest, the optimal node in network area where the end of family, carries out network access service.The wherein network of accurate judgement client ip
Region is a key problem.
The normal method for realizing intelligent scheduling at present is by DNS subregions analytical capabilities, realizes intelligent scheduling function.
As shown in figure 1,
1st, client accesses IP corresponding to domain name to local cache DNS request.
2nd, local cache DNS (8.8.8.8), will be to CDN intelligent schedulings system if inquiring about local cache without cache contents
The DNS authority server of system, request access the IP of domain name.
3rd, the DNS authority server of CDN intelligent dispatching systems obtains local cache DNS recurrence outlet IP (IP2),
IP storehouses with local determine this IP network area, and carry out intelligent scheduling according to this network area and choose the optimal IP of service
Serviced.
Authoritative server can only obtain IP2, IP3 and IP4 information in Fig. 1, and do intelligently parsing according to IP2.
Because above scheme is to replace client to carry out network area positioning with DNS recurrence outlet IP, so once objective
Family end IP and DNS recurrence export IP not in same network area, can cause position inaccurate, in order to solve this problem, this
Ground caching DNS realizes DNS Extended Protocol functions, that is, allows domain name mapping equipment to transmit the ip addresses of user and taken to authoritative DNS
The function of business device, referred to as edns-client-subnet functions, allow local cache DNS to carry the IP of client and pass to
The DNS authority server of CDN intelligent dispatching systems, DNS authoritative server can be according to the client of local cache DNS carryings
IP carries out the positioning of network area, and carries out the optimal IP of intelligent scheduling selection service according to client ip and serviced.
As shown in Fig. 2
1st, client accesses IP corresponding to domain name to local cache DNS request
2nd, local cache DNS (8.8.8.8), will be to CDN intelligent schedulings system if inquiring about local cache without cache contents
The DNS authority server of system, request access the IP of domain name.The client ip (IP1) that request bag carries to access.
3rd, the DNS authority server of CDN intelligent dispatching systems obtains local cache DNS and carries the client ip of coming
(IP1) network area that local IP storehouses determine this IP, is matched, and intelligent scheduling is carried out according to this network area and chooses service
Optimal IP is serviced.
In practical implementations, public DNS or operator DNS (local cache DNS two types) are true in order to hide
The IP of client and the parsing pressure for reducing local cache DNS, can be by client ip according to certain when carrying client ip
Masked bits, cover into CIDR and be sent to DNS authority server, now when the host ip in CIDR and client ip be not unified
During region, network area position inaccurate can be caused, influence the precision of intelligent scheduling.This patent is by rationally assessing client
The network area relation of host ip in IP and CIDR is held, judges possess the local cache of edns-client-subnet functions
Whether DNS can cause position inaccurate, determine whether client ip can use the local cache dns server specified, and solve
The problem of position inaccurate
CIDR:CIDR, herein means the bit format of subnet mask, such as 192.168.0.0/24,
192.168.1.8/32 etc.
Masked bits:24 in the digit of subnet mask, such as above-mentioned example and 32
For example, if client ip is 192.168.1.8, local cache DNS is 24 according to masked bits, is drawn
CIDR:192.168.1.0/24 the DNS authority server of CDN intelligent dispatching systems obtains 192.168.1.0/24, and uses
192.168.1.0 the network area positioning of client is carried out, once client ip 192.168.1.8 and CIDR main frame occurs
During the difference of IP192.168.1.0 network areas, positioning can be caused abnormal.So need to ensure client ip and CIDR main frame
In the case of IP network region is consistent, this local cache DNS service could be used.
In the prior art, when client selection possesses the local cache DNS of edns-client-subnet functions, do not examine
Consider client ip and CIDR host ip network area uniformity, cause intelligent dispatching system to client ip network area
Judge inaccuracy, influence final service quality.
The content of the invention
In order to solve the above-mentioned technical problem, the invention provides a kind of method and device for selecting local cache DNS.
The invention provides a kind of method for selecting local cache DNS, including:
Determine the combination of local cache DNS IP and network area to the lower masked bits for DNS Extended Protocol functions;
Obtain the masked bits service condition of combination pair of the client ip in different local cache DNS IP and network area
Lower corresponding CIDR host ips;
The network area that client ip and each CIDR host ips belong to together is determined, local cache is selected from the network area
DNS。
Further, the above method also has the characteristics that:
Local cache DNS is selected to include from the network area:There are multiple available local cache DNS in network area
During server, each local cache DNS IP in the network area are obtained, select masked bits institute maximum in corresponding masked bits
Corresponding local cache DNS IP.
Further, the above method also has the characteristics that:
Determine the combination of local cache DNS IP and network area to the lower masked bits bag for DNS Extended Protocol functions
Include:
It is determined that the local cache DNS IP lists for DNS Extended Protocol functions;
Unique test domain name is set for each local cache DNS IP in local cache DNS IP lists, uses test
Domain name sends analysis request to corresponding local cache DNS IP, obtains the daily record of test domain name, is obtained from daily record local slow
The combination of DNS IP and network area is deposited to the lower masked bits for DNS Extended Protocol functions.
Further, the above method also has the characteristics that:
Determine the combination of local cache DNS IP and network area to the lower masked bits bag for DNS Extended Protocol functions
Include:
It is determined that the local cache DNS IP lists for DNS Extended Protocol functions;
Unique test domain name is set for each local cache DNS IP in local cache DNS IP lists, uses test
Domain name sends analysis request, the analysis request and response message of crawl test domain name, from report to corresponding local cache DNS IP
The optsubnet fields extraction masked bits of text.
Further, the above method also has the characteristics that:
Obtain the masked bits service condition of combination pair of the client ip in different local cache DNS IP and network area
Lower corresponding CIDR host ips include:
Client ip is generated into CIDR lattice according to masked bits of the combination of local cache DNS IP and network area under
Formula, CIDR host ips are extracted from CIDR forms.
Further, the above method also has the characteristics that:
When determining the network area that client ip and each CIDR host ips belong to together, client is known according to scheduling system IP storehouses
The network area belonging to IP, and the network area according to belonging to CIDR host ips are known in scheduling system IP storehouses are held, in client
It is when network area belonging to IP with CIDR host ips is identical, this network area is same as client ip and each CIDR host ips
The network area of category.
Present invention also offers a kind of device for selecting local cache DNS, including:
Masked bits determining module, for determining that local cache DNS IP and network area combination extend to the lower DNS that is used for
The masked bits of protocol function;
CIDR host ip determining modules, obtain group of the client ip in different local cache DNS IP and network area
Corresponding CIDR host ips under the masked bits service condition of conjunction pair;
Network area determining module, the network area belonged to together for determining client ip and each CIDR host ips;
Selecting module, for selecting local cache DNS from the network area that network area determining module is selected.
Further, said apparatus also has the characteristics that:
Selecting module, during for there are multiple available local cache dns servers in network area, obtain the network area
Each local cache DNS IP in domain, select the local cache DNS IP corresponding to masked bits maximum in corresponding masked bits.
Further, said apparatus also has the characteristics that:
Masked bits determining module, for determining the combination pair of local cache DNS IP and network area using following methods
It is used for the masked bits of DNS Extended Protocol functions down:
It is determined that the local cache DNS IP lists for DNS Extended Protocol functions;
Unique test domain name is set for each local cache DNS IP in local cache DNS IP lists, uses test
Domain name sends analysis request to corresponding local cache DNS IP, obtains the daily record of test domain name, is obtained from daily record local slow
The combination of DNS IP and network area is deposited to the lower masked bits for DNS Extended Protocol functions.
Further, said apparatus also has the characteristics that:
Masked bits determining module, for determining the combination pair of local cache DNS IP and network area using following methods
It is used for the masked bits of DNS Extended Protocol functions down:It is determined that the local cache DNS IP lists for DNS Extended Protocol functions, are
Each local cache DNS IP set unique test domain name in local cache DNS IP lists, using test domain name to corresponding
Local cache DNS IP send analysis request, crawl test domain name analysis request and response message, from message
Optsubnet fields extract masked bits.
Further, said apparatus also has the characteristics that:
CIDR host ip determining modules, for obtaining client ip in different local cache DNS using following methods
Corresponding CIDR host ips under the masked bits service condition of the combination pair of IP and network area:By client ip according to local
Masked bits generation CIDR form of the combination of caching DNS IP and network area under, extracts CIDR main frames from CIDR forms
IP。
Further, said apparatus also has the characteristics that:
Network area determining module, for being used to determine that client ip and each CIDR host ips belong to together using following methods
Network area:Network area according to belonging to client ip is known in scheduling system IP storehouses, and obtained according to scheduling system IP storehouses
The network area belonging to CIDR host ips is known, when client ip is identical with network area belonging to CIDR host ips, by this net
The network area that network region belongs to together as client ip and each CIDR host ips.
When using the local cache DNS for possessing DNS Extended Protocol functions, with reference to client ip and CIDR host ip
Network area uniformity, ensure that the local cache DNS for possessing DNS Extended Protocol functions can accurately transmit the net of client ip
Network area information.
Brief description of the drawings
The accompanying drawing for forming the part of the present invention is used for providing a further understanding of the present invention, and of the invention is schematic
Embodiment and its illustrate be used for explain the present invention, do not form inappropriate limitation of the present invention.In the accompanying drawings:
Fig. 1 is the schematic diagram of DNS subregions analytical capabilities in the prior art;
Fig. 2 is the schematic diagram of another DNS subregions analytical capabilities in the prior art;
Fig. 3 is the flow chart for the method that local cache DNS is selected in embodiment;
Fig. 4 is the flow chart for the device that local cache DNS is selected in embodiment.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
Part of the embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, ordinary skill people
The every other embodiment that member is obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.Need
It is noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can mutually any group
Close.
Fig. 3 is the flow chart for the method that local cache DNS is selected in embodiment;The method includes:
Step 1, determine that the combination of local cache DNS IP and network area is covered to lower for DNS Extended Protocol functions
Code bit;
Step 2, obtaining the masked bits of combination pair of the client ip in different local cache DNS IP and network area makes
The corresponding CIDR host ips in the case of;
Step 3, the network area that client ip and each CIDR host ips belong to together is determined, this is selected from the network area
Ground caches DNS.
By the method, local cache can be selected in the network area that client ip and each CIDR host ips belong to together
DNS, when using the local cache DNS for possessing DNS Extended Protocol functions, with reference to client ip and CIDR main frame IP network
Region consistency, ensure that the local cache DNS for possessing DNS Extended Protocol functions can accurately transmit the network area of client ip
Domain information.
Wherein,
In step 1, the ip addresses that DNS Extended Protocol functions refer to allow domain name mapping equipment transmission user are to authoritative DNS
The function of server, referred to as edns-client-subnet functions.
In step 1, determine that the combination of local cache DNS IP and network area is used for edns-client-subnet to lower
The masked bits of function include following two modes:
Mode one:
Step 101, it is determined that local cache DNS IP lists for edns-client-subnet functions.
Such as:
Local cache DNS IP lists include:1.1.1.1、2.2.2.2.
Step 102, it is that each local cache DNS IP set unique test domain name in local cache DNS IP lists,
Analysis request is sent to corresponding local cache DNS IP using test domain name, the daily record of test domain name is obtained, is obtained from daily record
The combination of local cache DNS IP and network area is taken to the lower masked bits for edns-client-subnet functions.Specifically
, each network area is provided with a detecting server, and locator and local cache DNS are provided with detecting server
IP lists.After starting locator, detecting server is each test domain name of IP structures one in local cache DNS IP lists
(during structure test domain name, each domain name of testing can be that DNS IP add fixed domain name, it is ensured that each domain name is uniquely corresponding
One local cache DNS), every a period of time, into local cache DNS IP lists, each IP transmissions parsing domain name is advance
The test domain name of structure.
Such as:It is for the detection domain names set of 1.1.1.1 in the local cache DNS IP lists in above-mentioned example
1.1.1.1.test.com, it is that the detection domain name that 2.2.2.2 is set in local cache DNS IP lists in above-mentioned example is
2.2.2.2.test.com.The detection that detection domain name is 1.1.1.1.test.com is sent to 1.1.1.1 every a period of time
Request, the probe requests thereby that detection domain name is 2.2.2.2.test.com is sent to 2.2.2.2.
The content that CIDR fields are obtained from daily record is as follows:
Table 1
Detect domain name |
Network area |
CIDR fields |
1.1.1.1.test.com |
UNICOM Beijing |
192.168.1.1/32 |
1.1.1.1.test.com |
Telecommunications 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 |
Telecommunications Shanghai |
192.168.2.0/24 |
The final combination for obtaining local cache DNS IP and network area is used for edns-client-subnet functions to lower
Masked bits it is as follows:
Table 2
Local cache DNS IP |
Network area |
Masked bits |
1.1.1.1 |
UNICOM Beijing |
32 |
1.1.1.1 |
Telecommunications Shanghai |
24 |
2.2.2.2 |
UNICOM Beijing |
16 |
2.2.2.2 |
Telecommunications Shanghai |
24 |
Mode two:
It is determined that the local cache DNS IP lists for DNS Extended Protocol functions;To be every in local cache DNS IP lists
Individual local cache DNS IP set unique test domain name, are sent and solved to corresponding local cache DNS IP using test domain name
Analysis request, the analysis request and response message of crawl test domain name, masked bits are extracted from the optsubnet fields of message.
The masked bits of combination pair of the client ip in different local cache DNS IP and network area are obtained in step 2
Corresponding CIDR host ips include under service condition:By client ip according to local cache DNS IP and the group of network area
The masked bits generation CIDR forms under are closed, CIDR host ips are extracted from CIDR forms.
Such as:
UNICOM Beijing netizen IP is 172.16.1.1, and telecommunications Shanghai netizen IP is 172.16.2.1.Client ip is
172.16.1.1 masked bits mapping table is as shown in table 2.
Table 3
In step 3, when determining the network area that client ip and each CIDR host ips belong to together, according to scheduling system IP storehouses
Know the network area belonging to client ip, and the network area according to belonging to CIDR host ips are known in scheduling system IP storehouses,
When client ip is identical with network area belonging to CIDR host ips, using this network area as client ip and each CIDR
The network area that host ip belongs to together.
Such as:
The corresponding network area of CIDR host ips is in scheduling system IP storehouses:
Table 4
CIDR host ips |
Network area |
172.16.1.1 |
UNICOM Beijing |
172.16.2.1 |
Shanghai Telecom |
172.16.2.0 |
Shanghai Telecom |
172.16.0.0 |
The U.S. |
Client ip is consistent with the network area of CIDR host ips, illustrates local cache DNS in network area, can be with
Service is provided for client ip;Explanation can not provide service for client ip if inconsistent.
Behind the network area for obtaining client ip, table 5 is obtained:
Behind the network area for obtaining CIDR host ips, table 6 is obtained:
As known from Table 6, UNICOM Beijing netizen 1.1.1.1 is identical available, 2.2.2.2 differ it is unavailable, so UNICOM is northern
1.1.1.1 can be used in capital netizen 172.16.1.1.Telecommunications Shanghai netizen is in 1.1.1.1 and 2.2.2.2 all sames, so telecommunications
1.1.1.1 and 2.2.2.2 can be used in Shanghai netizen 172.16.2.1.
Local cache DNS is selected to include from the network area:Obtain each local cache DNS in the network area
IP, select the local cache DNS IP corresponding to masked bits maximum in corresponding masked bits.It is if each in the network area
Corresponding to local cache DNS IP during masked bits all same, a local cache DNS IP are randomly choosed.Such as telecommunications Shanghai
In this network area, masked bits all same, then a local cache DNS IP can be arbitrarily selected.
Fig. 4 is the structure chart for the device that local cache DNS is selected in embodiment, and this device includes:
Masked bits determining module, for determining that local cache DNS IP and network area combination extend to the lower DNS that is used for
The masked bits of protocol function;
CIDR host ip determining modules, obtain group of the client ip in different local cache DNS IP and network area
Corresponding CIDR host ips under the masked bits service condition of conjunction pair;
Network area determining module, the network area belonged to together for determining client ip and each CIDR host ips;
Selecting module, for selecting local cache DNS from the network area that network area determining module is selected.
Wherein,
When selecting module is used to there are multiple available local cache dns servers in network area, the network area is obtained
In each local cache DNS IP, select the local cache DNS IP corresponding to masked bits maximum in corresponding masked bits.
Masked bits determining module is used to determine local cache DNS IP and network area using following methods one or method two
Combination to the lower masked bits for DNS Extended Protocol functions:
Method one, it is determined that the local cache DNS IP lists for DNS Extended Protocol functions;For local cache DNS IP
Each local cache DNS IP set unique test domain name in list, using test domain name to corresponding local cache DNS
IP sends analysis request, obtains the daily record of test domain name, and the combination of local cache DNS IP and network area is obtained from daily record
To the lower masked bits for DNS Extended Protocol functions.
Method two, it is determined that the local cache DNS IP lists for DNS Extended Protocol functions, are local cache DNS IP
Each local cache DNS IP set unique test domain name in list, using test domain name to corresponding local cache DNS
IP sends analysis request, the analysis request and response message of crawl test domain name, is covered from the optsubnet fields extraction of message
Code bit.
CIDR host ips determining module is used to obtain client ip in different local cache DNS IP using following methods
With CIDR host ips corresponding under the masked bits service condition of the combination pair of network area:By client ip according to local slow
Masked bits generation CIDR form of the combination of DNS IP and network area under is deposited, CIDR host ips are extracted from CIDR forms.
Network area determining module is used to being used to determining client ip using following methods and each CIDR host ips belong to together
Network area:Network area according to belonging to client ip is known in scheduling system IP storehouses, and known according to scheduling system IP storehouses
Network area belonging to CIDR host ips, when client ip is identical with network area belonging to CIDR host ips, by this network
The network area that region belongs to together as client ip and each CIDR host ips.
Descriptions above can combine implementation individually or in a variety of ways, and these variants are all
Within protection scope of the present invention.
One of ordinary skill in the art will appreciate that all or part of step in the above method can be instructed by program
Related hardware is completed, and described program can be stored in computer-readable recording medium, such as read-only storage, disk or CD
Deng.Alternatively, all or part of step of above-described embodiment can also be realized using one or more integrated circuits, accordingly
Ground, each module/unit in above-described embodiment can be realized in the form of hardware, can also use software function module
Form is realized.The present invention is not restricted to the combination of the hardware and software of any particular form.
It should be noted that herein, term " comprising ", "comprising" or its any other variant are intended to non-
It is exclusive to include, so that article or equipment including a series of elements not only include those key elements, but also including
The other element being not expressly set out, or also include for this article or the intrinsic key element of equipment.Not more
In the case of limitation, the key element that is limited by sentence " including ... ", it is not excluded that in article or equipment including the key element
In other identical element also be present.
The above embodiments are merely illustrative of the technical solutions of the present invention and it is unrestricted, reference only to preferred embodiment to this
Invention is described in detail.It will be understood by those within the art that technical scheme can be repaiied
Change or equivalent substitution, without departing from the spirit and scope of technical solution of the present invention, the claim in the present invention all should be covered
Among scope.