METHOD AND DEVICE FOR REDIRECTION TO WEB PAGE
20170317967 ยท 2017-11-02
Assignee
Inventors
Cpc classification
H04L69/16
ELECTRICITY
H04L67/02
ELECTRICITY
H04L61/00
ELECTRICITY
International classification
Abstract
Disclosed are a method and device for redirection to a Web page. The method includes: when a first device receives a Domain Name System (DNS) request from a second device and a domain name requested by the DNS request is not a domain name of a gateway of the first device and satisfies a redirection condition, the first device sends a response message of the DNS request to the second device (S102), wherein an unused virtual Internet Protocol (IP) address in a locally preset virtual IP address group is carried in the response message; the first device establishes a correspondence between the virtual IP address and the domain name satisfying the redirection condition (S104); and after receiving a Transport Control Protocol (TCP) data packet sent from the second device, the first device replaces the virtual IP address carried in the TCP data packet with a designated IP address, and forwards, according to the designated IP address, interactive data packets between the second device and the designated IP address (S106). The technical solution solves the problem in the related art of redirection to the Web page resulting from optimization of a Personal Computer (PC) browser.
Claims
1. A method for redirection to a Web page, comprising: when a first device receives a Domain Name System (DNS) request from a second device and a domain name requested by the DNS request is not a domain name of a gateway of the first device and satisfies a redirection condition, sending, by the first device, a response message of the DNS request to the second device, wherein an unused virtual Internet Protocol (IP) address in a locally preset virtual IP address group is carried in the response message, and the unused virtual IP address being a virtual IP address having not been used for redirecting a DNS response packet yet; establishing, by the first device, a correspondence between the virtual IP address and the domain name satisfying the redirection condition; and after the first device receives a Transport Control Protocol (TCP) data packet sent from the second device, replacing the virtual IP address carried in the TCP data packet with a designated IP address, and forwarding, according to the designated IP address, interactive data packets between the second device and the designated IP address.
2. The method as claimed in claim 1, wherein replacing, when the redirection condition is satisfied, the virtual IP address carried in the TCP data packet according to the designated IP address to further implement the interactive data packets of data via the designated IP address comprises: replacing the designated IP address with a gateway address of the first device, and forwarding interactive data packets between the second device and the gateway according to the gateway address.
3. The method as claimed in claim 1, wherein replacing, when the redirection condition is not satisfied, the virtual IP address carried in the TCP data packet according to the designated IP address to further implement the interactive data packets of data via the designated IP address comprises: acquiring, by the first device, a destination address of the TCP data packet from the TCP data packet; judging, by the first device, whether a virtual IP address corresponding to the destination address exists in the virtual IP address group; and when the virtual IP address corresponding to the destination address exists in the virtual IP address group, searching for a redirected domain name corresponding to the virtual IP address, replacing the virtual IP address with a true IP address of the redirected domain name, and forwarding interactive data packets between the second device and the true IP address according to the true IP address of the redirected domain name.
4. The method as claimed in claim 3, wherein after forwarding the interactive data packets between the second device and the true IP address according to the true IP address of the redirected domain name, the method further comprises: conducting DNS resolution on the redirected domain name to obtain a true IP address of the redirected domain name.
5. The method as claimed in claim 4, wherein after forwarding the interactive data packets between the second device and the true IP address according to the true IP address of the redirected domain name, the method further comprises: saving a correspondence between the redirected domain name and the true IP address of the redirected domain name.
6. A device for redirection to a Web page, comprising: a receiving module, configured to send, when a Domain Name System (DNS) request is received from a second device and a domain name requested by the DNS request is not a domain name of a gateway of the first device and satisfies a redirection condition, a response message of the DNS request to the second device, wherein an unused virtual Internet Protocol (IP) address in a locally preset virtual IP address group is carried in the response message, the unused virtual IP address being a virtual IP address having not been used for redirecting a DNS response packet yet; an establishment module, configured to establish a correspondence between the virtual IP address and the domain name satisfying the redirection condition; and a replacement module, configured to replace, after receiving a Transport Control Protocol (TCP) data packet sent from the second device, the virtual IP address carried in the TCP data packet with a designated IP address, and forward, according to the designated IP address, interactive data packets between the second device and the designated IP address.
7. The device as claimed in claim 6, wherein the replacement module comprises: a first replacement unit, configured to replace, when the redirection condition is satisfied, the designated IP address with a gateway address of the first device, and forward interactive data packets between the second device and the gateway according to the gateway address.
8. The device as claimed in claim 6, wherein when the redirection condition is not satisfied, the replacement module further comprises: an acquisition unit, configured to acquire a destination address of the TCP data packet from the TCP data packet; a judgment unit, configured to judge whether a virtual IP address corresponding to the destination address exists in the virtual IP address group; and a second replacement unit, configured to search, when the virtual IP address corresponding to the destination address exists in the virtual IP address group, for a redirected domain name corresponding to the virtual IP address, replace the virtual IP address with a true IP address of the redirected domain name, and forward interactive data packets between the second device and the true IP address according to the true IP address of the redirected domain name.
9. The device as claimed in claim 8, further comprising: a resolution module, configured to conduct DNS resolution on the redirected domain name to obtain a true IP address of the redirected domain name.
10. The device as claimed in claim 9, further comprising: a saving module, configured to save a correspondence between the redirected domain name and the true IP address of the redirected domain name.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings illustrated herein are intended to provide a further understanding for the present disclosure, and form a part of the present application. The schematic embodiments and illustrations of the present disclosure are intended to explain the present disclosure.
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] It is important to note that the embodiments in the present application and characteristics in the embodiments may be combined under the condition of no conflicts. The present disclosure will be illustrated hereinbelow with reference to the drawings and in conjunction with the embodiments in detail.
[0031] The steps shown in the flowchart of the drawings may be executed in a computer system including, for example, a set of computer-executable instructions. Moreover, although a logic sequence is shown in the flowchart, the shown or described steps may be executed in a sequence different from the sequence here under certain conditions.
[0032] The present embodiment provides a method for redirection to a Web page.
[0033] At Step S102: When a first device receives a DNS request from a second device and a domain name requested by the DNS request is not a domain name of a gateway of the first device and satisfies a redirection condition, the first device sends a response message of the DNS request to the second device.
[0034] The response message carries an unused virtual IP address in a locally preset virtual IP address group; the unused virtual IP address refers to a virtual IP address having not been used for redirecting a DNS response packet yet.
[0035] At Step S104: The first device establishes a correspondence between the virtual IP address and the domain name satisfying the redirection condition.
[0036] At Step S106: After receiving a TCP data packet sent from the second device, the first device replaces the virtual IP address carried in the TCP data packet with a designated IP address, and forwards, according to the designated IP address, interactive data packets between the second device and the designated IP address.
[0037] By means of the above embodiments, the DNS response packet fed back to the second device by the first device carries the virtual IP address, and when the first device receives the TCP data packet of the second device, the virtual IP address in the TCP data packet is replaced, thus implementing data interaction between the second device and the first device. The problem in the related art where a redirected domain name will be redirected within a period of time in case of not wiping a cache from a PC browser when being not required to be redirected due to optimization of the PC browser is solved, thus the user experience is improved.
[0038] There are many modes for replacing a virtual IP address involved in the present embodiment. In an implementation mode of the present embodiment, the virtual IP address is replaced by using the following modes.
[0039] When the redirection condition is satisfied, the designated IP address is replaced with a gateway address of the first device, and interactive data packets between the second device and the gateway are forwarded according to the gateway address.
[0040] When the redirection condition is not satisfied, the first device acquires a destination address of the TCP data packet from the TCP data packet, and the first device judges whether a virtual IP address corresponding to the destination address exists in the virtual IP address group. If so, a redirected domain name corresponding to the virtual IP address is searched; and the virtual IP address is replaced with a true IP address of the redirected domain name, and interactive data packets between the second device and the true IP address are forwarded according to the true IP address of the redirected domain name.
[0041] In another implementation mode of the present embodiment, the mode of acquiring the true IP address may be implemented by the following mode: conducting DNS resolution on the redirected domain name, so as to obtain a true IP address of the redirected domain name.
[0042] In order to improve the experience effect of the user, after the true IP address of the redirected domain name is acquired, a correspondence between the redirected domain name and the true IP address of the redirected domain name is saved.
[0043] The embodiments of the present disclosure also provide a device for redirection to a Web page. The device may be configured to implement the abovementioned method embodiment of the present disclosure.
[0044] a receiving module 22, configured to send, when a DNS request is received from a second device and a domain name requested by the DNS request is not a domain name of a gateway of the first device and satisfies a redirection condition, a response message of the DNS request to the second device, the response message carrying an unused virtual IP address in a locally preset virtual IP address group, the unused virtual IP address being a virtual IP address having not been used for redirecting a DNS response packet yet;
[0045] an establishment module 24, coupled to the receiving module 22, and configured to establish a correspondence between the virtual IP address and the domain name satisfying the redirection condition; and
[0046] a replacement module 26, coupled to the establishment module 24, and configured to replace, after receiving a TCP data packet sent from the second device, the virtual IP address carried in the TCP data packet with a designated IP address, and forward, according to the designated IP address, interactive data packets between the second device and the designated IP address.
[0047]
[0048]
[0049] a judgment unit 44, coupled to the acquisition unit 42, and configured to judge whether a virtual IP address corresponding to the destination address exists in the virtual IP address group; and
[0050] a second replacement unit 46, coupled to the judgment unit 44, and configured to search, if so, for a redirected domain name corresponding to the virtual IP address, replace the virtual IP address with a true IP address of the redirected domain name, and forward interactive data packets between the second device and the true IP address according to the true IP address of the redirected domain name.
[0051]
[0052]
[0053] It is important to note that the device for redirection to a Web page described in the device embodiment corresponds to the abovementioned method embodiment. A specific implementation process has been illustrated in detail in the method embodiment, which will not be elaborated herein.
[0054] The present disclosure will be illustrated with examples hereinbelow in conjunction with alternative embodiments of the present disclosure and the drawings.
[0055] In order to solve the problem in the related art where a redirected domain name will be redirected within a period of time in case of not wiping a cache from a PC browser when being not required to be redirected due to optimization of the PC browser so as to improve the user experience, in an embodiments of the present disclosure, the following steps S1 to S3 are provided to solve the abovementioned problem is solve.
[0056] At Step S1: When a device receives a DNS request sent from a PC and a requested domain name is not a domain name of a gateway of the device and satisfies a redirection condition, an unused virtual IP address in a preset virtual IP address group is selected, and a DNS response data packet is assembled and returned to the PC.
[0057] At Step S2: A correspondence between the redirected domain name and a responding virtual IP address is recorded and saved.
[0058] At Step S3: When the device receives a tcp data packet sent from the PC, and if the redirection condition is satisfied, a virtual IP address in the tcp data packet with a gateway address and interactive data packets between the PC and the gateway are forwarded.
[0059] If the redirection condition is satisfied and a destination address of the tcp data packet is in a preset virtual IP address group, a domain name of a true access address of the tcp data packet is found according to the correspondence between the redirected domain name and the virtual IP address, a true IP address of the domain name is acquired, a virtual target IP address in the data packet is replaced with the true IP address, and interactive data packets between the PC and the true IP address are forwarded.
[0060] The defect in the related art of user experience resulting from optimization of the PC browser is overcome by means of the abovementioned mode, thus improving the user experience.
[0061] The method for redirecting a mobile terminal to a Web page of a gateway according to an embodiment of the present disclosure includes step A to step K.
[0062] At Step A: When a user accesses a web page of a PC browser via a domain name and a device receives a DNS request, it is judged whether to request for a domain name of a gateway before entering a DNS resolution flow. If so, the flow is ended, and a normal DNS resolution flow is entered. If not, Step B is executed.
[0063] At Step B: It is judged whether a redirection condition is satisfied. If not, the flow is ended, and a normal DNS resolution flow is entered. If not, Step C is executed.
[0064] At Step C: An unused virtual IP address is selected from a set virtual IP address group, and a DNS response packet is assembled and returned to a PC browser.
[0065] At Step D: A correspondence between a domain name of the DNS request and a responding virtual IP address is recorded.
[0066] At Step E: When receiving a tcp handshaking message sent from the PC browser, the device judges whether the redirection condition is satisfied, if so, Step F is executed, and if not, Step H is jumped.
[0067] At Step F: A tcp data packet sent from the PC browser is forwarded to the gateway, and a tcp response message of the gateway is forwarded to the PC browser.
[0068] At Step G: After receiving an http request sent from the PC browser, the device assembles an http 302 redirection message for redirection to the domain name of the gateway, and the flow is ended.
[0069] At Step H: It is judged whether a target address of the tcp data packet is in a set virtual IP address group. If not, a normal data routing flow is executed, and then the flow is ended. If so, Step I is executed.
[0070] At Step I: A domain name corresponding to the target address of the tcp data packet is found from the recorded correspondence of the redirected domain name with the virtual IP address.
[0071] At Step J: The recorded domain name and the recorded true IP address are searched for a true IP address of the domain name. If not, DNS resolution is conducted on the domain name to obtain the true IP address of the domain name, and a correspondence record is saved.
[0072] At Step K: A message of the PC browser is forwarded to the true IP address, and a data packet response of the true IP address is forwarded to the PC browser.
[0073] If the user accesses by directly using an IP address or the PC browser accesses by using a cached IP address, the flow directly starts from Step E.
[0074] Compared with the related art, the method in the embodiment of the present disclosure can overcome the problem and defect in the related art of redirection to a Web page of a gateway due to optimization of a PC browser, thus improving the user experience.
[0075] The implementation of the technical solution will be further described in detail hereinbelow in conjunction with
[0076] At Step S702: When a user accesses a web page of a PC browser via a domain name and a device receives a DNS request, it is judged whether to request for a domain name of a gateway before entering a DNS resolution flow.
[0077] If the DNS request is for the domain name of the gateway, processing is not needed, and a normal DNS resolution flow is entered to respond to a DNS response of a gateway address. If not, the next step is entered.
[0078] At Step S704: It is judged whether a redirection condition is satisfied.
[0079] If the redirection condition is not satisfied, processing is not needed, a normal DNS resolution flow is entered, and a true IP address corresponding to the domain name is resolved from a network. If the redirection condition is satisfied, the next step is entered.
[0080] At Step S706: An unused virtual IP address is selected from a set virtual IP address group, and a DNS response packet is assembled and returned to a PC browser.
[0081] At Step S708: A correspondence between a domain name of the DNS request and a responding virtual IP address is recorded.
[0082] The recorded correspondence between the redirected domain name and the responding virtual IP address is recorded for use in the subsequent steps.
[0083] At Step S710: When receiving a tcp handshaking message sent from the PC browser, the device judges whether the redirection condition is satisfied.
[0084] If so, it skips to Step S612, and if not, it skips to Step S616.
[0085] At Step S712: A tcp data packet sent from the PC browser is forwarded to the gateway, and a tcp response message of the gateway is forwarded to the PC browser.
[0086] A device tcp protocol stack forwards tcp data interaction between the PC browser and the gateway of the device.
[0087] At Step S714: After receiving an http request sent from the PC browser, the device assembles an http 302 redirection message for redirection to the domain name of the gateway, and the flow is ended.
[0088] When the PC browser completes tcp handshaking, an http request message will be sent, and at this time, an effect of redirection to a Web page of the gateway is achieved by responding to an http 302 message.
[0089] At Step S716: It is judged whether a target address of the tcp data packet is in a set virtual IP address group.
[0090] When the browser sends a tcp handshaking request and the redirection condition is not satisfied, it is judged whether the target address of the data packet is in the set virtual IP address group. If not, a normal data routing flow is executed, and then the flow is ended. If so, it skips to Step S718.
[0091] At Step S718: A domain name corresponding to the target address of the tcp data packet is found from the recorded correspondence between the redirected domain name and the virtual IP address.
[0092] A domain name corresponding to a tcp target virtual address is found from an information record recorded in Step S708.
[0093] At Step S720: A true IP address of the domain name is obtained.
[0094] The domain name recorded in Step S720 and a true IP address record are searched for the true IP address of the domain name. If it cannot be found in the record, DNS resolution is conducted on the domain name, the true IP address of the domain name is obtained from a network, and a record about a correspondence between the domain name and the true IP address is saved.
[0095] At Step S722: A data packet interactive between the PC browser and the true IP address is forwarded.
[0096] The above is only the exemplary embodiments of the present disclosure, and not intended to limit the present disclosure. There may be various modifications and variations in the present disclosure for those skilled in the art. Any modifications, equivalent replacements, improvements and the like shall fall within the scope of protection of the present disclosure.
INDUSTRIAL APPLICABILITY
[0097] As above, the method and device for redirection to a Web page provided in the embodiments of the present disclosure have the following beneficial effects: the problem in the related art where a redirected domain name will be redirected within a period of time in case of not wiping a cache from a PC browser when being not required to be redirected due to optimization of the PC browser is solved, thus the user experience is improved.