Network detection method and device, electronic equipment and storage medium
By running dynamic domain name services in the terminal, sending probe messages regularly and updating the binding relationship, the DDNS failure problem caused by the change of the router's public network address is solved, and automatic connection of DDNS and convenient network access is realized.
Patent Information
- Application Number
- CN202411825837.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-03-11
AI Technical Summary
In the prior art, changes in the public network address of the router cause DDNS between the terminal and the router to fail, external network devices cannot access the terminal, and resuming the connection requires manually resetting DDNS, which is cumbersome.
Run dynamic domain name service in the terminal, send probe messages to the router's public network address regularly, receive and parse the probe response to determine the router's current WAN interface address, and update the binding relationship when the address changes to achieve automatic connection.
By automatically detecting the change of the WAN interface address of the router, the failure of external network access caused by the failure of DDNS binding relationship in time is avoided, the network connection process is simplified, and the convenience of DDNS applications is improved.
Smart Images

Figure CN119603219A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet application technology, and in particular to a network detection method, device, electronic device and storage medium. Background Art
[0002] DDNS (Dynamic Domain Name Server) can bind a dynamic IP (Internet Protocol) address to a fixed domain name, so that other devices can access the bound dynamic IP address by accessing the domain name.
[0003] Both routers and terminals can support DDNS. To enable DDNS, the terminal needs to know the public network address of the router. Once the public network address of the router changes, the DDNS between the terminal and the router will become invalid, and other devices will no longer be able to access the terminal through DDNS. To restore the connection, you need to manually set up DDNS again, which is cumbersome. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a network detection method, device, electronic device and storage medium to achieve automatic connection of DDNS. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a network detection method, which is applied to a terminal, including:
[0006] When a dynamic domain name service is run in the terminal and a first binding relationship between a first domain name and a wide area network interface address of a router exists in the dynamic domain name service, a detection message is sent to the first public network address at intervals of a first preset time period;
[0007] Upon receiving a probe response returned by the gateway of the router, determining the current wide area network interface address of the router according to the probe response;
[0008] When the current WAN interface address of the router is inconsistent with the WAN interface address existing in the dynamic domain name service, the WAN interface address of the router in the first binding relationship is updated.
[0009] In one embodiment of the present application, the method further includes:
[0010] Checking whether the current Internet address of the terminal has changed;
[0011] When the current Internet address of the terminal changes, a first notification message is sent to the router, so that the router performs port mapping for the current Internet address of the terminal.
[0012] In one embodiment of the present application, the detection message is a message with a lifetime of 2, and the detection response is a timeout message returned by the gateway of the router to the terminal after the lifetime of the detection message returns to zero.
[0013] In one embodiment of the present application, upon receiving a probe response returned by a gateway of the router, determining the current wide area network interface address of the router according to the probe response includes:
[0014] When receiving a timeout message returned by the gateway of the router, parsing the timeout message to obtain the address of the gateway of the router;
[0015] Based on the address of the router gateway, obtain multiple Internet addresses to be explored that exist in the network segment between the terminal and the router gateway;
[0016] For each Internet address to be explored, sending an exploration network packet to the Internet address, wherein the lifetime of the exploration network packet is 1;
[0017] In case of receiving a discovery response, the Internet address from which the discovery response is sent is determined as the wide area network interface address of the router.
[0018] In a second aspect, an embodiment of the present application provides a network detection method, which is applied to a router, including:
[0019] In a case where a dynamic domain name service is run in the router and a second binding relationship between a second domain name and an Internet address of a terminal exists in the dynamic domain name service, an address resolution protocol cache table stored in the router is traversed at intervals of a second preset time period to determine whether a media access control address of the terminal exists in the address resolution protocol cache table, wherein the address resolution protocol cache table is used to store the media access control address and the Internet address of the terminal, and when the current Internet address of the terminal changes, the address resolution protocol cache table is updated;
[0020] In the case where the media access control address of the terminal exists in the address resolution protocol cache table, checking whether the current Internet address of the terminal has changed;
[0021] When the current Internet address of the terminal is inconsistent with the Internet address existing in the dynamic domain name service, the Internet address of the terminal in the second binding relationship is updated.
[0022] In one embodiment of the present application,
[0023] The public network address of the router and the Internet address of the terminal are both ipv6 addresses.
[0024] In a third aspect, an embodiment of the present application provides a network detection device, applied to a terminal, including:
[0025] a detection module, configured to send a detection message to the first public network address at intervals of a first preset time period when a dynamic domain name service is running in the terminal and a first binding relationship between a first domain name and a wide area network interface address of a router exists in the dynamic domain name service;
[0026] A wide area network interface address determination module, configured to determine the current wide area network interface address of the router according to the detection response when receiving the detection response returned by the gateway of the router;
[0027] The WAN interface address updating module is used to update the WAN interface address of the router in the first binding relationship when the current WAN interface address of the router is inconsistent with the WAN interface address existing in the dynamic domain name service.
[0028] In one embodiment of the present application, the device further includes:
[0029] A first address checking module, used to check whether the current Internet address of the terminal has changed;
[0030] The port mapping module is used to send a first notification message to the router when the current Internet address of the terminal changes, so that the router performs port mapping for the current Internet address of the terminal.
[0031] In one embodiment of the present application, the detection message is a message with a lifetime of 2, and the detection response is a timeout message returned by the gateway of the router to the terminal after the lifetime of the detection message returns to zero.
[0032] In one embodiment of the present application, the wide area network interface address determination module is specifically used to:
[0033] When receiving a timeout message returned by the gateway of the router, parsing the timeout message to obtain the address of the gateway of the router;
[0034] Based on the address of the router gateway, obtain multiple Internet addresses to be explored that exist in the network segment between the terminal and the router gateway;
[0035] For each Internet address to be explored, sending an exploration network packet to the Internet address, wherein the lifetime of the exploration network packet is 1;
[0036] In case of receiving a discovery response, the Internet address from which the discovery response is sent is determined as the wide area network interface address of the router.
[0037] In a fourth aspect, an embodiment of the present application provides a network detection device, applied to a router, including:
[0038] a media access control address determination module, configured to, when a dynamic domain name service is running in the router and a second binding relationship between a second domain name and an Internet address of a terminal exists in the dynamic domain name service, traverse an address resolution protocol cache table stored in the router at intervals of a second preset time period to determine whether the media access control address of the terminal exists in the address resolution protocol cache table, wherein the address resolution protocol cache table is used to store the media access control address and the Internet address of the terminal, and when the current Internet address of the terminal changes, the address resolution protocol cache table is updated;
[0039] A second address checking module, configured to check whether the current Internet address of the terminal has changed if the media access control address of the terminal exists in the address resolution protocol cache table;
[0040] The Internet address module is used to update the Internet address of the terminal in the second binding relationship when the current Internet address of the terminal is inconsistent with the Internet address existing in the dynamic domain name service.
[0041] In one embodiment of the present application,
[0042] The public network address of the router and the Internet address of the terminal are both ipv6 addresses.
[0043] In a fifth aspect, an embodiment of the present application provides an electronic device, including:
[0044] Memory, used to store computer programs;
[0045] The processor is used to implement any of the above-mentioned network detection methods when executing the program stored in the memory.
[0046] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any of the above-mentioned network detection methods.
[0047] An embodiment of the present application also provides a computer program product including instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned network detection methods.
[0048] Beneficial effects of the embodiments of the present application:
[0049] The network detection method, device, electronic device and storage medium provided in the embodiment of the present application, when a dynamic domain name service is running in a terminal and there is a first binding relationship between a first domain name and a wide area network interface address of a router in the dynamic domain name service, a detection message is sent to a first public network address at intervals of a first preset time period; when a detection response returned by a gateway of the router is received, the current wide area network interface address of the router is determined according to the detection response; when the current wide area network interface address of the router is inconsistent with the wide area network interface address existing in the dynamic domain name service, the wide area network interface address of the router in the first binding relationship is updated. The terminal automatically detects changes in the wide area network interface address of the upper-level router by regularly sending detection messages, thereby avoiding the failure of external network device access caused by changes in the wide area network interface address of the router and the failure to update the binding relationship in the DDNS in a timely manner, and at the same time eliminating the cumbersome steps of manually resetting and updating the DDNS due to changes in the wide area network interface address of the router, thereby improving the convenience of DDNS application and simplifying the process of network connection.
[0050] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0052] Figure 1 A first flow chart of the network detection method according to an embodiment of the present application;
[0053] Figure 2 An example diagram of intranet and extranet access provided in the embodiment of the present application;
[0054] Figure 3 A second flow chart of the network detection method according to an embodiment of the present application;
[0055] Figure 4 This is an example diagram of a DDNS network detection process running on a terminal according to an embodiment of the present application;
[0056] Figure 5 A schematic diagram of a possible implementation of step S102 in an embodiment of the present application;
[0057] Figure 6 This is an example diagram of the process of detecting the wide area network interface address of a router according to an embodiment of the present application;
[0058] Figure 7 A third flow chart of the network detection method according to an embodiment of the present application;
[0059] Figure 8 This is an example diagram of the DDNS detection process running on a router according to an embodiment of the present application;
[0060] Fig. 9 This is a schematic diagram of the structure of a first network detection device according to an embodiment of the present application;
[0061] Fig.10 This is a schematic diagram of the structure of a second network detection device according to an embodiment of the present application;
[0062] Fig.11 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0064] In the related art, the terminal needs to know the public network address of the router to enable DDNS. Once the public network address of the router changes, the DDNS between the terminal and the router will become invalid, and other devices can no longer access the terminal through DDNS. To restore the connection, the DDNS needs to be manually set up again, which is cumbersome. In order to solve this problem, the embodiments of the present application provide a network detection method, device, electronic device and storage medium.
[0065] The following describes in detail the network detection method of the embodiment of the present application. Figure 1 , Figure 1 This is a first flow chart of the network detection method according to an embodiment of the present application, which is applied to a terminal and includes:
[0066] S101, when a dynamic domain name service is running in a terminal and a first binding relationship between a first domain name and a wide area network interface address of a router exists in the dynamic domain name service, a detection message is sent to a first public network address at intervals of a first preset time period.
[0067] Terminal refers to the intranet server, such as ftp server (File Transfer Protocol Server, a computer that provides file storage and access services on the Internet) and http server (website server). Intranet servers only allow intranet devices to freely access them. External network devices cannot directly access the terminal and need to forward the access through the terminal's upper router to achieve connection.
[0068] The WAN interface (WAN port) address of the router is used to establish communication between external network devices and internal network servers. The external network sends access requests to the WAN interface address of the router, and the router receives the access request and forwards it to the terminal.
[0069] Dynamic Domain Name Service is DDNS. DDNS binds the WAN interface address of the router to the first domain name. At the same time, the router sets port mapping for the IP address of the terminal. At this time, the address of the router can be an IPv4 (Internet Communication Protocol Version 4) address or an IPv6 (Internet Communication Protocol Version 6) address. In the case where there is a first binding relationship between the first domain name and the WAN interface address of the router in the dynamic domain name service, when the external network device requests to access the terminal, it requests to access the first domain name, and DDNS sends the access request to the WAN interface address of the router through the first binding relationship. The router sets port mapping for the terminal, and when receiving the access request, it forwards the access request to the terminal through the port that has a mapping relationship with the IP address of the terminal, so as to realize the access of the external network device to the internal network server.
[0070] For example Figure 2 As shown in the figure, if the public network address of the router is 1.1.1.1, the IP address of the HTTP server (terminal) is 192.168.1.1, bind 1.1.1.1 to the domain name www.test.com through ddns, set up port mapping on the router, map port 8000 to port 80 of the intranet 192.168.1.1, then use a PC (external network device) to access www.test.com:8080 on the external network to access the HTTP server (terminal) on the internal network.
[0071] When DDNS is running on the terminal, and there is a first binding relationship between the first domain name and the wide area network interface address of the router in the dynamic domain name service, the terminal sends a detection message to the first public network address at intervals of a first preset time period. Specifically, the first preset time period is a pre-set time period in which automatic detection of DDNS is more reasonable, and can be set according to the historical changes of the wide area network interface address of the router. The first public network address is any public network address, such as baidu.com (Baidu search website).
[0072] In a possible implementation, the probe message is a message with a lifetime of 2, and the probe response is a timeout message returned by the gateway of the router to the terminal after the lifetime of the probe message returns to zero.
[0073] The detection message can be a UDP (User Datagram Protocol) protocol type detection message (in this case, the destination port needs to be greater than 40000), or an ICMP (Internet Control Message Protocol) protocol type detection message. The survival time (TTL) is 2. The detection message is sent out by the terminal, and the survival time will be reduced by 1 after each device it passes through. Since the router is the upper-level device of the terminal, the survival time of the detection message will be reset to zero after passing through the router, and the detection message will be discarded. The gateway of the router returns a timeout message to the terminal. Specifically, the timeout message can be an ICMP protocol type message.
[0074] By using a probe message with a limited survival time, the gateway address of the router with a response timeout is obtained. This method can easily obtain the current address of the router gateway, and the operation is simple and efficient.
[0075] S102: upon receiving a detection response returned by the gateway of the router, determining a current wide area network interface address of the router according to the detection response.
[0076] When a probe response returned by the gateway of the router is received, the current address of the gateway of the router is obtained through the probe response, and the current wide area network interface address is determined according to the gateway address.
[0077] S103: When the current WAN interface address of the router is inconsistent with the WAN interface address existing in the dynamic domain name service, update the WAN interface address of the router in the first binding relationship.
[0078] Check whether the currently acquired WAN interface address is consistent with the WAN interface address in the first binding relationship in the dynamic domain name service. If not, it means that the WAN interface address of the router has changed and the DDNS of the terminal has expired. Then, start DDNS to update the WAN interface address of the router in the first binding relationship, and bind the current WAN interface address to the first domain name. So that DDNS can be re-run in the connection between the terminal and the router. When the external network device requests to access the first domain name, the access request is sent to the current WAN interface address of the router through the updated first binding relationship, and the router forwards it to the terminal through the port to realize the access request of the external network.
[0079] In a possible implementation, the terminal sends a detection message to the router. If the router has not yet performed DDNS binding with the terminal, the DDNS is started to establish a first binding relationship to bind the first domain name with the wide area network interface address of the router.
[0080] As can be seen from the above, the network detection method provided by the embodiment of the present application, when a dynamic domain name service is running in the terminal and there is a first binding relationship between a first domain name and a wide area network interface address of a router in the dynamic domain name service, sends a detection message to the first public network address at intervals of a first preset time period; when a detection response returned by the gateway of the router is received, the current wide area network interface address of the router is determined according to the detection response; when the current wide area network interface address of the router is inconsistent with the wide area network interface address existing in the dynamic domain name service, the wide area network interface address of the router in the first binding relationship is updated. The terminal automatically detects the change of the wide area network interface address of the upper-level router by regularly sending detection messages, avoiding the failure of external network device access caused by the change of the wide area network interface address of the router and the failure to update the binding relationship in the DDNS in time, and at the same time eliminating the cumbersome steps of manually resetting and updating the DDNS due to the change of the wide area network interface address of the router, thereby improving the convenience of DDNS application and simplifying the process of network connection.
[0081] In one possible implementation, Figure 3 Said method further comprises:
[0082] S201, checking whether the current Internet address of the terminal has changed;
[0083] S202: When the current Internet address of the terminal changes, send a first notification message to the router, so that the router performs port mapping for the current Internet address of the terminal.
[0084] At intervals of a first preset time period, the terminal checks whether its own Internet address (IP address) has changed. If changed, a UPNP (Universal Plug and Play) client in the terminal is started, and a first notification message is sent to a UPNP server running on a router, informing the router to perform port mapping for the current Internet address of the terminal, so that when an external network requests to access the terminal, the router can forward the access request to the current IP address through the port.
[0085] In a possible implementation, if the DDNS of the terminal is started for the first time and the first detection is successful to bind with the WAN interface address of the router, UPNP is also started to trigger the router to perform port mapping.
[0086] In a possible implementation, the DDNS network detection process running on the terminal is as follows: Figure 4 shown.
[0087] As can be seen from the above, the network detection method provided in the embodiment of the present application enables the terminal to periodically detect whether its own IP address has changed, so that when its own IP changes, it can automatically start UPNP to trigger the router to perform port mapping, thereby eliminating the tedious manual update of the router's port forwarding mapping due to the change of the terminal IP address, and simplifying the network connection process.
[0088] In one possible implementation, Figure 5 As shown, in the above step S102, when receiving the detection response returned by the gateway of the router, determining the current wide area network interface address of the router according to the detection response includes:
[0089] S301, upon receiving a timeout message returned by the gateway of the router, parsing the timeout message to obtain the address of the router gateway;
[0090] S302, based on the address of the router gateway, obtaining a plurality of Internet addresses to be explored that exist in the network segment between the terminal and the router gateway;
[0091] S303, for each Internet address to be explored, sending an exploration network packet to the Internet address;
[0092] Wherein, the survival time of the exploration network packet is 1;
[0093] S304: When a discovery response is received, the Internet address that sends the discovery response is determined as the wide area network interface address of the router.
[0094] When receiving the ICMP timeout message returned by the router's gateway, parse the message to obtain the source IP address of the router that sent the message, that is, the current address of the router gateway.
[0095] Determine all the IP addresses in the network segment between the terminal and the router gateway address, and send a discovery network packet to each IP address, that is, ping (Packet Internet Groper, Internet packet discovery) each IP address, and the TTL of the discovery network packet is 1. In this case, only the WAN interface address of the router can be pinged, and a ping response (discovery response) is returned to the terminal. At this time, the IP that returns the discovery response is determined as the IP address of the router's WAN interface.
[0096] In an example, the process of detecting the router WAN interface address is as follows Figure 6shown.
[0097] As can be seen from the above, the network detection method provided in the embodiment of the present application, after obtaining the current gateway address of the router, explores each IP address in the intermediate network segment until a exploration response is received, thereby accurately and efficiently determining the address of the current wide area network interface of the router.
[0098] In one possible implementation, Figure 7 As shown, the present application also provides a flow chart of a third network detection method, which is applied to a router, including:
[0099] S401, when a dynamic domain name service is running in the router and a second binding relationship between a second domain name and an Internet address of a terminal exists in the dynamic domain name service, traverse an address resolution protocol cache table stored in the router at intervals of a second preset time period to determine whether a media access control address of the terminal exists in the address resolution protocol cache table;
[0100] The address resolution protocol cache table is used to store the media access control address and the Internet address of the terminal, and when the current Internet address of the terminal changes, the address resolution protocol cache table is updated;
[0101] S402, if the media access control address of the terminal exists in the address resolution protocol cache table, checking whether the current Internet address of the terminal has changed;
[0102] S403: When the current Internet address of the terminal is inconsistent with the Internet address existing in the dynamic domain name service, update the Internet address of the terminal in the second binding relationship.
[0103] In a possible implementation, the public network address of the router and the Internet address of the terminal are both IPv6 addresses. Therefore, the router does not need to set up port forwarding mapping for the terminal. It only needs to determine the current IP address of the terminal and bind the IP address to the second domain name. When the external network device requests to access the terminal, the access request can be forwarded to the IP address of the terminal through the second binding relationship. This improves the convenience and efficiency of the external network device accessing the internal network server.
[0104] The second preset time period is a preset time period during which automatic detection of DDNS is more reasonable, and can be set according to the historical changes in the Internet address of the terminal.
[0105] The terminal sets DDNS on the router. Every second preset time period, the router traverses the stored address resolution protocol cache table (ARP, Address Resolution Protocol), which stores the media access control addresses (MAC addresses, Media Access Control Address) and their corresponding IP addresses of multiple terminals under the router. When the IP address of the terminal changes, the current IP address will be automatically updated in the ARP table.
[0106] The router checks whether the IP address of the terminal stored in the ARP table is consistent with the IP address in the second binding relationship. If not, it means that the IP address of the terminal has changed. Then, DDNS is started to update the second binding relationship and bind the current IP address of the terminal to the second domain name.
[0107] Specifically, users can set up DDNS for multiple terminals on the router. The router can manage the DDNS connections of multiple terminals at the same time. The router saves the corresponding relationship between the MAC address and DDNS of each terminal. Based on this corresponding relationship, the router regularly detects whether the terminal set by the user is online, whether DDNS has been started, whether the MAC address is in the ARP table, and whether the IP address has changed. If a terminal has set up DDNS on the router during the inspection process, and the router has not yet bound DDNS to the terminal, the DDNS is started to establish a second binding relationship, and the second domain name is bound to the current IP address of the terminal.
[0108] The DDNS detection process running on the router is as follows: Figure 8 shown.
[0109] As can be seen from the above, the network detection method provided by the embodiment of the present application, the router can provide DDNS proxy for multiple terminals, uniformly manage the DDNS of multiple terminals, regularly detect whether the sensing terminal is online and whether the terminal IP has changed, and there is no need to set up DDNS on the terminal one by one. When the addresses of the router and the terminal are both IPv6 addresses, the router does not need to set up port forwarding mapping for the terminal, and only needs a second binding relationship to forward the access of the external network device, thereby realizing more efficient and convenient DDNS management.
[0110] like Fig. 9 As shown, the embodiment of the present application also provides a structural schematic diagram of a first network detection device, which is applied to a terminal, including:
[0111] The detection module 501 is used to send a detection message to the first public network address at intervals of a first preset time period when a dynamic domain name service is running in the terminal and a first binding relationship between a first domain name and a wide area network interface address of a router exists in the dynamic domain name service;
[0112] A WAN interface address determination module 502, configured to determine the current WAN interface address of the router according to the detection response when receiving a detection response returned by the gateway of the router;
[0113] The WAN interface address updating module 503 is configured to update the WAN interface address of the router in the first binding relationship when the current WAN interface address of the router is inconsistent with the WAN interface address existing in the dynamic domain name service.
[0114] As can be seen from the above, the network detection device provided in the embodiment of the present application, when a dynamic domain name service is running in the terminal and there is a first binding relationship between a first domain name and a wide area network interface address of a router in the dynamic domain name service, sends a detection message to the first public network address at intervals of a first preset time period; when a detection response returned by the gateway of the router is received, the current wide area network interface address of the router is determined according to the detection response; when the current wide area network interface address of the router is inconsistent with the wide area network interface address existing in the dynamic domain name service, the wide area network interface address of the router in the first binding relationship is updated. The terminal automatically detects the change of the wide area network interface address of the upper-level router by regularly sending detection messages, avoiding the failure of access to external network devices caused by the change of the wide area network interface address of the router and the failure to update the binding relationship in the DDNS in time, and at the same time eliminating the cumbersome steps of manually resetting and updating the DDNS due to the change of the wide area network interface address of the router, thereby improving the convenience of DDNS application and simplifying the process of network connection.
[0115] In a possible implementation manner, the device further includes:
[0116] A first address checking module, used to check whether the current Internet address of the terminal has changed;
[0117] The port mapping module is used to send a first notification message to the router when the current Internet address of the terminal changes, so that the router performs port mapping for the current Internet address of the terminal.
[0118] In a possible implementation, the detection message is a message with a lifetime of 2, and the detection response is a timeout message returned by the gateway of the router to the terminal after the lifetime of the detection message returns to zero.
[0119] As can be seen from the above, the network detection device provided in the embodiment of the present application enables the terminal to periodically detect whether its own IP address has changed, so that when its own IP changes, it can automatically start UPNP to trigger the router to perform port mapping, thereby eliminating the tedious manual update of the router's port forwarding mapping due to the change of the terminal IP address, and simplifying the network connection process.
[0120] In a possible implementation, the wide area network interface address determination module 502 is specifically configured to:
[0121] When receiving a timeout message returned by the gateway of the router, parsing the timeout message to obtain the address of the gateway of the router;
[0122] Based on the address of the router gateway, obtain multiple Internet addresses to be explored that exist in the network segment between the terminal and the router gateway;
[0123] For each Internet address to be explored, sending an exploration network packet to the Internet address, wherein the lifetime of the exploration network packet is 1;
[0124] In case of receiving a discovery response, the Internet address from which the discovery response is sent is determined as the wide area network interface address of the router.
[0125] As can be seen from the above, the network detection device provided in the embodiment of the present application, after obtaining the current gateway address of the router, explores each IP address in the intermediate network segment until receiving a exploration response, thereby accurately and efficiently determining the address of the current wide area network interface of the router.
[0126] like Fig.10 As shown, the embodiment of the present application also provides a structural schematic diagram of a network detection device, which is applied to a router, including:
[0127] The media access control address determination module 601 is used to traverse the address resolution protocol cache table stored in the router at intervals of a second preset time period to determine whether the media access control address of the terminal exists in the address resolution protocol cache table when a dynamic domain name service is run in the router and a second binding relationship between a second domain name and an Internet address of the terminal exists in the dynamic domain name service, wherein the address resolution protocol cache table is used to store the media access control address and Internet address of the terminal, and when the current Internet address of the terminal changes, the address resolution protocol cache table is updated;
[0128] A second address checking module 602, configured to check whether the current Internet address of the terminal has changed if the media access control address of the terminal exists in the address resolution protocol cache table;
[0129] The Internet address module 603 is used to update the Internet address of the terminal in the second binding relationship when the current Internet address of the terminal is inconsistent with the Internet address existing in the dynamic domain name service.
[0130] In one possible implementation,
[0131] The public network address of the router and the Internet address of the terminal are both ipv6 addresses.
[0132] As can be seen from the above, the network detection device provided by the embodiment of the present application, the router can provide DDNS proxy for multiple terminals, uniformly manage the DDNS of multiple terminals, regularly detect whether the sensing terminal is online and whether the terminal IP has changed, and there is no need to set up DDNS on the terminal one by one. When the addresses of the router and the terminal are both ipv6 addresses, the router does not need to set up port forwarding mapping for the terminal, and only needs a second binding relationship to forward the access of the external network device, thereby realizing more efficient and convenient DDNS management.
[0133] The present application also provides an electronic device, such as Fig.11 As shown, including:
[0134] Memory 701, used for storing computer programs;
[0135] The processor 702 is used to implement any of the above-mentioned network detection methods when executing the program stored in the memory 701.
[0136] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 702, the communication interface, and the memory 701 communicate with each other via the communication bus.
[0137] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0138] The communication interface is used for communication between the above electronic device and other devices.
[0139] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0140] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0141] In another embodiment provided by the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above network detection methods are implemented.
[0142] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any network detection method in the above embodiments.
[0143] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0144] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0145] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A network detection method, characterized in that: Applied to terminals, including: When a dynamic domain name service is run in the terminal and a first binding relationship between a first domain name and a wide area network interface address of a router exists in the dynamic domain name service, a detection message is sent to the first public network address at intervals of a first preset time period; Upon receiving a probe response returned by the gateway of the router, determining the current wide area network interface address of the router according to the probe response; When the current WAN interface address of the router is inconsistent with the WAN interface address existing in the dynamic domain name service, the WAN interface address of the router in the first binding relationship is updated.
2. The method according to claim 1, characterized in that The method further comprises: Checking whether the current Internet address of the terminal has changed; When the current Internet address of the terminal changes, a first notification message is sent to the router, so that the router performs port mapping for the current Internet address of the terminal.
3. The method according to claim 1, characterized in that The detection message is a message with a lifetime of 2, and the detection response is a timeout message returned by the gateway of the router to the terminal after the lifetime of the detection message returns to zero.
4. The method according to claim 3, characterized in that The step of determining the current wide area network interface address of the router according to the detection response upon receiving the detection response returned by the gateway of the router comprises: When receiving a timeout message returned by the gateway of the router, parsing the timeout message to obtain the address of the gateway of the router; Based on the address of the router gateway, obtain multiple Internet addresses to be explored that exist in the network segment between the terminal and the router gateway; For each Internet address to be explored, sending an exploration network packet to the Internet address, wherein the lifetime of the exploration network packet is 1; In case of receiving a discovery response, the Internet address from which the discovery response is sent is determined as the wide area network interface address of the router.
5. A network detection method, characterized in that: Applicable to routers, including: In a case where a dynamic domain name service is run in the router and a second binding relationship between a second domain name and an Internet address of a terminal exists in the dynamic domain name service, an address resolution protocol cache table stored in the router is traversed at intervals of a second preset time period to determine whether a media access control address of the terminal exists in the address resolution protocol cache table, wherein the address resolution protocol cache table is used to store the media access control address and the Internet address of the terminal, and when the current Internet address of the terminal changes, the address resolution protocol cache table is updated; In the case where the media access control address of the terminal exists in the address resolution protocol cache table, checking whether the current Internet address of the terminal has changed; When the current Internet address of the terminal is inconsistent with the Internet address existing in the dynamic domain name service, the Internet address of the terminal in the second binding relationship is updated.
6. The method according to claim 5, characterized in that The public network address of the router and the Internet address of the terminal are both ipv6 addresses.
7. A network detection device, characterized in that: Applied to terminals, including: a detection module, configured to send a detection message to the first public network address at intervals of a first preset time period when a dynamic domain name service is running in the terminal and a first binding relationship between a first domain name and a wide area network interface address of a router exists in the dynamic domain name service; A wide area network interface address determination module, configured to determine the current wide area network interface address of the router according to the detection response when receiving the detection response returned by the gateway of the router; The WAN interface address updating module is used to update the WAN interface address of the router in the first binding relationship when the current WAN interface address of the router is inconsistent with the WAN interface address existing in the dynamic domain name service.
8. The device according to claim 7, characterized in that The device also includes: A first address checking module, used to check whether the current Internet address of the terminal has changed; The port mapping module is used to send a first notification message to the router when the current Internet address of the terminal changes, so that the router performs port mapping for the current Internet address of the terminal.
9. The device according to claim 7, characterized in that The detection message is a message with a lifetime of 2, and the detection response is a timeout message returned by the gateway of the router to the terminal after the lifetime of the detection message returns to zero.
10. The device according to claim 9, characterized in that The wide area network interface address determination module is specifically used to: When receiving a timeout message returned by the gateway of the router, parsing the timeout message to obtain the address of the gateway of the router; Based on the address of the router gateway, obtain multiple Internet addresses to be explored that exist in the network segment between the terminal and the router gateway; For each Internet address to be explored, sending an exploration network packet to the Internet address, wherein the lifetime of the exploration network packet is 1; In case of receiving a discovery response, the Internet address from which the discovery response is sent is determined as the wide area network interface address of the router.
11. A network detection device, characterized in that: Applicable to routers, including: a media access control address determination module, configured to, when a dynamic domain name service is running in the router and a second binding relationship between a second domain name and an Internet address of a terminal exists in the dynamic domain name service, traverse an address resolution protocol cache table stored in the router at intervals of a second preset time period to determine whether the media access control address of the terminal exists in the address resolution protocol cache table, wherein the address resolution protocol cache table is used to store the media access control address and the Internet address of the terminal, and when the current Internet address of the terminal changes, the address resolution protocol cache table is updated; A second address checking module, configured to check whether the current Internet address of the terminal has changed if the media access control address of the terminal exists in the address resolution protocol cache table; The Internet address module is used to update the Internet address of the terminal in the second binding relationship when the current Internet address of the terminal is inconsistent with the Internet address existing in the dynamic domain name service.
12. The device according to claim 11, characterized in that The public network address of the router and the Internet address of the terminal are both ipv6 addresses.
13. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.