CN115277410B - Gateway adjustment method, device, electronic equipment and storage medium - Google Patents

Gateway adjustment method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115277410B
CN115277410B CN202210931601.9A CN202210931601A CN115277410B CN 115277410 B CN115277410 B CN 115277410B CN 202210931601 A CN202210931601 A CN 202210931601A CN 115277410 B CN115277410 B CN 115277410B
Authority
CN
China
Prior art keywords
wan interface
target
gateway
information
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210931601.9A
Other languages
Chinese (zh)
Other versions
CN115277410A (en
Inventor
曾庆晃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Gongjin Electronics Co Ltd
Original Assignee
Shenzhen Gongjin Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Gongjin Electronics Co Ltd filed Critical Shenzhen Gongjin Electronics Co Ltd
Priority to CN202210931601.9A priority Critical patent/CN115277410B/en
Publication of CN115277410A publication Critical patent/CN115277410A/en
Application granted granted Critical
Publication of CN115277410B publication Critical patent/CN115277410B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • H04L41/0813Configuration setting characterised by the conditions triggering a change of settings
    • H04L41/0816Configuration setting characterised by the conditions triggering a change of settings the condition being an adaptation, e.g. in response to network events
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0668Management of faults, events, alarms or notifications using network fault recovery by dynamic selection of recovery network elements, e.g. replacement by the most appropriate element after failure
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0805Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
    • H04L43/0811Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/10Active monitoring, e.g. heartbeat, ping or trace-route

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Environmental & Geological Engineering (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the invention discloses a gateway adjusting method, a gateway adjusting device, electronic equipment and a storage medium. The method comprises the following steps: polling to check the connection state of each wan interface in the target system every first set time interval, and determining the target wan interface as a default gateway if the connection state of the target wan interface is the connected state; determining whether the current wan interface information is null; and in the case that the current wan interface information is null, polling the connection state of each wan interface every second set time interval, and if the connection state of the target wan interface is in a disconnection state, adjusting the default gateway to be a reference wan interface. According to the scheme provided by the embodiment of the invention, the equipment can be enabled to rapidly switch the link path, and normal network communication and internet surfing experience of a user are not affected.

Description

Gateway adjustment method, device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of communication equipment, in particular to a gateway adjusting method and device, electronic equipment and a storage medium.
Background
In recent years, with the rapid development of network communication technology, the demands of users for usage scenarios are also increasing. Especially for the operator market, the services that operators can offer are becoming more and more, including different internet dial-up types and different virtual local area network (Virtual Local Area Network, vlan) traffic; however, since the device actually has only one physical wide area network (Wide Area Network, wan) port, if multiple wan dialups are needed, a network card virtualization (Media Access Control Address Virtual Local Area Network, macvlan) technology is needed, multiple interfaces with different physical (Media Access Control Address, mac) addresses are virtualized, after the internet protocol (Internet Protocol Address, IP) addresses distributed by different vlan or the same vlan server are acquired, the netifd module of the OpenWRT system automatically sets the default gateway of the device, the domain name resolution server (Domain Name System, DNS) addresses (including IPV4 and IPV 6) and other information, because multiple wan, when the wan interface acquires the IP address, the gateway address and the DNS address, the gateway address covers the default gateway set by the previous interface, and finally the default gateway address is set as the last acquired gateway address, and the DNS address is accumulated; the user in the actual application scenario can arbitrarily designate a wan interface as a default route, and the DNS address can also arbitrarily designate a wan interface acquired DNS address as a unique DNS resolution address; meanwhile, when the specified wan interface is disconnected, other wan addresses which can be used for surfing the internet and corresponding gateway and DNS addresses are required to be replaced immediately; if the gateway and DNS addresses are uncontrolled by default for netifd, if the netifd module is modified directly, the update and maintenance of subsequent netifd is not facilitated.
How to enable a device to quickly switch a link path without affecting the normal network communication and internet surfing experience of a user is a key problem of research in the industry.
Disclosure of Invention
The embodiment of the invention provides a gateway adjusting method, a gateway adjusting device, electronic equipment and a storage medium, which can enable the equipment to rapidly switch a link path without influencing normal network communication and internet surfing experience of a user.
According to an aspect of an embodiment of the present invention, there is provided a gateway adjustment method, including:
polling and checking the connection state of each wan interface in the target system every first set time interval, and determining the target wan interface as a default gateway if the connection state of the target wan interface is the connected state;
determining whether the current wan interface information is null;
and under the condition that the information of the current wan interface is null, polling the connection state of each wan interface every second set time interval, and if the connection state of the target wan interface is in a disconnection state, adjusting a default gateway to be a reference wan interface.
According to another aspect of the embodiment of the present invention, there is provided a gateway adjustment apparatus, including:
The default gateway determining module is configured to poll and check a connection state of each wan interface in the target system every first set time interval, and if the connection state of the target wan interface is a connected state, determine the target wan interface as a default gateway;
the null value determining module is used for determining whether the information of the current wan interface is null value or not;
and the default gateway adjustment module is used for polling the connection state of each wan interface every second set time interval under the condition that the information of the current wan interface is null, and adjusting the default gateway to be a reference wan interface if the connection state of the target wan interface is a disconnection state.
According to another aspect of an embodiment of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the gateway adjustment method according to any one of the embodiments of the present invention.
According to another aspect of the embodiments of the present invention, there is provided a computer readable storage medium storing computer instructions for implementing the gateway adjustment method according to any one of the embodiments of the present invention when executed by a processor.
According to the technical scheme, the connection state of each wan interface in the target system is checked through polling at each first set time interval, and if the connection state of the target wan interface is the connected state, the target wan interface is determined to be a default gateway; determining whether the current wan interface information is null; under the condition that the information of the current wan interface is null, the connection state of each wan interface is polled every second set time interval, and if the connection state of the target wan interface is in a disconnection state, the default gateway is adjusted to be the reference wan interface, so that the device can rapidly switch the link path, and normal network communication and surfing experience of a user are not affected.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention, nor is it intended to be used to limit the scope of the embodiments of the invention. Other features of embodiments of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a gateway adjustment method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of a web-triggered gateway adjustment provided in accordance with a first embodiment of the present invention;
fig. 3 is a schematic diagram of a hotplug triggered gateway adjustment according to a first embodiment of the present invention;
fig. 4 is a flowchart of a gateway adjustment method according to a first embodiment of the present invention;
fig. 5 is a schematic structural diagram of a gateway adjusting device according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device implementing a gateway adjustment method according to an embodiment of the present invention.
Detailed Description
In order to make the embodiments of the present invention better understood by those skilled in the art, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the embodiments of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the embodiments of the present invention and the above-described drawings are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
The term "OpenWRT" as used herein is a highly extended GNU/Linux distribution developed for embedded devices (typically wireless routers).
The term "multi-wan" as used herein refers to a physical wan interface, virtual wan interfaces, and capable of dialing to obtain internet-enabled IP addresses.
The term "DHCPv6 PD" PD as used herein is an abbreviation for Prefix Delegation, a prefix assignment mechanism that causes a device or PC to obtain the global address of IPV6 by obtaining the PD address prefix.
The term "vlan" as used herein is a technique that implements virtual work groups by logically rather than physically dividing devices within a local area network into individual segments.
The term "macvlan" as used herein is a network card virtualization technology that can virtualize a network card into multiple network cards.
The term "netifd" is used herein in OpenWrt for daemons that do network configuration.
The term "ubus" as used herein is an inter-process communication mechanism in OpenWrt, ubusd implements servers, other processes implement clients, and two clients' communications need to be forwarded through a server.
Example 1
Fig. 1 is a flowchart of a gateway adjustment method according to a first embodiment of the present invention, where the method may be performed by a gateway adjustment device, the gateway adjustment device may be implemented in hardware and/or software, and the gateway adjustment device may be configured in an electronic device. Specifically, referring to fig. 1, the method specifically includes the following steps:
And 110, polling and checking the connection state of each wan interface in the target system every first set time interval, and determining the target wan interface as a default gateway if the connection state of the target wan interface is the connected state.
The first set time interval may be 30 seconds, 20 seconds, 60 seconds, or the like, which is not limited in this embodiment, and the target system may be an OpenWRT system or other embedded Linux systems, which is not limited in this embodiment.
In the Internet, a gateway refers to a network device for connecting two or more network segments, and a router is generally used as a gateway. In a TCP/IP network system, the gateway has the basic function of selecting the optimal outlet for forwarding the IP packet according to the network number and the subnet number of the destination IP address, so as to realize data communication across network segments. The gateway is sometimes also considered as this IP address with the data forwarding device, and the gateway should be in the same network segment as the IP address of its subnet. For example, there are a network a and a network B, the IP address range of the network a is "192.168.1.1-192.168.1.254", and the subnet mask is 255.255.255.0; the IP address range of network B is "192.168.2.1 to 192.168.2.254", and the subnet mask is 255.255.255.0. Without a router, TCP/IP communication is not possible between two networks, and even if two networks are connected to the same switch (or hub), the TCP/IP protocol determines that hosts in the two networks are in different networks according to a subnet mask (255.255.255.0). And to enable communication between the two networks, a gateway must be passed. If the host in the network A finds that the destination host of the data packet is not in the local network, the data packet is forwarded to its own gateway, then the gateway is forwarded to the gateway of the network B, and the gateway of the network B is forwarded to a host of the network B. The process of forwarding the data packet from the network B to the network a is also the same, so that the TCP/IP protocol can only realize the intercommunication between different networks if the IP address of the gateway is set. Then what is the IP address of which machine? The IP address of the gateway is the IP address of the device having the routing function, and the device having the routing function includes a router, a server (which is substantially equivalent to a router) having a routing protocol enabled, and a proxy server (which is also equivalent to a router).
Three wan interfaces, for example, a first wan interface, a second wan interface, and a third wan interface, may be included in the target system in this embodiment; the target wan interface may be a wan interface specified by the user, for example, the first wan interface, which is not limited in this embodiment.
In an alternative implementation manner of this embodiment, the connection state of each wan interface in the target system may be checked in a polling manner at intervals of a first set time interval, and if the connection state of the target wan interface is the connected state, the target wan interface is determined to be a default gateway.
Optionally, in this embodiment, the connection state of each wan interface in the system may be checked by using a custom ethmon module periodically using ubus polling, and if the wan interface specified by the user is in a connected state, it is set as a default gateway; for example, if the target system includes three interfaces wan, namely, a first wan interface, a second wan interface, and a third wan interface, and the user-specified interface wan is the first wan interface, if it is checked through ubus polling that the connection status of the first wan interface is connected, the first wan interface may be set as a default gateway.
In an optional implementation of this embodiment, determining the target wan interface as a default gateway may include: querying information of a current wan interface, and if the current wan interface is not the target wan interface, querying information of each wan interface; if it is determined that the target wan interface has been successfully dialed, updating the current interface information; wherein the target wan interface is a wan interface specified by a user.
The current wan interface may be a wan interface with successful dialing, which may be the same interface as the target wan interface, or may be another interface, which is not limited in this embodiment.
Optionally, if it is determined that the connection state of the target wan interface is the connected state, the information of the current wan interface may be further queried, if the current wan interface is not the target wan interface specified by the user, the information of all the wan interfaces in the system needs to be queried, if it is found that the wan interface specified by the user has been successfully dialed, the information of the current wan interface may be updated, and the corresponding information of the default gateway, DNS, DHCPV6 PD, and the like may be set; if the current wan interface is the target wan interface designated by the user, only the information of the current wan interface needs to be queried, whether the gateway addresses are the same is judged, and if not, updating is performed.
In an optional implementation of this embodiment, after determining the target wan interface as a default gateway, the method may further include: determining a DNS address corresponding to the target wan interface as a DNS nameserver; the current wan interface name is determined.
Alternatively, in this embodiment, if the target wan interface specified by the user is in the connected state, it is set as the default gateway, and its corresponding DNS address is set as the DNS domain name server, and the current wan interface name is set.
Step 120, determining whether the information of the current wan interface is null.
In an alternative implementation of this embodiment, after determining the target wan interface specified by the user as the default gateway, it may be further determined whether the information of the current wan interface is null; optionally, in this embodiment, determining whether the information of the current wan interface is null may include: determining interface information of a first wan interface which acquires an IP address and/or a gateway address; if the interface information of the first wan interface is different from the interface information of the target wan interface, determining that the information of the current wan interface is null.
In this embodiment, when the other wan interfaces (interfaces other than the target wan interface) acquire information such as an IP address and a gateway address, the mobile gateway information set by the other wan interfaces is covered, that is, the current wan interface information is set to a null value.
And 130, in the case that the information of the current wan interface is null, polling the connection state of each wan interface every second set time interval, and if the connection state of the target wan interface is a disconnection state, adjusting the default gateway to be a reference wan interface.
The second set time interval may be 3 seconds, 5 seconds, 10 seconds, or the like, which is not limited in this embodiment. In this embodiment, the first set time interval is greater than the second set time interval, for example, the first set time interval is 30 seconds, and the second set time interval is 3 seconds.
In an alternative implementation manner of this embodiment, after the current wan interface information is set to a null value, the connection status of each wan interface may be further polled every second set time interval, and if the connection status of the target wan interface is in a disconnected status, the default gateway is adjusted to be the reference wan interface.
In an optional implementation manner of this embodiment, if the connection state of the target wan interface is a disconnected state, the adjusting the default gateway to be the reference wan interface may include: determining the sequence of the wan interfaces, and determining the gateway address and the DNS address acquired by the first wan interface as the default gateway address and the domain name server address; wherein the reference wan interface is the first wan interface.
Optionally, in this embodiment, the information of each wan interface may be polled again by the custom-defined ethmon module, if it is determined that the current wan interface information is null, the connection state of each wan interface may be queried by ubus, and if the connection state of the target wan interface is the disconnection state, the gateway address and the dns address acquired by the first wan interface may be used as default gateway and domain name server addresses according to the wan interface sequence.
In another optional implementation manner of this embodiment, in a case where the information of the current wan interface is null, polling the connection status of each wan interface every second set time interval includes: if the connection state of the target wan interface is the connected state, determining the gateway address and DNS address of the target wan interface as the default gateway address and domain name server address.
Optionally, in this embodiment, the information of each wan interface may be polled again by the custom-defined ethmon module, if it is determined that the current wan interface information is null, the connection state of each wan interface may be queried by ubus, and if the connection state of the target wan interface is the connected state, the designated interface gateway address and dns address may be updated as default gateway and domain name server addresses.
According to the technical scheme, the connection state of each wan interface in the target system is checked through polling at each first set time interval, and if the connection state of the target wan interface is the connected state, the target wan interface is determined to be a default gateway; determining whether the current wan interface information is null; under the condition that the information of the current wan interface is null, the connection state of each wan interface is polled every second set time interval, and if the connection state of the target wan interface is in a disconnection state, the default gateway is adjusted to be the reference wan interface, so that the device can rapidly switch the link path, and normal network communication and surfing experience of a user are not affected.
In order to better understand the gateway adjustment method according to the embodiment of the present invention, a specific description is adopted below, and the specific scheme of the gateway adjustment method according to the embodiment of the present invention is as follows:
1. it can be understood that the module wide-dhcpv6 of the ipv6 needs to be developed to support more than wan, and only a single wan is supported by default to acquire the ipv6 address; in this embodiment, the interface information of wan is transmitted to the wide-dhcpv6 module as a parameter, and wan interface information is analyzed in the wide-dhcpv6 module, so that the device can be compatible with multiple uhcp 6c processes to obtain the ipv6 addresses of multiple interfaces;
2. macro isolation is needed to be used for a function for setting the DNS address in the netifd module, and the DNS address is uniformly configured by the ethmon;
3. a shell script of multi-wan is added in/etc/hotplug.d/ifoce/and when any wan interface obtains an IP address ifup, the information of the current wan interface (comprising ipv4 and ipv 6) is emptied; if the current wan interface ifdown is performed, the current wan interface (including ipv4 and ipv 6) information is also emptied;
4. when wan obtains an ipv6 address, uniformly transmitting the gateway setting the ipv6 and DHCPv6 PD operation to the ethmon for processing;
5. after wan has been numbered, ethmon polls wan the interface status every 30 seconds; if the current wan interface is empty, inquiring wan interface state every 3 seconds, and returning to 30 seconds after dialing is successful;
6. When inquiring wan interface state, if the current wan interface is wan interface appointed by the user, only inquiring the information of the current wan interface, judging whether the gateway addresses are the same, and if not, updating; if the current wan interface is not the wan interface designated by the user, information of all wan interfaces needs to be queried, if the wan interface designated by the user is successfully dialed, the current wan interface information is updated, and corresponding information such as a default gateway, DNS, DHCPV6 PD and the like is set.
By means of the scheme of the embodiment, a single physical wan interface can be used for establishing a plurality of virtual interfaces to dial and obtain the ipv4 and ipv6 addresses, internet service requests are carried out according to wan interfaces designated by users as default routes, meanwhile, connection states of wan interfaces are monitored, if dialing disconnection occurs, default routes of equipment are timely adjusted, and users can continue to normally surfing without perception.
According to the scheme, the default gateway, the dns address information, the DHCPv6 PD and other information are stripped from the netifd, the settings are uniformly put into a custom module for ethmon processing, the states of the connection of the network gateway wan are monitored in a polling mode in the ethmon, if abnormality is found or the connection is inconsistent with an interface designated by a user, correction is timely carried out, and the internet surfing service of the user can be timely switched to a normal wan interface link for surfing.
Fig. 2 is a schematic diagram of a web trigger gateway adjustment according to a first embodiment of the present invention, where, as shown in fig. 2, the web trigger gateway adjustment mainly includes:
step 210, web triggering.
Step 220, modifying the assigned wan internet interface.
Step 230, setting the current wan configuration to null.
Step 240, modifying the DNS address.
Step 250, create DNS modified flag.
In this embodiment, when the default wan interface of the web page is modified, the configuration of the current wan interface is cleared, triggering the ethmon to immediately perform dynamic adjustment; when dynamic and static address switching of the DNS address is performed on the web page, setting a flag of DNS modification, triggering ethmon to detect that the DNS address is modified, immediately performing DNS address update and DHCPv6 PD update, and notifying clients such as an underhung PC or mobile phone to perform DNS address update.
Fig. 3 is a schematic diagram of a hotplug trigger gateway adjustment according to a first embodiment of the present invention, where, as shown in fig. 3, the hotplug trigger gateway adjustment mainly includes:
step 310, hotplug triggering.
Step 320, wan dial the number.
Step 330, current wan configuration is set to null.
Steps 340, wan are disconnected.
Step 350, determining whether the currently used wan is disconnected;
If yes, go to step 360.
Step 360, the current wan configuration is set to null.
In this embodiment, a hotplug processing script is added, when wan dials successfully, the configuration of the current wan interface is cleared, and the ethmon is triggered to immediately perform the adaptation update, when wan disconnects, if the disconnected wan connection is the current wan interface, the configuration of the current wan interface is cleared, and the ethmon is triggered to immediately perform the adaptation update.
It can be understood that the specific implementation steps of the gateway adjustment method related to this embodiment are as follows:
s1: when the default wan interface of the web page is modified, the configuration of the current wan interface is cleared, triggering ethmon to immediately make dynamic adjustments.
S2: and adding a processing script of the hotplug, when wan dialing is successful, clearing the configuration of the current wan interface, triggering the ethmon to immediately perform adaptation updating, and when wan is disconnected, if the disconnected wan connection is the current wan interface, clearing the configuration of the current wan interface, and triggering the ethmon to immediately perform adaptation updating.
S3: when dynamic and static address switching of the DNS address is performed on the web page, setting a flag of DNS modification, triggering ethmon to detect that the DNS address is modified, immediately performing DNS address update and DHCPv6 PD update, and notifying clients such as an underhung PC or mobile phone to perform DNS address update.
S4: the ethmon module polls the interface state of check wan, check every 3 seconds;
s5: if wan interface is not connected with the network cable, the process returns to S4, if wan interface is connected, the process proceeds to S6.
S6: if wan dialing fails, or the current wan is configured to be empty, entering S8;
s7: if wan dialing is successful, the number of times of detection is required to reach 10 times, namely, after 30 seconds, the process goes to S8.
S8: if dialing is successful and the current wan interface is the configuration designated by the user, checking the connection state of the current wan interface, if the connection is disconnected, clearing the configuration information of the current wan interface, triggering the ethcon to immediately perform multi wan cycle detection in the next cycle, if the connection is normal, judging whether the gateway address is updated, and if the gateway address is updated, performing updating operation on default gateway information; otherwise, the process goes to S9.
S9: the connection state of each wan interface is read in a polling mode, and if the current wan interface is configured to be empty, the first wan is set as default gateway and DHCPv6 PD information; if the user-specified wan interface is also in a connected state, the user-specified wan interface is used as default gateway and DHCPv6 PD information, and a flag with a modified DNS address is created.
S10: if the wan is in the disconnected state after the polling detection is finished, the gateway, the DHCPv6 PD and other information are cleared; otherwise, update dns address, update wan interface of hard acceleration hnat module, etc.
S11: returning to S4 to perform polling check operation.
Fig. 4 is a flowchart of a gateway adjustment method according to a first embodiment of the present invention, as shown in fig. 4, mainly including the following steps:
step 410, dormancy for 3 seconds.
Step 411, wan, if a wire is inserted.
If yes, go to step 412;
otherwise, return to step 410.
Step 412, whether the current wan configuration is empty;
if yes, go to step 420;
otherwise, step 413 is performed.
Step 413, wan, if dialing is successful;
if not, go to step 420.
Step 420, loading a configuration file of the network.
Step 421, checking whether dialing is successful and whether the current wan configuration information is a user-specified interface;
if yes, go to step 430;
otherwise, step 422 is performed.
Step 422, sequentially reads the IP address, gateway address, and DNS address of each wan interface.
Step 423, determining if the gateway address is empty? Or whether the current wan interface is a user-specified interface;
if yes, go to step 424;
otherwise, step 425 is performed.
And step 424, setting default gateway address and DHCPv6 PD information, setting DNS, and modifying flag.
The interfaces of steps 425, wan check to see if they are complete.
If yes, go to step 426;
Otherwise, go back to step 422.
Step 426, whether there is a successful dialing wan;
if yes, go to step 427;
otherwise, the gateway, the DHCPv6 PD and other information are cleared.
Step 427, whether there is a DNS modified flag;
if yes, go to step 428.
Step 428, update DNS addresses of IPV4 and IPV6, update interfaces of the hardware acceleration hnat module wan, and so on.
Step 430, whether the current wan dialing is successful;
if yes, go to step 440;
otherwise, step 431 is performed.
Step 431, the current wan configuration information is removed.
Step 440, checking whether the gateway address changes;
if yes, go to step 450.
Step 450, updating gateway address information.
Step 460, whether there is a DNS modified flag;
if yes, go to step 470.
Step 470, updating DNS addresses for IPV4 and IPV 6.
The scheme of the embodiment can be combined with the configuration of a user, when the wan dialing state of the equipment changes, the connection state of the wan is polled through the shell script, and the default route, DNS address, PD and other information of the IPV4 and the IPV6 are dynamically adjusted, so that the equipment can rapidly switch the link path, and normal network communication and surfing experience of the user are not affected.
In the technical scheme of the embodiment of the invention, the acquisition, storage, application and the like of the related user personal information (such as face information, voice information and the like) accord with the regulations of related laws and regulations, and the public order welcome is not violated.
Example two
Fig. 5 is a schematic structural diagram of a gateway adjusting device according to a second embodiment of the present invention. The present embodiment may execute the gateway adjustment method related to the foregoing embodiment, as shown in fig. 5, where the apparatus includes: a default gateway determination module 510, a null determination module 520, and a default gateway adjustment module 530.
The default gateway determining module 510 is configured to poll and check a connection state of each wan interface in the target system every a first set time interval, and if the connection state of the target wan interface is a connected state, determine the target wan interface as a default gateway;
a null value determining module 520, configured to determine whether the information of the current wan interface is null;
and a default gateway adjustment module 530, configured to poll the connection status of each wan interface every second set time interval if the current wan interface information is null, and adjust the default gateway to be the reference wan interface if the connection status of the target wan interface is the disconnected connection status.
According to the scheme of the embodiment, the connection state of each wan interface in the target system is checked through polling of a default gateway determining module at each first set time interval, and if the connection state of the target wan interface is the connected state, the target wan interface is determined to be the default gateway; determining whether the current wan interface information is null or not through a null value determining module; and under the condition that the information of the current wan interface is null, polling the connection state of each wan interface every second set time interval by a default gateway adjustment module, and adjusting the default gateway to be a reference wan interface if the connection state of the target wan interface is a disconnection state, so that the equipment can rapidly switch a link path without affecting the normal network communication and internet surfing experience of a user.
In an optional implementation manner of this embodiment, the default gateway determining module 510 is specifically configured to query information of a current wan interface, and if it is determined that the current wan interface is not the target wan interface, query information of each wan interface;
if it is determined that the target wan interface has been successfully dialed, updating the current interface information;
wherein the target wan interface is a wan interface specified by a user.
In an optional implementation manner of this embodiment, the gateway adjusting apparatus further includes: the current wan interface name determining module is used for determining a DNS address corresponding to the target wan interface as a DNS domain name server; the current wan interface name is determined.
In an optional implementation manner of this embodiment, the null value determining module 520 is specifically configured to determine interface information of the first wan interface that obtains the IP address and/or the gateway address;
if the interface information of the first wan interface is different from the interface information of the target wan interface, determining that the information of the current wan interface is null.
In an optional implementation manner of this embodiment, a default gateway adjustment module 530 is specifically configured to determine an order of the wan interfaces, and determine a gateway address and a DNS address acquired by the first wan interface as the default gateway address and a domain name server address;
wherein the reference wan interface is the first wan interface.
In an optional implementation manner of this embodiment, the default gateway adjustment module 530 is further specifically configured to determine, if the connection state of the target wan interface is a connected state, a gateway address and a DNS address of the target wan interface as the default gateway address and a domain name server address.
In an alternative implementation of this embodiment, the first set time interval is greater than the second set time interval.
The gateway adjusting device provided by the embodiment of the invention can execute the gateway adjusting method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
Example III
Fig. 6 shows a schematic diagram of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the embodiments of the invention described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as the gateway adjustment method.
In some embodiments, method XXX may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. One or more of the steps of the gateway adjustment method described above may be performed when the computer program is loaded into RAM 13 and executed by processor 11. Alternatively, in other embodiments, the processor 11 may be configured to perform the gateway adjustment method in any other suitable way (e.g. by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of embodiments of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the embodiments of the present invention may be performed in parallel, sequentially or in a different order, so long as the desired result of the technical solution of the embodiments of the present invention can be achieved, which is not limited herein.
The above detailed description should not be construed as limiting the scope of the embodiments of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the embodiments of the present invention should be included in the scope of the embodiments of the present invention.

Claims (9)

1. A gateway adjustment method, comprising:
polling and checking the connection state of each wan interface in the target system every first set time interval, and determining the target wan interface as a default gateway if the connection state of the target wan interface is the connected state;
determining whether the current wan interface information is null;
under the condition that the information of the current wan interface is null, polling the connection state of each wan interface every second set time interval, and if the connection state of the target wan interface is a disconnection state, adjusting a default gateway to be a reference wan interface;
The determining the target wan interface as a default gateway includes:
querying information of the current wan interface, and if the current wan interface is determined not to be the target wan interface, querying information of each wan interface;
if it is determined that the target wan interface has been successfully dialed, updating the current wan interface information; setting corresponding default gateway, DNS and DHCPV6 PD information;
if the current wan interface is determined to be the target wan interface, inquiring the current wan interface information, judging whether gateway addresses are the same or not, and if not, updating;
wherein the target wan interface is a wan interface specified by a user.
2. The method of claim 1, further comprising, after determining the target wan interface as a default gateway:
determining a DNS address corresponding to the target wan interface as a DNS nameserver;
the current wan interface name is determined.
3. The method of claim 1, wherein the determining whether the information of the current wan interface is null comprises:
determining interface information of a first wan interface which acquires an IP address and/or a gateway address;
if the interface information of the first wan interface is different from the interface information of the target wan interface, determining that the information of the current wan interface is null.
4. The method of claim 1, wherein adjusting the default gateway to the reference wan interface if the connection state of the target wan interface is a disconnected state comprises:
determining the sequence of the wan interfaces, and determining the gateway address and the DNS address acquired by the first wan interface as the default gateway address and the domain name server address;
wherein the reference wan interface is the first wan interface.
5. The method of claim 1, wherein, in the case where the information of the current wan interface is null, polling the connection status of each wan interface every second set time interval comprises:
if the connection state of the target wan interface is the connected state, determining the gateway address and DNS address of the target wan interface as the default gateway address and domain name server address.
6. The method of claim 1, wherein the first set time interval is greater than the second set time interval.
7. A gateway adjustment apparatus, comprising:
the default gateway determining module is configured to poll and check a connection state of each wan interface in the target system every first set time interval, and if the connection state of the target wan interface is a connected state, determine the target wan interface as a default gateway;
The null value determining module is used for determining whether the information of the current wan interface is null value or not;
the default gateway adjustment module is configured to poll the connection status of each wan interface every second set time interval when the current wan interface information is null, and adjust the default gateway to be the reference wan interface if the connection status of the target wan interface is the disconnection status;
the default gateway determining module is specifically configured to:
querying information of the current wan interface, and if the current wan interface is determined not to be the target wan interface, querying information of each wan interface;
if the target wan interface is successfully dialed, updating the current interface information, and setting the corresponding default gateway, DNS and DHCPV6 PD information;
if the current wan interface is determined to be the target wan interface, inquiring the current wan interface information, judging whether the gateway addresses are the same or not, and if not, updating;
wherein the target wan interface is a wan interface specified by a user.
8. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
The memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the gateway adjustment method of any one of claims 1-6.
9. A computer readable storage medium storing computer instructions for causing a processor to implement the gateway adjustment method of any one of claims 1-6 when executed.
CN202210931601.9A 2022-08-04 2022-08-04 Gateway adjustment method, device, electronic equipment and storage medium Active CN115277410B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210931601.9A CN115277410B (en) 2022-08-04 2022-08-04 Gateway adjustment method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210931601.9A CN115277410B (en) 2022-08-04 2022-08-04 Gateway adjustment method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115277410A CN115277410A (en) 2022-11-01
CN115277410B true CN115277410B (en) 2024-04-12

Family

ID=83749546

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210931601.9A Active CN115277410B (en) 2022-08-04 2022-08-04 Gateway adjustment method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115277410B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115883383B (en) * 2022-12-09 2024-05-10 山东有人物联网股份有限公司 Network extension communication method, device, equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7881208B1 (en) * 2001-06-18 2011-02-01 Cisco Technology, Inc. Gateway load balancing protocol
CN105992262A (en) * 2016-06-30 2016-10-05 西安电子科技大学 Adaptive mode switching method for wireless Mesh network
CN110868746A (en) * 2019-11-18 2020-03-06 RealMe重庆移动通信有限公司 Network switching method and device, electronic equipment and storage medium
WO2020057625A1 (en) * 2018-09-21 2020-03-26 华为技术有限公司 Gateway switching method, gateway reselection method, and communication apparatus
CN111314984A (en) * 2020-03-23 2020-06-19 四川华丰企业集团有限公司 Gateway switching method, device, equipment and storage medium
CN111935752A (en) * 2020-08-28 2020-11-13 广州市百果园信息技术有限公司 Gateway access method, gateway access device, computer equipment and storage medium
CN113630333A (en) * 2020-05-08 2021-11-09 中国移动通信集团终端有限公司 Distributed networking system and method based on multi-gateway access
CN113709839A (en) * 2021-08-19 2021-11-26 珠海格力电器股份有限公司 Multi-gateway network switching method, device and system, electronic equipment and storage medium
CN114024903A (en) * 2021-11-08 2022-02-08 深圳市共进电子股份有限公司 Network switching method and device and gateway equipment
CN114286403A (en) * 2021-12-07 2022-04-05 深圳市联洲国际技术有限公司 Switching method and switching device for internet access mode of gateway equipment
CN114666864A (en) * 2022-03-24 2022-06-24 青岛海信移动通信技术股份有限公司 Multi-network communication method, terminal device, storage medium, and program product

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7881208B1 (en) * 2001-06-18 2011-02-01 Cisco Technology, Inc. Gateway load balancing protocol
CN105992262A (en) * 2016-06-30 2016-10-05 西安电子科技大学 Adaptive mode switching method for wireless Mesh network
WO2020057625A1 (en) * 2018-09-21 2020-03-26 华为技术有限公司 Gateway switching method, gateway reselection method, and communication apparatus
CN110868746A (en) * 2019-11-18 2020-03-06 RealMe重庆移动通信有限公司 Network switching method and device, electronic equipment and storage medium
CN111314984A (en) * 2020-03-23 2020-06-19 四川华丰企业集团有限公司 Gateway switching method, device, equipment and storage medium
CN113630333A (en) * 2020-05-08 2021-11-09 中国移动通信集团终端有限公司 Distributed networking system and method based on multi-gateway access
CN111935752A (en) * 2020-08-28 2020-11-13 广州市百果园信息技术有限公司 Gateway access method, gateway access device, computer equipment and storage medium
CN113709839A (en) * 2021-08-19 2021-11-26 珠海格力电器股份有限公司 Multi-gateway network switching method, device and system, electronic equipment and storage medium
CN114024903A (en) * 2021-11-08 2022-02-08 深圳市共进电子股份有限公司 Network switching method and device and gateway equipment
CN114286403A (en) * 2021-12-07 2022-04-05 深圳市联洲国际技术有限公司 Switching method and switching device for internet access mode of gateway equipment
CN114666864A (en) * 2022-03-24 2022-06-24 青岛海信移动通信技术股份有限公司 Multi-network communication method, terminal device, storage medium, and program product

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
"Improving sd-wan resilience: From vertical handoff to wan-aware MPTCP";Y Zhang;《IEEE》;全文 *
一种双冗余网络快速切换方法;徐雄斌;杨胜钊;高焘;;舰船电子工程(第11期);全文 *
校园网双出口策略路由实现链路备份解决方案;刘胜珍;姚志鸿;杨威;;电脑知识与技术(第17期);全文 *

Also Published As

Publication number Publication date
CN115277410A (en) 2022-11-01

Similar Documents

Publication Publication Date Title
CN107078969B (en) Realize computer equipment, the system and method for load balancing
CA2950206C (en) Flow entry configuration method, apparatus, and system
US9531643B2 (en) Extending virtual station interface discovery protocol (VDP) and VDP-like protocols for dual-homed deployments in data center environments
US9940153B2 (en) Method for generating configuration information, and network control unit
EP3182648A1 (en) Method, apparatus and system for implementing software-defined networking (sdn)
CN114070723B (en) Virtual network configuration method and system of bare metal server and intelligent network card
EP3418891A1 (en) Synchronization between virtual network functions and host systems
CN107682275B (en) Message monitoring method and device
CN115277410B (en) Gateway adjustment method, device, electronic equipment and storage medium
CN114978910B (en) Time sensitivity realization method and system of virtualization core network
CN107809386B (en) IP address translation method, routing device and communication system
EP3629535A1 (en) Method, device, and system for implementing mux machine
CN107645394B (en) Switch configuration method in SDN network
CN115225634A (en) Data forwarding method and device under virtual network and computer program product
US11929851B2 (en) Gateway selection method, device, and system
CN115695374A (en) IPv6 subnet prefix advertisement implementation method, device, equipment and storage medium
CN110391987B (en) Method, apparatus and computer readable medium for selecting a designated forwarder from a carrier edge device set
CN110086676B (en) Configuration method of distributed router and related equipment
CN107528929B (en) ARP (Address resolution protocol) entry processing method and device
CN111245728A (en) Data message forwarding method and system with multi-network card computing device
CN115190087B (en) Data transmission method, device, equipment and medium based on two-layer intermediate equipment
CN115314336A (en) User online method of vBRAS and related equipment
CN114024903A (en) Network switching method and device and gateway equipment
CN113612643A (en) Network configuration method, device, equipment and storage medium of cloud mobile phone
US9467375B2 (en) Service migration

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant