CN115277410A - Gateway adjusting method, device, electronic equipment and storage medium - Google Patents
Gateway adjusting method, device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN115277410A CN115277410A CN202210931601.9A CN202210931601A CN115277410A CN 115277410 A CN115277410 A CN 115277410A CN 202210931601 A CN202210931601 A CN 202210931601A CN 115277410 A CN115277410 A CN 115277410A
- Authority
- CN
- China
- Prior art keywords
- wan interface
- target
- gateway
- interface
- wan
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 61
- 238000004590 computer program Methods 0.000 claims description 16
- 238000004891 communication Methods 0.000 abstract description 22
- 230000008569 process Effects 0.000 description 12
- 230000001960 triggered effect Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 9
- 238000012545 processing Methods 0.000 description 9
- 230000006870 function Effects 0.000 description 7
- 230000006978 adaptation Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 4
- 238000012986 modification Methods 0.000 description 4
- 230000004048 modification Effects 0.000 description 4
- 238000001514 detection method Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 230000001133 acceleration Effects 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004422 calculation algorithm Methods 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/08—Configuration management of networks or network elements
- H04L41/0803—Configuration setting
- H04L41/0813—Configuration setting characterised by the conditions triggering a change of settings
- H04L41/0816—Configuration setting characterised by the conditions triggering a change of settings the condition being an adaptation, e.g. in response to network events
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L41/00—Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
- H04L41/06—Management of faults, events, alarms or notifications
- H04L41/0654—Management of faults, events, alarms or notifications using network fault recovery
- H04L41/0668—Management 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
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
- H04L43/0805—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
- H04L43/0811—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/10—Active 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 and checking the connection state of each wan interface in the target system at every first set time interval, and if the connection state of the target wan interface is the connected state, determining the target wan interface as a default gateway; determining whether the information of the current wan interface is null; when the information of the current wan interface is null, the connection state of each wan interface is polled at intervals of a second set time interval, and if the connection state of the target wan interface is a disconnected state, the default gateway is adjusted to refer to wan interface. The scheme of the embodiment of the invention can enable the equipment to rapidly switch the link path without influencing the normal network communication and the internet experience of the user.
Description
Technical Field
The embodiment of the invention relates to the technical field of communication equipment, in particular to a gateway adjusting method, a gateway adjusting device, electronic equipment and a storage medium.
Background
In recent years, with the rapid development of network communication technology, users have more and more demands for use scenes. Particularly for the operator market, more and more services can be provided by operators, including different dial-on-internet types and different Virtual Local Area Network (vlan) services; however, since the device actually has only one physical Wide Area Network (wan) port, if it needs to realize multi-wan dialing, it needs to use Network card virtualization (Media Access Control Virtual Local Area Network, macvlan) technology, virtualize multiple interfaces with different physical (Media Access Control, mac) addresses, and after obtaining Internet Protocol (Internet Protocol, IP) addresses allocated by different vlans or the same vlan server, the netifd module of the OpenWRT System automatically sets up the default gateway of the device, domain Name resolution server (Domain Name, system) addresses (including IPV4 and IPV 6), because of multi-353532, when the IP 25 interface obtains the Address, the gateway Address, the DNS Address, and the DNS Address are set up as the default gateway Address, and finally, the gateway will obtain the DNS Address, and finally obtain the default gateway Address; in an actual application scenario, a user can arbitrarily designate a wan interface as a default route, and the DNS address can also arbitrarily designate a DNS address acquired by a wan interface as a unique DNS resolution address; meanwhile, when the specified wan interface has a network disconnection phenomenon, other wan addresses capable of accessing the internet and corresponding gateway and DNS addresses need to be immediately replaced; if the gateway and the DNS address are not controlled according to the default of the netifd, the update and maintenance of the subsequent netifd is not facilitated if the netifd module is directly modified.
How to enable the device to rapidly switch the link path without affecting the normal network communication and internet experience of the user is a key problem of research in the industry.
Disclosure of Invention
Embodiments of the present invention provide a gateway adjustment method, an apparatus, an electronic device, and a storage medium, which enable a device to switch a link path quickly without affecting normal network communication and internet experience of a user.
According to an aspect of the embodiments of the present invention, there is provided a gateway adjusting method, including:
polling and checking the connection state of each wan interface in the target system at every first set time interval, and if the connection state of a target wan interface is a connected state, determining the target wan interface as a default gateway;
determining whether the information of the current wan interface is null;
and when the information of the current wan interface is null, polling the connection state of the wan interfaces at intervals of a 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.
According to another aspect of the embodiments of the present invention, there is provided a gateway adjusting apparatus, including:
the default gateway determining module is used for polling and checking the connection state of each wan interface in the target system at every interval of a first set time interval, and if the connection state of a target wan interface is a connected state, determining the target wan interface as a default gateway;
a null value determining module, configured to determine whether information of the current wan interface is a null value;
and a default gateway adjusting module, configured to poll the connection state of each wan interface at a second set time interval when the information of the current wan interface is null, and adjust the default gateway to refer to wan interface if the connection state of the target wan interface is a disconnected state.
According to another aspect of the embodiments 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 first and the second end of the pipe are connected with each other,
the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the gateway adjusting method according to any 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 causing a processor to implement the gateway adjusting method according to any one of the embodiments of the present invention when the computer instructions are executed.
According to the technical scheme of the embodiment of the invention, the connection state of each wan interface in the target system is checked through polling at each interval of a first set time interval, and if the connection state of a target wan interface is in a connected state, the target wan interface is determined as a default gateway; determining whether the information of the current wan interface is a null value; when the information of the current wan interface is null, polling the connection state of the wan interface at intervals of a second set time interval, if the connection state of the target wan interface is a disconnected state, adjusting the default gateway to the reference wan interface allows the device to switch the link path quickly without affecting the user's normal network communication and internet experience.
It should be understood that the statements in this section do not necessarily identify key or critical features of any embodiments of the present invention, nor limit the scope of any embodiments of the present invention. Other features of embodiments of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a gateway adjusting method according to an embodiment of the present invention;
fig. 2 is a schematic diagram of a web-triggered gateway adjustment according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a hot plug triggered gateway adjustment according to an embodiment of the present invention;
fig. 4 is a flowchart of a gateway adjusting method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a gateway adjusting apparatus 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 those skilled in the art better understand the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only some embodiments, not all embodiments, of the embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present invention, shall fall within the protection scope of the embodiments of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the embodiments of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation 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 noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but could have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.
The term "OpenWRT" as used herein is a highly extensible GNU/Linux release developed for embedded devices, typically wireless routers.
The term "multi-wan" used herein refers to a physical wan interface, a plurality of virtual wan interfaces, and can dial to obtain an IP address capable of accessing to the internet.
The term "DHCPv6 PD" PD as used herein is an abbreviation for Prefix deletion, a Prefix assignment mechanism that enables a device or PC to obtain the global address of IPV6 by means of the obtained PD address Prefix.
The term "vlan" as used herein is a technology that implements a virtual workgroup by logically, rather than physically, dividing devices within a local area network into segments.
The term "macvlan" as used herein is a network card virtualization technology that enables one network card to be virtualized into multiple network cards.
The term "netifd" is used herein in OpenWrt for a daemon for network configuration.
The term "ubus" as used herein is an inter-process communication mechanism in OpenWrt, ubusd implements server, other processes implement client, and two client communications need to be forwarded through server.
Example one
Fig. 1 is a flowchart of a gateway adjusting method according to an embodiment of the present invention, where this embodiment is applicable to a case of performing fast adjustment on a default gateway, and the method may be executed by a gateway adjusting apparatus, where the gateway adjusting apparatus may be implemented in a form of hardware and/or software, and the gateway adjusting apparatus 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 at intervals of a first set time interval, and if the connection state of a target wan interface is a connected state, determining the target wan interface as a default gateway.
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 another embedded Linux system, which is also 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 the gateway. In a TCP/IP network system, a gateway basically functions to select an optimal outlet to forward an IP packet according to a network number and a subnet number of a destination IP address, thereby realizing data communication across network segments. Sometimes, a gateway is also considered to be the IP address with a data forwarding device, and the IP address of the gateway and its subnet should be on the same network segment. For example, there are network a and network B, the IP address range of network a is "192.168.1.1-192.168.1.254", the subnet mask is 255.255.255.0; the IP address range of the network B is 192.168.2.1-192.168.2.254, and the subnet mask is 255.255.255.0. Without a router, TCP/IP communication between two networks is not possible, and even if two networks are connected to the same switch (or hub), the TCP/IP protocol determines that the hosts in the two networks are in different networks based on the subnet mask (255.255.255.0). Communication between the two networks must be accomplished through a gateway. If the host in network A finds that the destination host of the data packet is not in the local network, the data packet is forwarded to the gateway of the host in network A and then forwarded to the gateway of network B, and the gateway of network B forwards to a host in network B. The same is true for the process of forwarding the data packet from the network B to the network a, so that the TCP/IP protocol can only realize the intercommunication between different networks if the IP address of the gateway is set. Then is this IP address of which machine? The IP address of the gateway is an IP address of a device having a routing function, and the device having a routing function includes a router, a server (substantially equivalent to one router) that enables a routing protocol, and a proxy server (also equivalent to one router).
In the present embodiment, the target system may include three wan interfaces, for example, a first wan interface, a second wan interface, and a third wan interface; the target wan interface may be a wan interface specified by a user, for example, the first wan interface, which is not limited in this embodiment.
In an optional implementation manner of this embodiment, the connection state of each wan interface in the target system may be polled and checked every first set time interval, and if the connection state of the target wan interface is a connected state, the target wan interface is determined as a default gateway.
Optionally, in this embodiment, the connection state of each wan interface in the system may be periodically checked by using a customized ethmon module, and if the wan interface specified by the user is in a connected state, the connection state is set as a default gateway; illustratively, if the target system includes three wan interfaces, namely a first wan interface, a second wan interface and a third wan interface, and the wan interface specified by the user is a first wan interface, if the first wan interface is detected to be connected through ubus polling, the first wan interface may be set as the default gateway.
In an optional implementation manner of this embodiment, determining the target wan interface as a default gateway may include: inquiring information of a current wan interface, and if the current wan interface is determined not to be the target wan interface, inquiring information of each wan interface; if the target wan interface is determined to be dialed successfully, updating the current interface information; wherein, the target wan interface is a wan interface designated by a user.
The current wan interface may be a wan interface that successfully dials, 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 wan interfaces in the system needs to be queried, and if it is found that the wan interface specified by the user has successfully dialed, the information of the current wan interface may be updated, and information of a default gateway, a DNS, a DHCPV6 PD and the like corresponding to the information is set; if the current wan interface is the target wan interface specified by the user, only the information of the current wan interface needs to be queried, and whether the gateway addresses are the same or not is judged, and if not, the gateway addresses are updated.
In an optional implementation manner of this embodiment, after determining that the target wan interface is the default gateway, the method may further include: determining a DNS address corresponding to the target wan interface as a DNS domain name server; the current wan interface name is determined.
Optionally, in this embodiment, if the target wan interface specified by the user is in a connected state, it is set as a default gateway, and sets the DNS address corresponding to the default gateway as the DNS nameserver, and sets the current wan interface name.
And step 120, determining whether the information of the current wan interface is a null value.
In an optional implementation manner of this embodiment, after determining that the target wan interface specified by the user is 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 a null value may include: determining interface information of a first wan interface for acquiring an IP address and/or a gateway address; and 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 a null value.
It should be noted that, in this embodiment, when another wan interface (an interface other than the target wan interface) acquires information such as an IP address and a gateway address, the moving gateway information set by the interface is overwritten, that is, the information of the current wan interface is set to a null value.
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 optional implementation manner of this embodiment, after the current wan interface information is set to be null, the connection state of each wan interface may be further polled at second set time intervals, and if the connection state of the target wan interface is a disconnected state, the default gateway is adjusted to refer to wan interface.
In an optional implementation manner of this embodiment, if the connection state of the target wan interface is a disconnection state, adjusting the default gateway to the reference wan interface may include: determining the sequence of wan interfaces, and determining a gateway address and a DNS address acquired by a 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 through a customized ethmon module, if it is determined that the current wan interface information is null, the connection state of each wan interface may be queried through the ubus, and if the connection state of the target wan interface is a disconnection state, the gateway address and the dns address obtained by the first wan interface may be used as the default gateway and domain name server address according to the wan interface sequence.
In another optional implementation manner of this embodiment, when the information of the current wan interface is null, polling the connection state of each wan interface at intervals of a second set time interval includes: and if the connection state of the target wan interface is the connected state, determining the gateway address and the DNS address of the target wan interface as the default gateway address and the domain name server address.
Optionally, in this embodiment, the information of each wan interface may be polled again through a customized ethmon module, if it is determined that the current wan interface information is null, the connection state of each wan interface may be queried through the ubus, and if the connection state of the target wan interface is a connected state, the specified interface gateway address and dns address may be updated as the default gateway and domain name server address.
According to the technical scheme of the embodiment, the connection state of each wan interface in the target system is polled and checked at every interval of a first set time interval, and if the connection state of a target wan interface is a connected state, the target wan interface is determined as a default gateway; determining whether the information of the current wan interface is null; when the information of the current wan interface is null, polling the connection state of each wan interface at every second set time interval, and if the connection state of the target wan interface is a disconnection state, adjusting the default gateway to refer to wan interface, so that the device can quickly switch the link path without affecting the normal network communication and internet experience of the user.
In order to better understand the gateway adjusting method involved in the embodiment of the present invention, the following is to specifically describe the gateway adjusting method, and a specific scheme of the gateway adjusting method involved in the embodiment is as follows:
1. it can be understood that the module wide-dhcpv6 required to develop ipv6 supports wan, and only supports wan to obtain ipv6 address by default; in the embodiment, the interface information of wan is used as parameters and transmitted to the wide-dhcpv6 module, and the wan interface information is analyzed in the wide-dhcpv6 module, so that the ipv6 address of a plurality of interfaces can be obtained by being compatible with a plurality of udhcp6c processes;
2. macro isolation is used for a function for setting a DNS address in a netifd module, and a DNS address is uniformly configured by ethmon;
3. adding a shell script of multi _ wan in/etc/hot plug.d/iface/and emptying information of a current wan interface (including ipv4 and ipv 6) when an arbitrary wan interface acquires an IP address ifup; if the current wan interface is ifdown, the information of the current wan interface (including ipv4 and ipv 6) is also cleared;
4. when wan obtains the ipv6 address, uniformly handing gateway and DHCPv6 PD operations for setting ipv6 to ethmon for processing;
5. after wan has dialed up, ethmon polls wan interface state every 30 seconds; if the current wan interface is empty, inquiring the wan interface state every 3 seconds, and returning the polling time to 30 seconds after dialing is successful;
6. when the wan interface state is inquired, if the current wan interface is the wan interface appointed by the user, only the information of the current wan interface needs to be inquired, whether the gateway addresses are the same or not is judged, and if the gateway addresses are different, updating is carried out; if the current wan interface is not wan interface designated by the user, the information of all wan interfaces needs to be inquired, and if the wan interface designated by the user is found to be dialed successfully, the information of the current wan interface is updated, and the corresponding information of the default gateway, DNS, DHCPV6 PD and the like is set.
By the scheme of the embodiment, a single physical wan interface can establish a plurality of virtual interfaces to dial to acquire ipv4 and ipv6 addresses, an internet service request is performed by taking a wan interface designated by a user as a default route, the connection state of the wan interface is monitored, if the dial-up is disconnected, the default route of the device is adjusted in time, and the user can continue to surf the internet without sensing.
According to the scheme of the embodiment, the settings of information such as a default gateway, dns address information, DHCPv6 PD and the like are stripped from the netifd and are put into a custom module ethmon for processing in a unified manner, the state of multi-wan connection is polled and monitored in the ethmon, if abnormity is found or the connection state is inconsistent with an interface designated by a user, correction is carried out in time, and the purpose that the internet access service of the user can be switched to a normal wan interface link for internet access is achieved in time.
Fig. 2 is a schematic diagram of a web trigger gateway adjustment according to an embodiment of the present invention, and as shown in fig. 2, the web trigger gateway adjustment mainly includes:
In the embodiment, when the default wan interface of the web page is modified, the configuration of the current wan interface is cleared, and ethmon is triggered to immediately perform dynamic adjustment; when the dynamic and static addresses of the DNS address are switched on a web page, a flag for DNS modification is set, ethmon is triggered to detect that the DNS address is modified, the DNS address is immediately updated and DHCPv6 PD is immediately updated, and clients such as a down-hung PC or a mobile phone are informed to update the DNS address.
Fig. 3 is a schematic diagram of a hot plug triggered gateway adjustment according to an embodiment of the present invention, and as shown in fig. 3, the hot plug triggered gateway adjustment mainly includes:
And steps 320 and wan dial up the number.
if yes, go to step 360.
In the embodiment, a processing script of the hot plug is added, when wan successfully dials, the configuration of a current wan interface is cleared, ethmon is triggered to immediately do adaptation updating, and when wan is disconnected, if the disconnected wan connection is the current wan interface, the configuration of the current wan interface is cleared, ethmon is triggered to immediately do adaptation updating.
It can be understood that the gateway adjusting method related in this embodiment is implemented as follows:
s1: when the default wan interface of the web page is modified, the configuration of the current wan interface is cleared, and ethmon is triggered to immediately make dynamic adjustment.
S2: adding a processing script of a hot plug, emptying the configuration of a current wan interface when wan dials successfully, triggering ethmon to immediately do adaptation updating, and emptying the configuration of the current wan interface to immediately do adaptation updating if the disconnected wan connection is the current wan interface when wan is disconnected.
S3: when the dynamic address and the static address of the DNS address are switched on the web page, a DNS modification flag is set, ethmon is triggered to detect that the DNS address is modified, the DNS address and the DHCPv6 PD are immediately updated, and a hung client such as a PC or a mobile phone is informed to update the DNS address.
S4: the ethmon module polls and checks the interface state of wan, and checks every 3 seconds;
s5: if the wan interface is not connected with the network cable, the process returns to S4, and if the wan interface is connected, the process proceeds to S6.
S6: if wan fails to dial, or the current wan is configured to be empty, entering S8;
s7: if wan dials successfully, the number of times of detection is required to reach 10, i.e., the operation proceeds to S8 after 30 seconds.
S8: if the 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 ethmon to immediately perform multiple wan circulation detection in the next circulation, if the connection is normal, judging whether the gateway address is updated, and if the gateway address is updated, performing update operation on default gateway information; otherwise, go to S9.
S9: polling and reading the connection state of each wan interface, and if the current wan interface is configured to be empty, setting a first wan as a default gateway and DHCPv6 PD information; if the wan interface designated by the user is also in the connected state, the wan interface designated by the user is used as the default gateway and DHCPv6 PD information, and a flag with the modified DNS address is created.
S10: if the wan is in the off state after the polling detection is finished, removing the information such as the gateway and the DHCPv6 PD; otherwise, the dns address is updated, and the wan interface of the hard acceleration hnat module is updated.
S11: and returning to S4 for polling check.
Fig. 4 is a flowchart of a gateway adjustment method according to an embodiment of the present invention, as shown in fig. 4, which mainly includes the following steps:
and step 410, sleeping for 3 seconds.
Whether a net wire is inserted into the port wan or not is judged in the steps 411 and wan.
If yes, go to step 412;
otherwise, return to step 410.
if yes, go to step 420;
otherwise, step 413 is performed.
if not, go to step 420.
And step 420, loading a configuration file of the network.
if yes, go to step 430;
otherwise, step 422 is performed.
And step 422, sequentially reading the IP address, the gateway address and the DNS address of each wan interface.
if yes, go to step 424;
otherwise, step 425 is performed.
And 424, setting the default gateway address and information of the DHCPv6 PD, setting a DNS and modifying a flag.
And step 425, wan whether the interface is checked.
If yes, go to step 426;
otherwise, return to execute step 422.
if yes, go to step 427;
otherwise, the information such as the gateway, the DHCPv6 PD and the like is cleared.
427, judging whether a DNS modified flag exists;
if yes, go to step 428.
if yes, go to step 440;
otherwise, step 431 is performed.
And 431, clearing the current wan configuration information.
if yes, go to step 450.
if yes, go to step 470.
Step 470, update the DNS addresses of IPV4 and IPV 6.
According to the scheme of the embodiment, the configuration of the user can be combined, when the wan dialing state of the device changes, the connection state of wan is polled through the shell script, the information such as the default route of the IPV4 and the IPV6, the DNS address, the PD of the DHCPv6 and the like is dynamically adjusted, the device can rapidly switch the link path, and the normal network communication and internet experience of the user are not influenced.
In the technical scheme of the embodiment of the invention, the acquisition, storage, application and the like of the personal information (such as face information, voice information and the like) of the related user all accord with the regulations of related laws and regulations without violating the good customs of the public order.
Example two
Fig. 5 is a schematic structural diagram of a gateway adjusting apparatus according to a second embodiment of the present invention. The present embodiment may execute the gateway adjusting method related in the foregoing embodiments, as shown in fig. 5, the apparatus includes: a default gateway determination module 510, a null determination module 520, and a default gateway adjustment module 530.
A default gateway determining module 510, configured to poll and view a connection state of each wan interface in the target system at 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;
a null value determining module 520, configured to determine whether information of the current wan interface is a null value;
a default gateway adjusting module 530, configured to poll the connection state of each wan interface at a second set time interval when the information of the current wan interface is null, and adjust the default gateway to refer to wan interface if the connection state of the target wan interface is a disconnected state.
In the scheme of this embodiment, the default gateway determining module polls and checks the connection state of each wan interface in the target system at every first set time interval, and if the connection state of the target wan interface is the connected state, determines the target wan interface as the default gateway; determining whether the information of the current wan interface is a null value or not through a null value determining module; and polling the connection state of each wan interface at a second set time interval by a default gateway adjusting module under the condition that the information of the current wan interface is null, and if the connection state of the target wan interface is a disconnection state, adjusting the default gateway to refer to wan interface, so that the device can quickly switch the link path without affecting the normal network communication and internet experience of the 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 the target wan interface is determined to be dialed successfully, updating the current interface information;
wherein, the target wan interface is a wan interface designated by a user.
In an optional implementation manner of this embodiment, the gateway adjusting apparatus further includes: a current wan interface name determining module, configured to determine 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 a first wan interface that acquires the IP address and/or the gateway address;
and 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 a null value.
In an optional implementation manner of this embodiment, the default gateway adjusting module 530 is specifically configured to determine an order of the wan interfaces, and determine a gateway address and a DNS address acquired by a 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 adjusting module 530 is further specifically configured to determine the gateway address and the DNS address of the target wan interface as the default gateway address and the domain name server address if the connection state of the target wan interface is the connected state.
In an optional implementation manner 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 corresponding functional modules and beneficial effects of the executing method.
EXAMPLE III
FIG. 6 illustrates a schematic structural diagram of an electronic device 10 that may be used to implement embodiments of the present 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. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, 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 embodiments of the inventions described and/or claimed herein.
As shown in fig. 6, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various suitable 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 necessary for the operation of the electronic apparatus 10 can 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.
A number of 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, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, 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, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, or the like. 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. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the gateway adaptation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the gateway adjustment method by any other suitable means (e.g. by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a 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 that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Computer programs for implementing 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 performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a 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. A 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 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) by 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 can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end 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 back-end, 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. A client and server are generally 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 host and VPS service are overcome.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the embodiments of the present invention may be executed in parallel, may be executed sequentially, or may be executed in different orders, as 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 does not limit the scope of the embodiments of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the embodiments of the present invention should be included in the scope of the embodiments of the present invention.
Claims (10)
1. A method for gateway adjustment, comprising:
polling and checking the connection state of each wan interface in the target system at every first set time interval, and if the connection state of a target wan interface is a connected state, determining the target wan interface as a default gateway;
determining whether the information of the current wan interface is null;
and when the information of the current wan interface is null, polling the connection state of the wan interfaces at intervals of a 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.
2. The method of claim 1, wherein determining the target wan interface as a default gateway comprises:
inquiring information of a current wan interface, and if the current wan interface is determined not to be the target wan interface, inquiring information of each wan interface;
if the target wan interface is determined to be dialed successfully, updating the current wan interface information;
wherein the target wan interface is a wan interface designated by a user.
3. The method of claim 1, wherein after determining the target wan interface as a default gateway, further comprising:
determining a DNS address corresponding to the target wan interface as a DNS domain name server;
the current wan interface name is determined.
4. 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 for acquiring an IP address and/or a gateway address;
and 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 a null value.
5. The method of claim 1, wherein if the connection status of the target wan interface is a disconnection status, adjusting the default gateway to the reference wan interface comprises:
determining the sequence of wan interfaces, and determining a gateway address and a DNS address acquired by a first wan interface as the default gateway address and the domain name server address;
wherein the reference wan interface is the first wan interface.
6. The method according to claim 1, wherein when the information of the current wan interface is null, polling the connection status of each wan interface at every second set time interval comprises:
and if the connection state of the target wan interface is the connected state, determining the gateway address and the DNS address of the target wan interface as the default gateway address and the domain name server address.
7. The method of claim 1, wherein the first set time interval is greater than the second set time interval.
8. A gateway adjustment apparatus, comprising:
the default gateway determining module is used for polling and checking the connection state of each wan interface in the target system at every interval of a first set time interval, and if the connection state of a target wan interface is a connected state, determining the target wan interface as a default gateway;
a null value determining module, configured to determine whether information of the current wan interface is a null value;
and a default gateway adjusting module, configured to poll the connection state of each wan interface at a second set time interval when the information of the current wan interface is null, and adjust the default gateway to refer to wan interface if the connection state of the target wan interface is a disconnected state.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the first and the second end of the pipe are connected with each other,
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-7.
10. A computer-readable storage medium, having stored thereon computer instructions for causing a processor to execute the method of adjusting a gateway according to any one of claims 1-4.
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 true CN115277410A (en) | 2022-11-01 |
CN115277410B 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) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115883383A (en) * | 2022-12-09 | 2023-03-31 | 山东有人物联网股份有限公司 | Network expansion communication method, device, equipment and storage medium |
Citations (11)
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 |
-
2022
- 2022-08-04 CN CN202210931601.9A patent/CN115277410B/en active Active
Patent Citations (11)
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)
Title |
---|
Y ZHANG: ""Improving sd-wan resilience: From vertical handoff to wan-aware MPTCP"", 《IEEE》 * |
刘胜珍;姚志鸿;杨威;: "校园网双出口策略路由实现链路备份解决方案", 电脑知识与技术, no. 17 * |
徐雄斌;杨胜钊;高焘;: "一种双冗余网络快速切换方法", 舰船电子工程, no. 11 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115883383A (en) * | 2022-12-09 | 2023-03-31 | 山东有人物联网股份有限公司 | Network expansion communication method, device, equipment and storage medium |
CN115883383B (en) * | 2022-12-09 | 2024-05-10 | 山东有人物联网股份有限公司 | Network extension communication method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115277410B (en) | 2024-04-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP2866393B1 (en) | Method and apparatus for determining virtual machine drifting | |
CA2950206C (en) | Flow entry configuration method, apparatus, and system | |
US10361992B2 (en) | Method for synchronizing virtual machine location information between data center gateways, gateway, and system | |
US9036638B2 (en) | Avoiding unknown unicast floods resulting from MAC address table overflows | |
CN107682275B (en) | Message monitoring method and device | |
JP5980725B2 (en) | Network device, relay management method, relay management program, and communication system | |
CN109067784B (en) | Method and equipment for preventing cheating in VXLAN | |
EP3059929A1 (en) | Method for acquiring physical address of virtual machine | |
CN107809386B (en) | IP address translation method, routing device and communication system | |
US8887237B2 (en) | Multimode authentication | |
CN108039968B (en) | Network optimization method, device and computer readable storage medium | |
CN115277410B (en) | Gateway adjustment method, device, electronic equipment and storage medium | |
CN107911496A (en) | A kind of VPN service terminal acts on behalf of the method and device of DNS | |
JP5980724B2 (en) | Network device, relay management method, relay management program, and communication system | |
CN107528929B (en) | ARP (Address resolution protocol) entry processing method and device | |
CN110086676B (en) | Configuration method of distributed router and related equipment | |
CN114978910B (en) | Time sensitivity realization method and system of virtualization core network | |
CN111245728A (en) | Data message forwarding method and system with multi-network card computing device | |
CN115225634A (en) | Data forwarding method and device under virtual network and computer program product | |
CN112511440B (en) | Message forwarding method, system, storage medium and electronic equipment | |
CN111800340B (en) | Data packet forwarding method and device | |
CN113612643A (en) | Network configuration method, device, equipment and storage medium of cloud mobile phone | |
CN109088767B (en) | Route updating method and device | |
EP3200433A1 (en) | Ipv6 address management method, device and terminal | |
CN108848033B (en) | Method, device and storage medium for avoiding route conflict |
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 |