Embodiment
Long in order to solve in the prior art local dns parsing time, and can not define the problem of complicated local dns parses policy, the invention provides a kind of dns resolution method and device, that is, in Intranet, realize the technical scheme of this machine dns resolution.This technical scheme is filtered this machine dns resolution request package by the network data filtering module, and the request msg that will meet this machine dns resolution strategy is forwarded to this machine dns resolution module.This machine dns resolution module directly writes back operating system with analysis result after receiving the dns resolution request msg of forwarding, finishes the flow process of dns resolution.If the DNS request msg does not meet this machine dns resolution strategy, then the network data filtering module directly sends to these data operating system bottom module, thereby improves the resolution speed that non-local dns is resolved.Below in conjunction with accompanying drawing and embodiment, the present invention is further elaborated.Should be appreciated that specific embodiment described herein only in order to explain the present invention, does not limit the present invention.
Method embodiment
According to embodiments of the invention, a kind of dns resolution method is provided, Fig. 3 is the flow chart of the dns resolution method of the embodiment of the invention, as shown in Figure 3, comprises following processing according to the dns resolution method of the embodiment of the invention:
Step 301, the network data filtering module filters this machine dns resolution request package, this machine dns resolution request package that will meet the local dns parses policy that sets in advance is forwarded to this machine dns resolution module, and this machine dns resolution request package that does not meet the local dns parses policy is forwarded to operating system bottom module;
Before execution in step 301, this machine dns resolution module need be provided with listening port and listening port and local dns parses policy are inserted the network data filtering module.
In step 301, the network data filtering module need filter this machine dns resolution request package according to the local dns parses policy,, judges whether this machine dns resolution request package needs to carry out local dns and resolve that is; Determining under the situation that this machine dns resolution request package need carry out handling this locality, the network data filtering module is revised as this machine address with the former destination address of this machine dns resolution request package, and the former destination interface of this machine dns resolution request package is revised as the listening port that this machine dns resolution module is provided with, and this machine dns resolution request package is transmitted to this machine dns resolution module; Subsequently, follow-up inquiry for convenience, the network data filtering module is preserved the source port of this machine dns resolution request package, former destination address and former destination interface.
Step 302, this machine dns resolution module is resolved this machine dns resolution request package that receives, and obtains analysis result, and analysis result is carried at sends to operating system bottom module in this machine dns resolution response packet.
In step 302, this machine dns resolution module need resolve to corresponding IP address with the domain name addresses in this machine dns resolution request package according to user-defined domain name and procotol IP address corresponding relation; Subsequently, this machine dns resolution module is inquired about the former destination address and the former destination interface of this machine dns resolution request package according to the source port in this machine dns resolution request package to the network data filtering module; At last, this machine dns resolution module is constructed this machine dns resolution response packet according to IP address, former destination address and former destination interface after resolving, and by raw socket this machine dns resolution response packet is sent to operating system bottom module.
In actual applications, can expand the local dns parses policy, particularly: this machine dns resolution module receives the current local dns parses policy of DNS strategic server distribution; This machine dns resolution module is upgraded former local dns resolution strategy according to current local dns parses policy, and the local dns parses policy after will upgrading is inserted the network data filtering module.
Below in conjunction with accompanying drawing, be example with the Windows system, the technical scheme of the embodiment of the invention is elaborated.
In the Windows system, the network data filtering module is TDI filter (Transport Driver Interface Filter abbreviates TDI Filter as).Fig. 4 is the detailed process flow chart of the dns resolution method of the embodiment of the invention, as shown in Figure 4, comprises following processing:
TDI Filter mainly finishes filtration, coupling and the forwarding work of network data as the realization of network data filtering module on Windows operating system.After operating system was sent the dns resolution request, TDI Filter can intercept and capture this request msg, and according to presetting its inner dns resolution strategy, judged whether to carry out local parsing.As need not to carry out local parsing, then TDI Filter can directly carry out subsequent treatment for operating system bottom module this data forwarding; Carry out local parsing as needs, then TDI Filter can revise the destination address and the port of this request msg, and it is transmitted to DNS local parsing module.
DNS local parsing module (promptly, above-mentioned machine dns resolution module) mainly be to receive TDI Filter to be forwarded to the dns resolution request msg, and according to user-defined domain name to IP address corresponding relation, convert the domain name addresses of request analysis to the IP address, according to dns resolution response packet of analysis result structure, (RAW Socket) writes back to operating system by raw socket then.
In this example, can at first monitor certain udp port after DNS local parsing module starts at this machine.This udp port can be made an appointment, and is selected at random in the time of also can being started by DNS local parsing module.
After DNS local parsing module starts successfully, udp port number (UDP 53) and local dns parses policy can be inserted TDI Filter.
After TDI Filter receives udp port that DNS local parsing module inserts number and local dns parses policy, think that promptly DNS local parsing module has started success, can open the local dns analytical capabilities.From after this, TDI Filter promptly begins to filter all data of flowing through on UDP 53 ports.
Intercept the data of UDP 53 ports of flowing through as TDI Filter after,, judge whether these data are the dns resolution request msg at first according to network protocol type and port numbers.As not, then call TDI Filter and send function, data forwarding operating system bottom assembly is carried out subsequent treatment.As being the dns resolution request msg, then, judge whether to meeting the data of local dns parses policy according to the local dns parses policy of inserting.As not, then call TDI Filter and send function, data forwarding operating system bottom assembly is carried out subsequent treatment.
After intercepting the dns resolution request msg that meets the local dns parses policy as TDI Filter, then revise the destination address and the destination interface of this request msg.Destination address is revised as this machine address, and destination interface is set to the listening port of DNS local parsing module, calls TDI Filter then and sends function, and data forwarding operating system bottom assembly is carried out subsequent treatment.TDI Filter simultaneously can be with the source port of this packet, and original purpose address and original purpose port are preserved for future reference.
Revised and the dns resolution request msg after operating system is handled by TDI Filter, finally can be received by DNS local parsing module.DNS local parsing module after the analysis request data, the domain name addresses of extract to need resolving, and the domain name that presets according to the user obtains the IP address of this domain name correspondence to the corresponding relation of IP.
After DNS local parsing module is finished domain name mapping, can inquire about the original purpose address and the original purpose port of this request msg to TDI Filter according to the source port of dns resolution request msg.After successful inquiring, can be according to the original purpose address, the original purpose port, data such as the IP address after the parsing are constructed a complete dns resolution request and are responded bag, write back system by RAW Socket, finish the local dns process of analysis.
In above-mentioned example, the dns resolution strategy presets, and can not change.But for some complicated Intranet, static dns resolution strategy possibly can't satisfy its needs.Therefore, can expand, the dns resolution strategy is carried out remote deployment and management the embodiment of the invention.Fig. 5 is the flow chart that the dns resolution policy configurations of the embodiment of the invention is upgraded, as shown in Figure 5:
At first, the keeper is by the DNS strategic server, and editor's dns resolution strategy after forming the dns resolution strategy file, is distributed this strategy file by the DNS strategic server.DNS local parsing module is understood its dns resolution strategy of real-time update behind the dns resolution strategy file of receiving the distribution of DNS strategic server, and strategy is write among the TDI Filter.By at enterprises DNS strategic server, can carry out telemanagement and renewal to user's local dns parses policy, improve manageability and ease for use.Need to prove that the content that the local dns parses policy is comprised is: the domain name of predefined type is made local dns resolve, perhaps, the domain name of predefined type is done outside dns resolution.
In sum, the embodiment of the invention proposes a kind of technical scheme that local dns is resolved that realizes in Intranet.Different with prior art, the embodiment of the invention is by inserting network data filtering module (the present invention is an example with Windows TDI Filter) in operating system, and the dns resolution request msg that will meet the local dns parses policy is transmitted to DNS local parsing module.After DNS local parsing module is finished dns resolution, by RAW Socket analysis result is write back system again, realize the local dns parsing.
In the present invention, the network data filtering module can determine whether that needs are transmitted to DNS local parsing module with request msg according to the local dns parses policy that the user is provided with, thereby realize complicated local dns parses policy after intercepting the dns resolution request msg.For example, the user can the local dns parses policy be set to: " all domain names are all made local dns and resolved, and only tangible domain name as * .sina.com is carried out outside dns resolution ".
In embodiments of the present invention, the network data filtering module as is judged as non-local dns analysis request data after coupling local dns parses policy, then directly the DNS request msg is sent to operating system bottom module and carry out subsequent treatment.Compare with the prior art scheme, the present invention need not to non-local dns request msg provides the response data of dns resolution mistake, thereby accelerates the resolution speed that non-local dns is resolved.In addition, in embodiments of the present invention, the local dns resolution rules can be specified in advance, also can be by the long-range issue of DNS policy manager.
Need to prove, in embodiments of the present invention, be example with Windows operating system, described the handling process of the embodiment of the invention.But the embodiment of the invention is not limited to Windows operating system.
Device embodiment
According to embodiments of the invention, a kind of dns resolution device is provided, Fig. 6 is the structural representation of the dns resolution device of the embodiment of the invention, as shown in Figure 6, dns resolution device according to the embodiment of the invention comprises: networkdata filtering module 60, this machinedns resolution module 62 below are described in detail each module of the embodiment of the invention.
Networkdata filtering module 60 is used for this machine dns resolution request package is filtered, this machine dns resolution request package that will meet the local dns parses policy that sets in advance is forwarded to this machinedns resolution module 62, and this machine dns resolution request package that does not meet the local dns parses policy is forwarded to operating system bottom module;
Networkdata filtering module 60 specifically is used for:
According to the local dns parses policy this machine dns resolution request package is filtered, judge whether this machine dns resolution request package needs to carry out local dns and resolve; Determining under the situation that this machine dns resolution request package need carry out handling this locality, the former destination address of this machine dns resolution request package is revised as this machine address, and the former destination interface of this machine dns resolution request package is revised as the listening port of this machine dns resolution module, and this machine dns resolution request package is transmitted to this machinedns resolution module 62; The source port of this machine dns resolution request package, former destination address and former destination interface are preserved.
This machinedns resolution module 62 is used for this machine dns resolution request package that receives is resolved, and obtains analysis result, and analysis result is carried at sends to operating system bottom module in this machine dns resolution response packet.
This machinedns resolution module 62 specifically is used for:
According to user-defined domain name and procotol IP address corresponding relation, the domain name addresses in this machine dns resolution request package is resolved to corresponding IP address; According to the source port in this machine dns resolution request package, inquire about the former destination address and the former destination interface of this machine dns resolution request package to the network data filtering module; Construct this machine dns resolution response packet according to IP address, former destination address and former destination interface after resolving, and this machine dns resolution response packet is sent to operating system bottom module by raw socket.
The dns resolution device of the embodiment of the invention also comprises:
Module is set, is used to be provided with listening port, and listening port and local dns parses policy are inserted the network data filtering module.
Update module is used to receive the current local dns parses policy that the DNS strategic server is distributed, and according to current local dns parses policy former local dns resolution strategy is upgraded, and the local dns parses policy after upgrading is inserted the network data filtering module.
Below in conjunction with accompanying drawing, be example with the Windows system, the technical scheme of the embodiment of the invention is elaborated.
In the Windows system, networkdata filtering module 60 is TDI filter (Transport Driver Interface Filter abbreviates TDI Filter as).As shown in Figure 4, comprise following processing:
TDI Filter mainly finishes filtration, coupling and the forwarding work of network data as the realization of networkdata filtering module 60 on Windows operating system.After operating system was sent the dns resolution request, TDI Filter can intercept and capture this request msg, and according to presetting its inner dns resolution strategy, judged whether to carry out local parsing.As need not to carry out local parsing, then TDI Filter can directly carry out subsequent treatment for operating system bottom module this data forwarding; Carry out local parsing as needs, then TDI Filter can revise the destination address and the port of this request msg, and it is transmitted to this machinedns resolution module 62.
This machinedns resolution module 62 mainly is to receive TDI Filter to be forwarded to the dns resolution request msg, and according to user-defined domain name to IP address corresponding relation, convert the domain name addresses of request analysis to the IP address, according to dns resolution response packet of analysis result structure, (RAW Socket) writes back to operating system by raw socket then.
In this example, can at first monitor certain udp port after this machinedns resolution module 62 starts at this machine.This udp port can be made an appointment, and is selected at random in the time of also can being started by this machinedns resolution module 62.
After this machinedns resolution module 62 starts successfully, udp port number (UDP 53) and local dns parses policy can be inserted TDI Filter.
After TDI Filter receives udp port that this machinedns resolution module 62 inserts number and local dns parses policy, think that promptly this machinedns resolution module 62 has started success, can open the local dns analytical capabilities.From after this, TDI Filter promptly begins to filter all data of flowing through on UDP 53 ports.
Intercept the data of UDP 53 ports of flowing through as TDI Filter after,, judge whether these data are the dns resolution request msg at first according to network protocol type and port numbers.As not, then call TDI Filter and send function, data forwarding operating system bottom assembly is carried out subsequent treatment.As being the dns resolution request msg, then, judge whether to meeting the data of local dns parses policy according to the local dns parses policy of inserting.As not, then call TDI Filter and send function, data forwarding operating system bottom assembly is carried out subsequent treatment.
After intercepting the dns resolution request msg that meets the local dns parses policy as TDI Filter, then revise the destination address and the destination interface of this request msg.Destination address is revised as this machine address, and destination interface is set to the listening port of DNS local parsing module, calls TDI Filter then and sends function, and data forwarding operating system bottom assembly is carried out subsequent treatment.TDI Filter simultaneously can be with the source port of this packet, and original purpose address and original purpose port are preserved for future reference.
Revised and the dns resolution request msg after operating system is handled by TDI Filter, finally can be received by this machine dns resolution module 62.This machinedns resolution module 62 after the analysis request data, the domain name addresses of extract to need resolving, and the domain name that presets according to the user obtains the IP address of this domain name correspondence to the corresponding relation of IP.
After this machinedns resolution module 62 is finished domain name mapping, can inquire about the original purpose address and the original purpose port of this request msg to TDI Filter according to the source port of dns resolution request msg.After successful inquiring, can be according to the original purpose address, the original purpose port, data such as the IP address after the parsing are constructed a complete dns resolution request and are responded bag, write back system by RAW Socket, finish the local dns process of analysis.
In above-mentioned example, the dns resolution strategy presets, and can not change.But for some complicated Intranet, static dns resolution strategy possibly can't satisfy its needs.Therefore, can expand, the dns resolution strategy is carried out remote deployment and management the embodiment of the invention.As shown in Figure 5: at first, the keeper is by the DNS strategic server, and editor's dns resolution strategy after forming the dns resolution strategy file, is distributed this strategy file by the DNS strategic server.This machinedns resolution module 62 is understood its dns resolution strategy of real-time update behind the dns resolution strategy file of receiving the distribution of DNS strategic server, and strategy is write among the TDI Filter.By at enterprises DNS strategic server, can carry out telemanagement and renewal to user's local dns parses policy, improve manageability and ease for use.Need to prove that the content that the local dns parses policy is comprised is: the domain name of predefined type is made local dns resolve, perhaps, the domain name of predefined type is done outside dns resolution.
In sum, the embodiment of the invention proposes a kind of technical scheme that local dns is resolved that realizes in Intranet.Different with prior art, the embodiment of the invention is by inserting network data filtering module 60 (the present invention is an example with Windows TDI Filter) in operating system, the dns resolution request msg that will meet the local dns parses policy is transmitted to this machine dns resolution module 62.After this machinedns resolution module 62 is finished dns resolution, by RAW Socket analysis result is write back system again, realize the local dns parsing.
In the present invention, networkdata filtering module 60 is after intercepting the dns resolution request msg, can determine whether that needs are transmitted to this machinedns resolution module 62 with request msg according to the local dns parses policy that the user is provided with, thereby realize complicated local dns parses policy.For example, the user can the local dns parses policy be set to: " all domain names are all made local dns and resolved, and only tangible domain name as * .sina.com is carried out outside dns resolution ".
In embodiments of the present invention, networkdata filtering module 60 as is judged as non-local dns analysis request data after coupling local dns parses policy, then directly the DNS request msg is sent to operating system bottom module and carry out subsequent treatment.Compare with the prior art scheme, the present invention need not to non-local dns request msg provides the response data of dns resolution mistake, thereby accelerates the resolution speed that non-local dns is resolved.In addition, in embodiments of the present invention, the local dns resolution rules can be specified in advance, also can be by the long-range issue of DNS policy manager.
Need to prove, in embodiments of the present invention, be example with Windows operating system, described the handling process of the embodiment of the invention.But the embodiment of the invention is not limited to Windows operating system.
The embodiment of the invention is filtered this machine dns resolution request package by the network data filtering module, the request msg that will meet this machine dns resolution strategy is forwarded to this machine dns resolution module and handles, it is long to have solved in the prior art local dns parsing time, and can not define the problem of complicated local dns parses policy, therefore the embodiment of the invention can realize complicated dns resolution strategy owing to use the network data filtering module that the DNS request msg is filtered; Because the network data filtering module can directly be transmitted the packet of this machine of not meeting dns resolution strategy, therefore can improve dns resolution speed; Because the network data filtering module need not listening port, therefore can not exist and conflict with the mounted dns server software of this machine; In addition, need not to revise domain name, can not trigger the anti-virus software action, and can improve the execution efficient that local dns is resolved to IP address corresponding relation configuration file.
Although be the example purpose, the preferred embodiments of the present invention are disclosed, it also is possible those skilled in the art will recognize various improvement, increase and replacement, therefore, scope of the present invention should be not limited to the foregoing description.