Routing device configuration method, routing device, and computer readable medium

By adaptively modifying the gateway address and address pool range of wireless routing devices, the IP address conflict problem during switching between AP mode and APSTA mode is solved, and configuration adjustment without user perception is achieved, improving network connection stability and user experience.

CN113852482BActive Publication Date: 2025-04-04ZTE CORP
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202010600110.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-28
Publication Date
2025-04-04
Estimated Expiration
2040-06-28

AI Technical Summary

Technical Problem

When the working mode of the wireless routing device switches from AP mode to APSTA mode, or switches connected external hotspots in APSTA mode, the gateway address may be the same as the gateway address of the external hotspot, resulting in IP address conflicts and unable to connect to the network.

Method used

By determining whether the working mode and gateway address of the routing device are the same, adaptively modify the local gateway address and address pool range, configure redirection rules to avoid IP address conflicts, and restore the initial configuration during mode switching.

Benefits of technology

It effectively avoids the bridging failure and inability to access the Internet caused by two identical IP addresses in the same network segment, reduces the user's learning costs and the after-sales costs of equipment manufacturers, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113852482B_ABST
    Figure CN113852482B_ABST
Patent Text Reader

Abstract

The embodiment of the present disclosure provides a configuration method for a routing device, comprising: judging whether it is necessary to modify the configuration information of the routing device according to the working mode of the routing device, wherein the working mode is one of an access point AP mode and an access point / station APSTA mode; when the configuration information needs to be modified, modifying the local gateway address and address pool range. The embodiment of the present disclosure also provides a routing device and a computer-readable medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of communications, and in particular to a configuration method for a routing device, a routing device, and a computer-readable medium. Background Art

[0002] Wireless routers have two working modes: access point (AP) mode and access point / station (APSTA). Among them, AP mode means that the wireless router acts as a wireless access point, providing wireless access services, allowing other wireless devices to access and access data; APSTA mode means that the wireless router acts as both a STA station and a wireless access point AP, that is, AP mode and STA mode coexist.

[0003] When the working mode of the wireless router device is switched between AP mode and APSTA mode, it may be impossible to connect to the network. Summary of the invention

[0004] The embodiments of the present disclosure provide a configuration method for a routing device, a routing device, and a computer-readable medium.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for configuring a routing device, including:

[0006] According to the working mode of the routing device, determining whether the configuration information of the routing device needs to be modified, wherein the working mode is one of an access point AP mode and an access point / station APSTA mode;

[0007] When the configuration information needs to be modified, the local gateway address and address pool range are modified.

[0008] In some embodiments, when the working mode is the APSTA mode, the step of determining whether the configuration information of the routing device needs to be modified includes:

[0009] When accessing an external hotspot, determining whether the current gateway address is the same as the gateway address of the external hotspot;

[0010] When the current gateway address is the same as the gateway address of the external hotspot, it is determined that the configuration information needs to be modified.

[0011] In some embodiments, when the configuration information needs to be modified, after the step of modifying the local gateway address and the address pool range, the configuration method further includes:

[0012] A redirection rule is configured, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

[0013] In some embodiments, the steps of configuring redirection rules include:

[0014] Create redirect chains;

[0015] Adding the redirection rule to the redirection chain;

[0016] The redirection chain is mounted on the pre-classification PREROUTING chain of the network address translation table.

[0017] In some embodiments, when the configuration information needs to be modified, before the step of modifying the local gateway address and address pool range, the configuration method further includes:

[0018] Determine whether the gateway modification flag is a first predetermined value, if the gateway modification flag is the first predetermined value, it indicates that the current gateway address is the initial gateway address, and the current address pool range is the initial address pool range;

[0019] When the gateway storage flag is the first predetermined value, the initial gateway address and the initial address pool range are saved.

[0020] In some embodiments, when the gateway storage flag is the first predetermined value, after the step of modifying the local gateway address and address pool range, the configuration method further includes:

[0021] The gateway modification flag is modified to a second predetermined value. The gateway modification flag being the second predetermined value indicates that the current gateway address is not the initial gateway address, and the current address pool range is not the initial address pool range.

[0022] In some embodiments, the step of modifying the local gateway address and address pool range includes:

[0023] Modify the third segment value of the current gateway address to obtain the modified gateway address;

[0024] Modify the third segment value of the start address and the third segment value of the end address of the current address pool range to obtain the modified address pool range.

[0025] In some embodiments, when the working mode is AP mode, the step of determining whether the configuration information of the routing device needs to be modified includes:

[0026] Determine whether the gateway modification flag is a second predetermined value, where the gateway modification flag is the second predetermined value, indicating that the current gateway address is not the initial gateway address, and the current address pool range is not the initial address pool range;

[0027] When the gateway modification flag is the second predetermined value, determining that the configuration information needs to be modified;

[0028] When the gateway modification flag is not the second predetermined value, it is determined that the configuration information does not need to be modified.

[0029] In some embodiments, when the configuration information needs to be modified, after the step of modifying the local gateway address and the address pool range, the configuration method further includes:

[0030] The redirection rule is deleted, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

[0031] In some embodiments, the step of deleting the redirection rule includes:

[0032] Deleting the redirection chain mounted on the PREROUTING chain of the network address translation table, wherein the redirection chain carries the redirection rule;

[0033] Delete said redirect chain.

[0034] In some embodiments, when the gateway modification flag is the second predetermined value, the step of modifying the local gateway address and address pool range includes:

[0035] Read the initial gateway address and the initial address pool range stored locally;

[0036] Modify the local gateway address to the initial gateway address;

[0037] The local address pool range is modified to the initial address pool range.

[0038] In some embodiments, when the gateway modification flag is the second predetermined value, after the step of modifying the local gateway address and address pool range, the configuration method further includes:

[0039] The gateway modification flag is modified to a first predetermined value. The gateway modification flag being the first predetermined value indicates that the current gateway address is the initial gateway address and the current address pool range is the initial address pool range.

[0040] In some embodiments, when the configuration information needs to be modified, the steps of modifying the local gateway address and address pool range include:

[0041] Writing the modified gateway address and the modified address pool range into the non-volatile random access memory NVRAM;

[0042] End the current DNSMASQ process;

[0043] Configuring DNSMASQ information, wherein the DNSMASQ information includes a modified gateway address and a modified address pool range;

[0044] Create and start the DNSMASQ process.

[0045] In some embodiments, when the configuration information needs to be modified, the step of modifying the local gateway address and address pool range further includes:

[0046] Configure the modified gateway address and the modified address pool range on the bridge.

[0047] In some embodiments, when the configuration information needs to be modified, after the step of modifying the local gateway address and the address pool range, the configuration method further includes:

[0048] The terminal currently connected to the routing device is disconnected so that the terminal can reconnect to the routing device and obtain an address within the modified address pool range.

[0049] In a second aspect, an embodiment of the present disclosure provides a routing device, including:

[0050] A storage module on which an executable program is stored;

[0051] One or more processors, wherein the one or more processors are capable of calling the executable program so that the one or more processors implement any one of the above-mentioned configuration methods for a routing device;

[0052] One or more I / O interfaces are connected between the processor and the memory and are configured to implement information interaction between the processor and the memory.

[0053] In a third aspect, an embodiment of the present disclosure provides a computer-readable medium having an executable program stored thereon, and when the executable program is executed, any of the above-mentioned configuration methods for a routing device can be implemented.

[0054] The embodiment of the present disclosure provides a configuration method of a routing device, a routing device for executing the configuration method, and a computer-readable medium storing an executable program capable of implementing the configuration method. In the configuration method of the routing device provided in the embodiment of the present disclosure, when the routing device switches from AP mode to APSTA mode, or switches to an external hotspot connected in APSTA mode, the routing device can determine whether the local gateway address is the same as the gateway address of the external hotspot, and adaptively modify the local gateway address and address pool range when they are the same, so as to avoid the occurrence of two identical IP addresses in the same network segment, resulting in bridging failure and inability to access the Internet; in addition, when the routing device switches from APSTA mode to AP mode, the routing device can also change the local gateway address range back to the initial configuration. In this embodiment, when the routing device adaptively modifies the configuration information including the gateway address and the address pool range, the user is not aware of it, and no manual assistance is required by the user, thereby reducing the user's learning cost, improving the user's experience, and saving the after-sales cost of the equipment manufacturer. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 This is a flow chart of a method for configuring a routing device in an embodiment of the present disclosure;

[0056] Figure 2 A flowchart of some steps in another method for configuring a routing device in an embodiment of the present disclosure;

[0057] Figure 3 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0058] Figure 4 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0059] Figure 5 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0060] Figure 6 This is a flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0061] Figure 7 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0062] Figure 8 This is a flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0063] Fig. 9 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0064] Fig.10 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0065] Fig.11 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0066] Fig.12 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0067] Fig.13 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0068] Fig.14 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0069] Fig.15 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0070] Fig.16 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0071] Fig.17 A flowchart of some steps in a configuration method of a routing device in another embodiment of the present disclosure;

[0072] Fig.18 A schematic diagram of functional modules in another method for configuring a routing device in an embodiment of the present disclosure;

[0073] Fig.19 A block diagram of a routing device according to an embodiment of the present disclosure;

[0074] Fig. 20 The present invention is a block diagram of a computer-readable medium in an embodiment of the present invention. DETAILED DESCRIPTION

[0075] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, the configuration method of the routing device, the routing device, and the computer-readable medium provided by the present disclosure are described in detail below with reference to the accompanying drawings.

[0076] Example embodiments will be described more fully below with reference to the accompanying drawings, but the example embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. On the contrary, the purpose of providing these embodiments is to make the present disclosure thorough and complete and to enable those skilled in the art to fully understand the scope of the present disclosure.

[0077] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0078] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0079] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a", "an" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded.

[0080] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.

[0081] The inventor of the present disclosure has found that when the wireless routing device switches from AP mode to APSTA mode and accesses an external hotspot, or in APSTA mode, when the external hotspot connected is changed, the gateway address of the external hotspot accessed may be the same as the gateway address of the wireless routing device. When two identical IP addresses appear in the same network segment, it violates the network protocol regulations, and the wireless routing bridge fails due to the IP address conflict and cannot connect to the network. In the prior art, when the gateway address of the external hotspot accessed may be the same as the gateway address of the wireless routing device, resulting in the inability to connect to the network, the most common solution is for the user to manually modify the gateway address, address pool range and other configuration information of the wireless routing device; in another prior art, the wireless routing device will give prompt information for configuring the gateway address, address pool range, etc., to guide the user to complete the modification of the relevant configuration information. However, the above-mentioned prior art solutions are all for the user to manually modify the configuration information, which will cause network interruption and affect the user experience. Moreover, manual configuration by the user will increase the user's learning cost, and a large amount of after-sales cost will be required to respond to users asking customer service for help.

[0082] In view of this, firstly, refer to Figure 1 , the present disclosure provides a configuration method for a routing device, including:

[0083] In step S100, it is determined whether the configuration information of the routing device needs to be modified according to the working mode of the routing device, wherein the working mode is one of an access point AP mode and an access point / station APSTA mode;

[0084] In step S200, when the configuration information needs to be modified, the local gateway address and address pool range are modified.

[0085] In the embodiment of the present disclosure, judging whether the configuration information of the routing device needs to be modified includes but is not limited to the following scenarios:

[0086] The working mode of the routing device is switched from the AP mode to the APSTA mode, the routing device is connected to an external hotspot, and it is determined whether the configuration information of the routing device needs to be modified to avoid a conflict between the gateway address of the routing device and the gateway address of the external hotspot that is connected;

[0087] The working mode of the routing device is APSTA mode, the routing device is connected to a new external hotspot, and it is determined whether the configuration information of the routing device needs to be modified to avoid a conflict between the gateway address of the routing device and the gateway address of the new external hotspot;

[0088] The working mode of the routing device is switched from APSTA mode to AP mode, and it is determined whether the configuration information of the routing device needs to be modified so that the gateway address of the routing device in AP mode is the initial gateway address and the address pool range is the initial address pool range.

[0089] It should be noted that, in step S200, the modified gateway address and the modified address pool range are set in the same network segment.

[0090] When the configuration information needs to be modified, after the local gateway address and address pool range are modified in step S200, the Internet Protocol (IP) address obtained by the terminal connected to the routing device is the IP address in the modified address pool range. This can avoid IP conflicts caused by two identical IP addresses in the same network segment, ensuring that the terminal can connect to the network normally.

[0091] In the configuration method of the routing device provided in the embodiment of the present disclosure, when the routing device switches from AP mode to APSTA mode, or switches the connected external hotspot in APSTA mode, the routing device can determine whether the local gateway address is the same as the gateway address of the external hotspot, and adaptively modify the local gateway address and address pool range when they are the same, so as to avoid the occurrence of two identical IP addresses in the same network segment, resulting in bridging failure and inability to access the Internet; in addition, when the routing device switches from APSTA mode to AP mode, the routing device can also change the local gateway address range back to the initial configuration. In this embodiment, when the routing device adaptively modifies the configuration information including the gateway address and the address pool range, the user is unaware and does not need manual assistance from the user, thereby reducing the user's learning cost, improving the user's experience, and saving the after-sales cost of the equipment manufacturer.

[0092] As described above, in the embodiment of the present disclosure, when the working mode of the routing device is APSTA mode, judging whether the configuration information of the routing device needs to be modified includes but is not limited to the following scenarios: the working mode of the routing device is switched from AP mode to APSTA mode, and the routing device is connected to an external hotspot; the routing device is connected to a new external hotspot. In the above scenarios, when the current gateway address is the same as the gateway address of the external hotspot, the routing device automatically modifies the local gateway address and address pool range to avoid conflicts between the gateway address of the routing device and the gateway address of the new external hotspot.

[0093] Accordingly, refer to Figure 2 In some embodiments, when the working mode is APSTA mode, step S100 includes:

[0094] In step S110, when accessing an external hotspot, it is determined whether the current gateway address is the same as the gateway address of the external hotspot;

[0095] When the current gateway address is the same as the gateway address of the external hotspot, determining that the configuration information needs to be modified;

[0096] When the current gateway address is different from the gateway address of the external hotspot, it is determined that the configuration information does not need to be modified.

[0097] It should be noted that before step S110, after the routing device accesses the external hotspot, it will obtain information such as the IP address and the gateway address of the external hotspot from the external hotspot, and then execute step S110.

[0098] As an optional implementation, the routing device uses the BusyBox udhcpc tool to obtain information such as the IP address and the gateway address of the external hotspot from the external hotspot.

[0099] It should be noted that when the routing device accesses an external hotspot as a STA site, it obtains information such as IP address, gateway address, and Domain Name System (DNS) server address according to the Dynamic Host Configuration Protocol (DHCP). DHCP is formerly known as the Bootstrap Protocol (BOOTP), which is usually used in a local area network environment. Its main function is to centrally manage and allocate IP addresses, so that clients in the network environment can dynamically obtain information such as IP address, gateway address, and DNS server address, and can improve the usage rate of addresses.

[0100] Under the DHCP protocol, the steps for a routing device to obtain an IP address include: the routing device, as a DHCP client, sends a DHCP DISCOVER packet; after receiving the DHCP DISCOVER, the server sends a DHCP OFFER response packet, which includes information such as the IP address assigned to the DHCP client, the MAC address of the DHCP client, the lease expiration time, and the server's identifier; the DHCP client responds to the DHCP OFFER sent by the server and responds to the DHCP REQUEST packet; after receiving the DHCP REQUEST sent by the DHCP client, the server sends a DHCP ACK message to confirm success. After receiving the DHCP ACK message, the DHCP client confirms that the IP address and other information assigned by the server are available.

[0101] It should also be noted that when the routing device is connected to an external hotspot as a STA site and obtains information such as the IP address, gateway address, and DNS server address based on DHCP, the BusyBox udhcpc tool is used.

[0102] BusyBox is a software that integrates more than 300 most commonly used Linux commands and tools. BusyBox includes simple tools such as ls, cat, echo, and complex tools such as grep, find, mount, and telnet. Among them, udhcpc is a DHCP client for embedded systems in BusyBox. Routing devices can automatically obtain information such as IP addresses and gateway addresses of external hotspots through the BusyBox udhcpc tool.

[0103] In the embodiment of the present disclosure, after the terminal is connected to the routing device, the user configures the routing device through a web user interface (Web UI, WebUser Interface). The address of the Web UI is usually the initial gateway address, or the domain name of the Web UI points to the initial gateway address. In the embodiment of the present disclosure, when the configuration information including the gateway address and the address pool range is modified, by adding a redirection rule in the routing device, the data accessing the initial gateway address is redirected to the modified gateway address, so that the user can still access the Web UI of the routing device through the initial gateway address, thereby making the user unaware of the process of the routing device adaptively modifying the configuration information including the gateway address and the address pool range.

[0104] Accordingly, refer to Figure 3 In some embodiments, when the configuration information needs to be modified, after step S200, the configuration method further includes:

[0105] In step S310, a redirection rule is configured, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

[0106] As an optional implementation, a redirection rule is added to a Network Address Translation (NAT) table of a routing device.

[0107] Accordingly, refer to Figure 4 In some embodiments, step S300 specifically includes:

[0108] In step S311, a redirect chain is created;

[0109] In step S312, the redirection rule is added to the redirection chain;

[0110] In step S313, the redirection chain is mounted to the pre-classification PREROUTING chain of the network address translation NAT table.

[0111] It should be noted that when the router accesses a new external hotspot in APSTA mode, the router may have redirection rules already mounted in the NAT table. In this case, the redirection rules already mounted in the NAT table need to be deleted first.

[0112] Accordingly, before step S301, step S300 further includes:

[0113] Delete the redirection chain mounted on the PREROUTING chain of the NAT table;

[0114] Delete said redirect chain.

[0115] In the disclosed embodiment, a gateway modification flag is set in the routing device, and the gateway modification flag has at least two states, and the first predetermined value and the second predetermined value correspond to the two states respectively. When the gateway modification flag is the first predetermined value, it indicates that the current gateway address is the initial gateway address and the current address pool range is the initial address pool range; when the gateway modification flag is the second predetermined value, it indicates that the current gateway address is not the initial gateway address and the current address pool range is not the initial address pool range. As an optional implementation, when the gateway modification flag is the first predetermined value, if it is necessary to modify configuration information such as the gateway address and the address pool range, it is necessary to first back up and store the initial gateway address and the initial address pool range, so that when the routing device switches to AP mode, the configuration information can be restored according to the backed-up stored initial gateway address and the initial address pool range.

[0116] Accordingly, refer to Figure 5 In some embodiments, when the configuration information needs to be modified, before step S200, the configuration method further includes:

[0117] In step S411, it is determined whether the gateway modification flag is a first predetermined value, and if the gateway modification flag is the first predetermined value, it indicates that the current gateway address is the initial gateway address, and the current address pool range is the initial address pool range;

[0118] In step S412, when the gateway storage flag is the first predetermined value, the initial gateway address and the initial address pool range are saved.

[0119] Accordingly, refer to Figure 5 In some embodiments, when the gateway storage flag is the first predetermined value, after step S200, the configuration method further includes:

[0120] In step S413, the gateway modification flag is modified to a second predetermined value. The gateway modification flag being the second predetermined value indicates that the current gateway address is not the initial gateway address, and the current address pool range is not the initial address pool range.

[0121] Reference Figure 6 In some embodiments, step S200 includes:

[0122] In step S211, the third segment value of the current gateway address is modified to obtain a modified gateway address;

[0123] In step S212, the third segment value of the start address and the third segment value of the end address of the current address pool range are modified to obtain a modified address pool range.

[0124] It should be noted that in step S201 and step S202, the change in the third segment value of the gateway address should be equal to the change in the third segment value of the starting address of the address pool range and the change in the third segment value of the ending address, so that the modified gateway address and the modified address pool range are in the same network segment.

[0125] In an embodiment of the present disclosure, if the routing device modifies the gateway address and the address pool range in APSTA mode, when switching to AP mode, the gateway address and the address pool range need to be restored to the initial gateway address and the initial address pool range. As described above, in an embodiment of the present disclosure, a gateway modification flag is set in the routing device, and the gateway modification flag has at least two states, and the two states are respectively corresponded to a first predetermined value and a second predetermined value. In the APSTA mode, when the routing device modifies configuration information such as the gateway address and the address pool range, the initial gateway address and the initial address pool range are first backed up and stored, and the gateway modification flag is modified to the second predetermined value after the modification. As an optional implementation, when the routing device is in AP mode, the gateway modification flag is used to determine whether it is necessary to restore the gateway address and the address pool range to the initial gateway address and the initial address pool range.

[0126] Accordingly, refer to Figure 7 In some embodiments, when the working mode is AP mode, step S100 includes:

[0127] In step S120, it is determined whether the gateway modification flag is a second predetermined value, and if the gateway modification flag is the second predetermined value, it indicates that the current gateway address is not the initial gateway address, and the current address pool range is not the initial address pool range;

[0128] When the gateway modification flag is the second predetermined value, determining that the configuration information needs to be modified;

[0129] When the gateway modification flag is not the second predetermined value, it is determined that the configuration information does not need to be modified.

[0130] As described above, when the configuration information including the gateway address and the address pool range is modified in the APSTA mode of the routing device, the data accessing the initial gateway address is redirected to the modified gateway address by adding a redirection rule in the routing device, so that the user can still access the Web UI of the routing device through the initial gateway address. When the routing device is switched to the AP mode and the gateway address and the address pool range are restored to the initial gateway address and the initial address pool range, the redirection rule must be deleted to allow the user to normally access the Web UI of the routing device through the initial gateway address.

[0131] Accordingly, refer to Figure 8In some embodiments, when the configuration information needs to be modified, after step S200, the configuration method further includes:

[0132] In step S320, the redirection rule is deleted, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

[0133] As an optional implementation method, the redirection rule is mounted in a network address translation (NAT) table of the routing device.

[0134] Accordingly, refer to Fig. 9 In some embodiments, step S320 includes:

[0135] In step S321, the redirection chain mounted on the PREROUTING chain of the NAT table is deleted, and the redirection chain carries the redirection rule;

[0136] In step S322, the redirection chain is deleted.

[0137] As described above, when the routing device is in APSTA mode, when modifying configuration information such as the gateway address and the address pool range, the initial gateway address and the initial address pool range are first backed up and stored, and after the modification, the gateway modification flag is modified to a second predetermined value. When the routing device switches to AP mode, the configuration information of the routing device can be restored by reading the locally stored initial gateway address and the initial address pool range.

[0138] Accordingly, refer to Fig.10 In some embodiments, when the gateway modifies the flag bit to the second predetermined value, step S200 includes:

[0139] In step S221, the initial gateway address and the initial address pool range stored locally are read;

[0140] In step S222, the local gateway address is modified to the initial gateway address;

[0141] In step S223, the local address pool range is modified to the initial address pool range.

[0142] In the embodiment of the present disclosure, after the routing device switches to AP mode and restores the gateway address to the initial gateway and modifies the address pool range to the initial address pool range, it is also necessary to modify the gateway modification flag to a first predetermined value to identify the current gateway address as the initial gateway address and the current address pool range as the initial address pool range.

[0143] Accordingly, refer to Fig.11In some embodiments, when the gateway modification flag is the second predetermined value, after step S200, the configuration method further includes:

[0144] In step S420, the gateway modification flag is modified to a first predetermined value, and the gateway modification flag being the first predetermined value indicates that the current gateway address is the initial gateway address, and the current address pool range is the initial address pool range.

[0145] It should be noted that in the embodiment of the present disclosure, configuration information such as the gateway address, address pool range, gateway modification flag, etc. of the routing device are all stored in the non-volatile random access memory (NVRAM, Non-Volatile Random Access Memory) in the routing device; the backup initial gateway address and initial address pool range are also stored in the NVRAM.

[0146] As an optional implementation, the routing device in the embodiment of the present disclosure automatically allocates IP addresses to the terminals connected to the routing device through the DNSMASQ tool. The gateway address and address pool range of the routing device are configured in the DNSMASQ information. When the terminal accesses the routing device, the IP address allocated to the terminal by the DNSMASQ tool is the IP address in the current address pool range of the routing device, and the allocated gateway address is the current gateway address of the routing device. In the routing device, the automatic allocation of IP addresses and gateway addresses is achieved by running the DNSMASQ process. In the embodiment of the present disclosure, after modifying the gateway address and address pool range and writing the modified gateway address and address pool range to NVRAM, it is also necessary to reconfigure the DNSMASQ information and start the DNSMASQ process configured with the modified gateway address and the modified address pool range, so that the IP address allocated to the terminal newly connected to the routing device is the IP address in the modified address pool range, so as to ensure that the terminal can connect to the network normally.

[0147] Accordingly, refer to Fig.12 In some embodiments, when the configuration information needs to be modified, step S200 includes:

[0148] In step S230, the modified gateway address and the modified address pool range are written into the non-volatile random access memory NVRAM;

[0149] In step S241, the current DNSMASQ process is terminated;

[0150] In step S242, DNSMASQ information is configured, wherein the DNSMASQ information includes the modified gateway address and the modified address pool range;

[0151] In step S243, a DNSMASQ process is created and started.

[0152] It should be noted that DNSMASQ is a small and convenient tool for configuring DNS and DHCP. It is suitable for small networks and provides DNS functions and optional DHCP functions. As a DHCP server, the DNSMASQ tool can automatically assign IP addresses to clients such as PCs and mobile phones connected to wireless routers.

[0153] As an optional implementation manner, the DNSMASQ process is a DNSMASQ DHCP server process.

[0154] In some embodiments, reference Fig.12 When the configuration information needs to be modified, step S200 also includes:

[0155] In step S250, the modified gateway address and the modified address pool range are configured on the bridge.

[0156] After the gateway address and address pool range of the routing device are modified through steps S100 to S200, the IP address assigned to the terminal previously connected to the routing device will remain the IP address within the address pool range before the modification, and thus cannot connect to the network normally. In the embodiment of the present disclosure, after the gateway address and address pool range of the routing device are modified, the connection with the terminal previously connected to the routing device will be disconnected, so that the terminal can obtain the IP address within the modified address pool range and the modified gateway address by re-accessing the routing device.

[0157] Accordingly, refer to Fig.13 In some embodiments, when the configuration information needs to be modified, after step S200, the configuration method further includes:

[0158] In step S500, the terminal currently connected to the routing device is disconnected so that the terminal can reconnect to the routing device and obtain an address within the modified address pool range.

[0159] It should be noted that the embodiment of the present disclosure does not specifically limit the specific method of disconnecting the terminal currently connected to the routing device. For example, the WiFi connection of the currently connected terminal can be directly disconnected, or the USB network card can be disabled and then enabled.

[0160] It should also be noted that the terminal described in the embodiments of the present disclosure includes but is not limited to a personal computer (PC), a mobile phone, etc.

[0161] In order to enable those skilled in the art to more clearly understand the technical solution provided by the present invention, the technical solution provided by the present invention is described in detail below through specific embodiments:

[0162] Embodiment 1

[0163] like Fig.14 As shown, this embodiment 1 provides a process for a routing device to connect to an external hotspot in APSTA mode and adaptively modify configuration information and adaptively restore configuration information in AP mode.

[0164] The gateway modification flag is gateway_change_flag. In this embodiment, the value of gateway_change_flag is empty, indicating that the gateway modification flag is the first predetermined value; the value of gateway_change_flag is 1, indicating that the gateway modification flag is the second predetermined value. In this embodiment, the IP address obtained by the routing device from the external hotspot in APSTA mode is saved in station_ip_addr, and the gateway address of the external hotspot obtained from the external hotspot is saved in gateway_gw_by_dhcp. In this embodiment, it also includes a gateway restoration flag restoring_gateway_flag. When the value of restoring_gateway_flag is 1, it indicates that the local gateway address needs to be restored to the initial gateway address when the routing device switches to AP mode; when the value of restoring_gateway_flag is 0, it indicates that the local gateway address of the routing device has been restored to the initial gateway address.

[0165] The process of the routing device connecting to an external hotspot in APSTA mode and adaptively modifying configuration information and adaptively restoring configuration information in AP mode includes:

[0166] Step 11: Check whether the gateway_change_flag currently stored in the routing device is empty. If so, back up and save the configuration information such as the initial gateway address and the initial address pool range of the routing device, and change the value of gateway_change_flag to 1; if gateway_change_flag is not empty, execute step 12;

[0167] Step 12: If the current working mode of the routing device is not one of the AP mode and the APSTA mode, then exit the process; if it is, proceed to step 13;

[0168] Step 13: If the current working mode of the routing device is AP mode, execute step 17; if the current working mode of the routing device is APSTA mode, determine whether the value of station_ip_addr is empty; if the value of station_ip_addr is empty, exit the process; if the value of station_ip_addr is not empty, execute step 14;

[0169] Step 14: If the current working mode of the routing device is APSTA mode, determine whether the value of gateway_gw_by_dhcp is empty; if the value of gateway_gw_by_dhcp is empty, exit the process; if the value of gateway_gw_by_dhcp is not empty, execute step 15;

[0170] Step 15: Determine whether the value of gateway_gw_by_dhcp is the same as the local gateway address of the routing device. If they are the same, execute step 16; if they are different, exit the process;

[0171] Step 16: Execute the process of adaptively modifying the local gateway address of the routing device, including: adaptively modifying the local gateway address, address pool range and other configuration information; ending the initial DNSMASQ dhcp server process, generating a new DNSMASQ configuration file, wherein the modified gateway address, modified address pool range and other configuration information are configured in the DNSMASQ configuration file, and starting a new DNSMASQ dhcp server process according to the new DNSMASQ configuration file; configuring the modified gateway address on the bridge; adding a redirection rule in the NAT table to redirect all data accessing the initial gateway address to the modified gateway address; setting the value of restoring_gateway_flag to 1; and setting the value of gateway_change_flag to 1.

[0172] Step 17: Execute the process of adaptively restoring configuration information, including: determine whether the value of restoring_gateway_flag is 1, if not, exit the process; if so, adaptively restore the local gateway address to the initial gateway address, and restore the local address pool range to the initial address pool range; end the current DNSMASQ dhcp server process, generate a new DNSMASQ configuration file, in which the initial gateway address, initial address pool range and other configuration information are configured, and start a new DNSMASQ dhcp server process according to the new DNSMASQ configuration file; configure the initial gateway address on the bridge; configure firewall rules and NAT table rules, and redirection rules mounted on the NAT table; set the value of restoring_gateway_flag to 0; set the value of gateway_change_flag to empty.

[0173] Embodiment 2

[0174] like Fig.15 As shown, this embodiment 2 provides a process for a routing device to adaptively modify configuration information in APSTA mode.

[0175] Step 21: respectively modify the current gateway address of the routing device, and the third segment values ​​of the start and end IP addresses of the address pool range. If the third segment value is equal to 255, set it to 0; if the third segment value is not equal to 255, add 1 to the original third segment value to obtain the modified gateway address and the modified address pool range; save the modified gateway address and address pool range in the NVRAM of the routing device;

[0176] Step 22: Generate a new DNSMASQ configuration file, which is configured with the modified gateway address, the modified address pool range, and the DHCP lease time, etc.

[0177] Step 23: Add a redirection rule to redirect all data whose destination address is the initial gateway address to the modified gateway address;

[0178] Step 24: Configure the modified gateway address on the bridge;

[0179] Step 25: End the initial DNSMASQ DHCP server process and start a new DNSMASQ DHCP server process according to the new DNSMASQ configuration file;

[0180] Step 26: Set the value of restoring_gateway_flag to 1;

[0181] Step 27: Disable and enable the USB network card, disconnect the currently connected WiFi terminal, and ensure that the PC, mobile phone and other terminals re-obtain the correct IP address.

[0182] Embodiment 3

[0183] like Fig.16 As shown, this third embodiment provides a process for adding redirection rules after the routing device connects to an external hotspot in APSTA mode and adaptively modifies configuration information.

[0184] Step 31: Delete the redirect chain redirect_webui mounted on the PREROUTING chain of the NAT table.

[0185] Step 32: Erase, delete the redirect chain redirect_webui.

[0186] Step 33: Create a new redirect chain redirect_webui.

[0187] Step 34: Add a redirection rule on the redirection chain redirect_webui, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

[0188] Step 35: Mount the newly created redirect chain redirect_webui to the PREROUTING chain of the NAT table.

[0189] Embodiment 4

[0190] like Fig.17 As shown, this fourth embodiment provides a process for adaptively restoring configuration information in AP mode.

[0191] Step 40: Read the initial gateway address, initial address pool range, DHCP lease time and other information stored in the routing device;

[0192] Step 41: Generate a new DNSMASQ configuration file according to the initial gateway address, initial address pool range, DHCP lease time and other information;

[0193] Step 42: End the current DNSMASQ process;

[0194] Step 43: Delete the redirect chain redirect_webui mounted on the NAT table PREROUTING chain;

[0195] Step 44: Delete the redirect chain redirect_webui;

[0196] Step 45: Configure the initial gateway address on the bridge;

[0197] Step 46: Save the initial gateway address and the initial address pool range in the NVRAM of the routing device;

[0198] Step 47: Start a new DNSMASQ process according to the newly generated DNSMASQ configuration file.

[0199] Step 48: Set the value of restoring_gateway_flag to 0, and set the value of Gateway_change_flag to null;

[0200] Step 49: Disable and enable the USB network card, disconnect the currently connected WiFi terminal, and ensure that the PC, mobile phone and other terminals re-obtain the correct IP address.

[0201] Embodiment 5

[0202] like Fig.18 As shown, in the fifth embodiment, the routing device includes five functional modules: a WiFi module, a main control module, a networking / disconnecting module, a routing module, and a redirection module.

[0203] The functions of the WiFi module are as follows:

[0204] When the routing device connects to an external hotspot in APSTA mode, the WiFi module completes the physical mode identity authentication of the 802.11 user; associates with the external hotspot by initiating an Assoc request; identifies the WiFi network of the connected external hotspot; confirms the WiFi authentication method and encryption algorithm of the external hotspot and completes the handshake; and reports the WiFi connection status with the external hotspot to the main control module.

[0205] After the routing device disconnects the WiFi hotspot in APSTA mode, or switches from APSTA mode to AP mode, the WiFi module reports the WiFi connection status or mode switching status to the main control module.

[0206] The functions of the main control module are as follows:

[0207] The main control module is mainly responsible for the power on and off process of the routing device, WiFi and mobile Internet dial-up priority switching, factory reset, battery power status maintenance, APN matching, and the logic of coordinated control between other modules.

[0208] The main control module detects the current WiFi connection status according to the connection status reported by the WiFi module; if the connection is successful, the routing module is notified to obtain the IP address and switch the route; after successfully connecting to the external hotspot and adding the default route, the mobile Internet connection status of the routing device is checked according to the information reported by the routing module. If the mobile Internet connection is successful, the mobile Internet connection is disconnected through the networking / disconnection module; the routing device disconnects the WiFi hotspot in APSTA mode, or notifies the networking / disconnection module to connect to the mobile Internet after switching from APSTA mode to AP mode.

[0209] The functions of the networking / disconnection module are as follows:

[0210] Dial-up networking is performed according to the dial-up mode set by the user. If it is automatic dialing, the automatic dial-up networking process is initiated every time the device is turned on; if it is manual dialing, dial-up networking is performed in response to the dial-up instruction initiated by the user through the Web UI; if disconnection is required, the disconnection operation is performed in response to the disconnection instruction initiated by the user through the Web UI.

[0211] After the routing device accesses an external hotspot in APSTA mode, it disconnects the mobile Internet connection in response to the disconnection message sent by the main control module; after the routing device disconnects the WiFi hotspot in APSTA mode, or switches from APSTA mode to AP mode, it responds to the networking message sent by the main control module and dials up to connect to the Internet according to the dial-up method set by the user.

[0212] The functions of the routing module are as follows:

[0213] The routing module is mainly responsible for setting the default route, configuring the firewall, NAT rules, etc.

[0214] When the routing device is connected to an external hotspot in APSTA mode, the routing module starts the BusyBox udhcpc tool to obtain the IP address, gateway and other information from the external hotspot, and determines whether the gateway address of the external hotspot is the same as the local gateway address; if the same, the local gateway address, address pool range and other configuration information are adaptively modified; the initial DNSMASQ dhcp server process is ended, and a new DNSMASQ configuration file is generated, in which the modified gateway address, modified address pool range and other configuration information are configured, and a new DNSMASQ dhcp server process is started according to the new DNSMASQ configuration file; the modified gateway address is configured on the bridge; a redirection rule is added to the NAT table to redirect all data with the initial gateway address as the access destination address to the modified gateway address; the value of restoring_gateway_flag is set to 1; the value of gateway_change_flag is set to 1.

[0215] After the routing device switches from APSTA mode to AP mode, it determines whether the value of restoring_gateway_flag is 1. If not, exit the process; if so, adaptively restore the local gateway address to the initial gateway address, and restore the local address pool range to the initial address pool range; end the current DNSMASQdhcp server process, generate a new DNSMASQ configuration file, in which the initial gateway address, initial address pool range and other configuration information are configured, and start a new DNSMASQdhcp server process according to the new DNSMASQ configuration file; configure the initial gateway address on the bridge; configure firewall rules and NAT table rules, and redirection rules mounted on the NAT table; set the value of restoring_gateway_flag to 0; and set the value of gateway_change_flag to empty.

[0216] After the routing device disconnects the WiFi hotspot in APSTA mode, or switches from APSTA mode to AP mode, it configures firewall rules and NAT table rules in response to the notification of the main control module; in response to the notification of the networking / disconnection module, it completes operations such as configuring the default route.

[0217] The functions of the redirection module are as follows:

[0218] The routing device connects to an external hotspot in APSTA mode, adaptively modifies the local gateway address, address pool range and other configuration information, and then adds a redirection rule in the NAT table in response to the notification of the routing module to redirect the data accessing the initial gateway address to the modified gateway address; after the routing device switches from APSTA mode to AP mode, the initial gateway address of the device is restored, and the redirection self-built chain mounted on the PREROUTING chain of the NAT table and the redirection rule added on the chain are erased and deleted.

[0219] Second, refer to Fig.19 , an embodiment of the present disclosure provides a routing device, comprising:

[0220] One or more processors 101;

[0221] A memory 102, on which one or more programs are stored, and when the one or more programs are executed by one or more processors, the one or more processors implement any of the above-mentioned configuration methods for routing devices;

[0222] One or more I / O interfaces 103 are connected between the processor and the memory and are configured to implement information exchange between the processor and the memory.

[0223] Among them, the processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU) and the like; the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 103 is connected between the processor 101 and the memory 102, and can realize information interaction between the processor 101 and the memory 102, including but not limited to a data bus (Bus) and the like.

[0224] In some embodiments, the processor 101 , the memory 102 , and the I / O interface 103 are connected to each other via a bus 104 , and further connected to other components of the computing device.

[0225] The configuration method of the routing device has been described in detail above and will not be repeated here.

[0226] Thirdly, refer to Fig. 20 The embodiment of the present disclosure provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, any of the above-mentioned configuration methods of a routing device is implemented.

[0227] The configuration method of the routing device has been described in detail above and will not be repeated here.

[0228] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0229] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.

Claims

1. A method for configuring a routing device, comprising: According to the working mode of the routing device, determining whether the configuration information of the routing device needs to be modified; When the configuration information needs to be modified, modify the local gateway address and address pool range; When the working mode is the access point AP mode, the step of determining whether the configuration information of the routing device needs to be modified includes: Determine whether the gateway modification flag is a second predetermined value, where the gateway modification flag is the second predetermined value, indicating that the current gateway address is not the initial gateway address, and the current address pool range is not the initial address pool range; When the gateway modification flag is the second predetermined value, determining that the configuration information needs to be modified; When the gateway modification flag is not the second predetermined value, it is determined that the configuration information does not need to be modified.

2. The configuration method according to claim 1, wherein: When the working mode is the access point / station APSTA mode, the step of determining whether the configuration information of the routing device needs to be modified includes: When accessing an external hotspot, determining whether the current gateway address is the same as the gateway address of the external hotspot; When the current gateway address is the same as the gateway address of the external hotspot, it is determined that the configuration information needs to be modified.

3. The configuration method according to claim 2, wherein: When the configuration information needs to be modified, after the step of modifying the local gateway address and the address pool range, the configuration method further includes: A redirection rule is configured, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

4. The configuration method according to claim 3, wherein: The steps to configure redirection rules include: Create redirect chains; Adding the redirection rule to the redirection chain; The redirection chain is mounted on the pre-classification PREROUTING chain of the network address translation table.

5. The configuration method according to claim 2, wherein: When the configuration information needs to be modified, before the step of modifying the local gateway address and the address pool range, the configuration method further includes: Determine whether the gateway modification flag is a first predetermined value, if the gateway modification flag is the first predetermined value, it indicates that the current gateway address is the initial gateway address, and the current address pool range is the initial address pool range; When the gateway modification flag is the first predetermined value, the initial gateway address and the initial address pool range are saved.

6. The configuration method according to claim 5, wherein: When the gateway modification flag is the first predetermined value, after the step of modifying the local gateway address and the address pool range, the configuration method further includes: The gateway modification flag is modified to a second predetermined value. The gateway modification flag being the second predetermined value indicates that the current gateway address is not the initial gateway address, and the current address pool range is not the initial address pool range.

7. The configuration method according to any one of claims 1 to 6, wherein: The steps to modify the local gateway address and address pool range include: Modify the third segment value of the current gateway address to obtain the modified gateway address; Modify the third segment value of the start address and the third segment value of the end address of the current address pool range to obtain the modified address pool range.

8. The configuration method according to claim 1, wherein: When the configuration information needs to be modified, after the step of modifying the local gateway address and the address pool range, the configuration method further includes: The redirection rule is deleted, wherein the redirection rule includes redirecting data accessing the initial gateway address to the modified gateway address.

9. The configuration method according to claim 8, wherein: To delete a redirection rule: Deleting the redirection chain mounted on the PREROUTING chain of the network address translation table, wherein the redirection chain carries the redirection rule; Delete said redirect chain.

10. The configuration method according to claim 1, wherein: When the gateway modification flag is the second predetermined value, the step of modifying the local gateway address and address pool range includes: Read the initial gateway address and the initial address pool range stored locally; Modify the local gateway address to the initial gateway address; The local address pool range is modified to the initial address pool range.

11. The configuration method according to claim 1, wherein: When the gateway modification flag is the second predetermined value, after the step of modifying the local gateway address and the address pool range, the configuration method further includes: The gateway modification flag is modified to a first predetermined value. The gateway modification flag being the first predetermined value indicates that the current gateway address is the initial gateway address and the current address pool range is the initial address pool range.

12. The configuration method according to any one of claims 1 to 6 and 8 to 11, wherein: When the configuration information needs to be modified, the steps of modifying the local gateway address and address pool range include: Writing the modified gateway address and the modified address pool range into the non-volatile random access memory NVRAM; End the current DNSMASQ process; Configuring DNSMASQ information, wherein the DNSMASQ information includes a modified gateway address and a modified address pool range; Create and start the DNSMASQ process.

13. The configuration method according to claim 12, wherein: When the configuration information needs to be modified, the step of modifying the local gateway address and address pool range also includes: Configure the modified gateway address and the modified address pool range on the bridge.

14. The configuration method according to any one of claims 1 to 6 and 8 to 11, wherein: When the configuration information needs to be modified, after the step of modifying the local gateway address and the address pool range, the configuration method further includes: The terminal currently connected to the routing device is disconnected so that the terminal can reconnect to the routing device and obtain an address within the modified address pool range.

15. A routing device, comprising: A storage module on which an executable program is stored; One or more processors, wherein the one or more processors are capable of calling the executable program so that the one or more processors implement the configuration method of the routing device according to any one of claims 1 to 14; One or more I / O interfaces are connected between the processor and the memory and are configured to implement information interaction between the processor and the memory.

16. A computer-readable medium having an executable program stored thereon, wherein the executable program can implement the method for configuring a routing device according to any one of claims 1 to 14 when executed.

Citation Information

Patent Citations

  • WiFi module communication method and device

    CN104468291A