Gateway equipment interface configuration matching method, electronic equipment and storage medium
By using virtual LAN and bridges in gateway devices, dynamically bind the network port and the physical interface, and automatically match the configuration according to the connection status, the problem of traditional gateway devices is solved, and the network port is automatically adapted to the network port Match and efficient interface configuration.
Patent Information
- Application Number
- CN202411540204.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-31
AI Technical Summary
Traditional gateway devices have difficulties in distinguishing between WAN ports and LAN ports, which leads to users being unable to connect to network cables correctly, which in turn affects the access and configuration of network equipment. The prior art methods increase the workload of network developers and reduce efficiency.
By adding a virtual LAN and a bridge to the gateway device, dynamically bind the physical interface of the main controller's network port and the switching module, and automatically match the interface configuration according to the connection status of the interface to achieve automatic network port adaptation.
It realizes automatic network interface adaptation, improves the accuracy of interface configuration matching, simplifies operations, reduces the workload and time of network developers, and improves efficiency.
Smart Images

Figure CN119420714A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communications, and in particular to a method for matching gateway device interface configuration, electronic equipment and storage medium. Background Art
[0002] With the popularization of the Internet, users access gateways through devices such as WiFi routers. However, traditional gateway communication products usually distinguish between WAN ports and LAN ports through fixed physical network ports. The WAN port is used to connect to the external network, and the LAN port is used to connect to the local area network. When there are a large number of network cables, users cannot distinguish whether the network port is a WAN port or a LAN port. The inability to distinguish the network cables leads to network cable connection errors, which makes the network equipment unable to access the Internet and the terminal unable to access the gateway device for configuration operations. Therefore, setting up a system so that users do not need to distinguish between WAN ports and LAN ports, and the gateway device can automatically adapt after the network cable is connected has become a hot research direction.
[0003] In the prior art, the method for matching the configuration of the gateway device interface is to establish a bridge on the WAN port and the LAN port respectively, bind the network ports to the bridges corresponding to the WAN port and the LAN port respectively, or directly configure different network ports as WAN ports. These methods require modification of the network port names corresponding to the application layer related applications as the three-layer network port names change, which increases the workload of network developers and reduces efficiency. Summary of the invention
[0004] In view of the above technical problems, the technical solution adopted by the present invention is: a method for matching gateway device interface configuration, comprising the following steps:
[0005] S100, add all interfaces of the switching module in the gateway device to the bridge established on the first network port, and configure the first virtual local area network at the same time, wherein the gateway device includes a main controller and a switching module, the main controller sets a first network port and a second network port, the first network port is configured as a LAN port, and the second network port is configured as a WAN port.
[0006] S200, confirming a candidate interface ID list according to the interfaces in the switching module, wherein the candidate interface ID list includes a plurality of candidate interface IDs, the candidate interface IDs are names corresponding to the candidate interfaces, and the candidate interfaces are connected interfaces in the switching module.
[0007] S300, according to the candidate interface ID list, obtain an initial network interface type list corresponding to the candidate interface ID list, wherein the initial network interface type list includes several initial network interface types, and each candidate interface ID corresponds to an initial network interface type, wherein S300 also includes the following steps:
[0008] S301, removing the candidate interface corresponding to the candidate interface ID from the network bridge of the first network port, and configuring the candidate interface corresponding to the candidate interface ID with a second virtual local area network and binding it with the second network port.
[0009] S302, obtaining a target network access method corresponding to the second network port from a network configuration file, wherein the target network access method is a method for the second network port in the gateway device to access the Internet.
[0010] S303: Obtain a target identifier corresponding to the candidate interface ID according to the target network access method.
[0011] S304, when the target identifier is "1", the candidate interface ID is saved in the target variable to obtain the initial network interface type corresponding to the candidate interface ID as a WAN port, wherein the target variable is a storage space for storing data.
[0012] S305, when the target identifier is "0", configuring the candidate interface corresponding to the candidate interface ID with the first virtual local area network and adding the candidate interface ID to the bridge of the first network port to obtain the initial network interface type corresponding to the candidate interface ID as a LAN port.
[0013] S400, obtaining target connection states corresponding to all interfaces of a switching module in a gateway device, wherein the target connection state is a connection state of an interface in a switching module in the gateway device obtained at a preset time interval.
[0014] S500, matching the interface configuration of the switch module in the gateway device according to the target connection state, wherein the interface configuration of the switch module in the gateway device is a LAN port or a WAN port.
[0015] The present invention protects a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the above-mentioned method for matching the interface configuration of the gateway device is implemented.
[0016] The present invention protects a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for matching the interface configuration of a gateway device is implemented.
[0017] The present invention has at least the following beneficial effects: a method for matching the interface configuration of a gateway device, comprising the following steps: adding all interfaces of a switching module in a gateway device to a network bridge established in a first network port, configuring a first virtual local area network at the same time, confirming a candidate interface ID list according to the interface in the switching module, obtaining an initial network interface type list corresponding to the candidate interface ID list according to the candidate interface ID list, wherein the candidate interface corresponding to the candidate interface ID is removed from the network bridge of the first network port, configuring a second virtual local area network for the candidate interface corresponding to the candidate interface ID and binding it to the second network port, obtaining a target network access method corresponding to the second network port from a network configuration file, and obtaining a candidate interface type list according to the target network access method. Select a target identifier corresponding to the interface ID, confirm the initial network interface type based on the target identifier, obtain the target connection status corresponding to all interfaces of the switching module in the gateway device, and match the interface configuration of the switching module in the gateway device according to the target connection status. The present invention keeps the network port name on the main controller unchanged, and the network port in the main controller is dynamically bound to each physical interface of the switching module according to the connection status. Different processing methods are used to match the interface configuration based on the different connection states of each physical interface of the switching module, thereby realizing the automatic adaptation function of the network port, making the interface configuration match more accurate. The main controller uniformly uses a fixed interface without additional processing, making the operation convenient and improving the efficiency of network developers. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0019] Figure 1 A flowchart of a method for matching gateway device interface configurations provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0021] Example
[0022] This embodiment provides a method for matching gateway device interface configuration, the method comprising the following steps: Figure 1 As shown:
[0023] S100, add all interfaces of the switching module in the gateway device to the bridge established on the first network port, and configure the first virtual local area network at the same time, wherein the gateway device includes a main controller and a switching module, the main controller sets a first network port and a second network port, the first network port is configured as a LAN port, and the second network port is configured as a WAN port.
[0024] S200, confirming a candidate interface ID list according to the interfaces in the switching module, wherein the candidate interface ID list includes a plurality of candidate interface IDs, the candidate interface IDs are names corresponding to the candidate interfaces, and the candidate interfaces are connected interfaces in the switching module.
[0025] S300, obtaining an initial network interface type list corresponding to the candidate interface ID list according to the candidate interface ID list, wherein the initial network interface type list includes several initial network interface types, and each candidate interface ID corresponds to an initial network interface type.
[0026] Specifically, S300 also includes the following steps:
[0027] S301, removing the candidate interface corresponding to the candidate interface ID from the network bridge of the first network port, and configuring the candidate interface corresponding to the candidate interface ID with a second virtual local area network and binding it with the second network port.
[0028] S302, obtaining a target network access method corresponding to the second network port from a network configuration file, wherein the target network access method is a method for the second network port in the gateway device to access the Internet.
[0029] S303, according to the target network access mode, obtain the target identifier corresponding to the candidate interface ID, wherein the target identifier is obtained in S303 through the following steps:
[0030] S3031, when the target network access mode is configured as DHCP and a DHCP service exists at the second network port connection end, the target identifier is obtained as "1", wherein the method for determining whether a DHCP service exists at the second network port connection segment is to detect it through the udhcpc tool.
[0031] S3032: When the target network access mode is configured as DHCP and there is no DHCP service at the second network port connection end, the target identifier is obtained as "0".
[0032] S3033, when the target network access mode is configured as PPPoE and a PPPoE service exists at the second network port connection end, the target identifier is obtained as "1", wherein the method for determining whether a PPPoE service exists at the second network port connection end is to detect it through a pppoe-discovery tool.
[0033] S3034: When the target network access mode is configured as PPPoE and there is no PPPoE service at the second network port connection end, the target identifier is obtained as "0".
[0034] S3035, when the target network access method is configured as a static IP and the second network port gateway IP is pinged through, the target identifier is obtained as "1", wherein the judgment method for the second network port gateway IP to be pinged through is to use the ping tool to detect the second network port gateway IP address obtained from the network configuration file.
[0035] S3036: When the target network access mode is configured as a static IP and the second network port gateway IP cannot be pinged, the target identifier is obtained as "0".
[0036] S304, when the target identifier is "1", the candidate interface ID is saved in the target variable to obtain the initial network interface type corresponding to the candidate interface ID as a WAN port, wherein the target variable is a storage space for storing data.
[0037] S305, when the target identifier is "0", configuring the candidate interface corresponding to the candidate interface ID with the first virtual local area network and adding the candidate interface ID to the bridge of the first network port to obtain the initial network interface type corresponding to the candidate interface ID as a LAN port.
[0038] S400, obtaining target connection states corresponding to all interfaces of a switching module in a gateway device, wherein the target connection state is a connection state of an interface in a switching module in the gateway device obtained at a preset time interval.
[0039] Specifically, those skilled in the art know that the preset time length can be selected according to actual needs, all of which fall within the protection scope of the present invention and will not be described in detail here.
[0040] S500, matching the interface configuration of the switch module in the gateway device according to the target connection state, wherein the interface configuration of the switch module in the gateway device is a LAN port or a WAN port.
[0041] Specifically, S500 also includes the following steps:
[0042] S501, obtaining a first key interface ID list according to a target connection state, wherein the first key interface ID list includes a plurality of first key interface IDs, and the first key interface ID is a name corresponding to the first key interface.
[0043] Specifically, the first key interface is an interface obtained from all interfaces of the switching module except the candidate interface and whose target connection status indicates being connected.
[0044] S502: Process the first key interface ID list in a first processing manner to obtain an interface configuration corresponding to each first key interface ID to match the interface configuration of the switch module.
[0045] Specifically, S502 also includes the following steps:
[0046] S1, when the target variable is not an empty set, keep the configuration of the first key interface unchanged to determine that the first key interface is configured as a LAN port.
[0047] S2, when the target variable is an empty set, the first key interface corresponding to the first key interface ID is removed from the bridge of the first network port, and the first key interface corresponding to the first key interface ID is configured with a second virtual local area network and bound to the second network port.
[0048] S3, obtaining a target network access method corresponding to the second network port from a network configuration file, wherein the target network access method is a method for the second network port in the gateway device to access the Internet.
[0049] S4, according to the target network access mode, obtain the key identifier corresponding to the first key interface ID, wherein the key identifier is obtained in S4 through the following steps:
[0050] S41, when the target network access mode is configured as DHCP and a DHCP service exists at the second network port connection end, a key identifier is obtained as "1", wherein the method for determining whether a DHCP service exists at the second network port connection segment is to detect it through a udhcpc tool.
[0051] S42: When the target network access mode is configured as DHCP and there is no DHCP service at the second network port connection end, the key identifier is obtained as "0".
[0052] S43, when the target network access mode is configured as PPPoE and a PPPoE service exists at the second network port connection end, a key identifier is obtained as "1", wherein the method for determining whether a PPPoE service exists at the second network port connection end is to detect it through a pppoe-discovery tool.
[0053] S44, when the target network access mode is configured as PPPoE and there is no PPPoE service at the second network port connection end, obtaining a key identifier of "0".
[0054] S45, when the target network access method is configured as a static IP and the second network port gateway IP is pinged through, the key identifier is obtained as "1", wherein the judgment method for the second network port gateway IP to be pinged through is to use the ping tool to detect the second network port gateway IP address obtained from the network configuration file.
[0055] S46, when the target network access mode is configured as a static IP and the second network port gateway IP cannot be pinged, the key identifier is obtained as "0".
[0056] S5, when the key identifier is "1", the first key interface ID is saved in the target variable to obtain the interface corresponding to the first key interface ID configured as a WAN port, wherein the target variable is a storage space for storing data.
[0057] S6, when the key identifier is "0", the first key interface corresponding to the first key interface ID is configured with a first virtual local area network and the first key interface ID is added to the bridge of the first network port to obtain the interface corresponding to the first key interface ID configured as a LAN port.
[0058] S503: Obtain a second key interface ID list according to the target connection state, wherein the second key interface ID list includes a plurality of second key interface IDs, and the second key interface ID is a name corresponding to the second key interface.
[0059] Specifically, the second key interface is an interface whose target connection status is obtained and displayed as disconnected from among the candidate interfaces.
[0060] S504: Process the second key interface ID list in a second processing manner to obtain an interface configuration corresponding to each second key interface ID to match the interface configuration of the switch module.
[0061] Specifically, S504 also includes the following steps:
[0062] S5041, when the second key interface ID is consistent with the interface ID recorded in the target variable, the second key interface corresponding to the second key interface ID is configured with the first virtual LAN and the second key interface ID is added to the bridge of the first network port. At the same time, the target variable is cleared to obtain the target network interface type corresponding to the second key interface ID as a LAN port.
[0063] S5042: When the second key interface ID is inconsistent with the interface ID recorded in the target variable, the second key interface configuration is kept unchanged to determine that the second key interface is configured as a LAN port.
[0064] From the above content, it can be seen that in this embodiment, the network port name on the main controller remains unchanged, the network port in the main controller is dynamically bound to each physical interface of the switching module according to the connection status, and different processing methods are used to match the interface configuration based on the different connection states of each physical interface of the switching module, thereby realizing the automatic adaptation function of the network port, making the interface configuration matching more accurate, and the main controller uniformly uses fixed interfaces without the need for additional processing, which makes operation convenient and improves the efficiency of network developers.
[0065] The present embodiment provides a method for matching the interface configuration of a gateway device, comprising the following steps: adding all interfaces of a switching module in the gateway device to a network bridge established on a first network port, configuring a first virtual local area network at the same time, confirming a candidate interface ID list according to the interface in the switching module, obtaining an initial network interface type list corresponding to the candidate interface ID list according to the candidate interface ID list, wherein the candidate interface corresponding to the candidate interface ID is removed from the network bridge of the first network port, configuring a second virtual local area network for the candidate interface corresponding to the candidate interface ID and binding it to the second network port, obtaining a target network access method corresponding to the second network port from a network configuration file, and obtaining the candidate interface ID according to the target network access method. D corresponds to a target identifier, confirms the initial network interface type based on the target identifier, obtains the target connection status corresponding to all interfaces of the switching module in the gateway device, and matches the interface configuration of the switching module in the gateway device according to the target connection status. The present invention keeps the network port name on the main controller unchanged, and the network port in the main controller is dynamically bound to each physical interface of the switching module according to the connection status. Different processing methods are used to match the interface configuration based on the different connection states of each physical interface of the switching module, thereby realizing the automatic adaptation function of the network port, making the interface configuration matching more accurate. The main controller uniformly uses a fixed interface without the need for additional processing, making the operation convenient and improving the efficiency of network developers.
[0066] An embodiment of the present invention also provides a non-transitory computer-readable storage medium, which can be set in an electronic device to store at least one instruction or at least one program related to implementing a method in a method embodiment. The at least one instruction or the at least one program is loaded and executed by the processor to implement the method provided in the above embodiment.
[0067] An embodiment of the present invention further provides an electronic device, comprising a processor and the aforementioned non-transitory computer-readable storage medium.
[0068] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.
Claims
1. A method for matching gateway device interface configuration, characterized in that: The method comprises the following steps: S100, adding all interfaces of the switching module in the gateway device to the bridge established on the first network port, and configuring the first virtual local area network at the same time, wherein the gateway device includes a main controller and a switching module, the main controller is configured with a first network port and a second network port, the first network port is configured as a LAN port, and the second network port is configured as a WAN port; S200, confirming a candidate interface ID list according to the interface in the switching module, wherein the candidate interface ID list includes a plurality of candidate interface IDs, the candidate interface ID is a name corresponding to the candidate interface, and the candidate interface is an interface connected in the switching module; S300, according to the candidate interface ID list, obtain an initial network interface type list corresponding to the candidate interface ID list, wherein the initial network interface type list includes several initial network interface types, and each candidate interface ID corresponds to an initial network interface type, wherein S300 also includes the following steps: S301, removing the candidate interface corresponding to the candidate interface ID from the bridge of the first network port, and configuring the candidate interface corresponding to the candidate interface ID with a second virtual local area network and binding it to the second network port; S302, obtaining a target network access method corresponding to the second network port from a network configuration file, wherein the target network access method is a method for the second network port in the gateway device to access the Internet; S303, obtaining a target identifier corresponding to the candidate interface ID according to the target network access method; S304, when the target identifier is "1", the candidate interface ID is saved in the target variable to obtain the initial network interface type corresponding to the candidate interface ID as a WAN port, wherein the target variable is a storage space for storing data; S305, when the target identifier is "0", configuring the first virtual local area network for the candidate interface corresponding to the candidate interface ID and adding the candidate interface ID to the bridge of the first network port to obtain the initial network interface type corresponding to the candidate interface ID as a LAN port; S400, obtaining target connection states corresponding to all interfaces of a switching module in a gateway device, wherein the target connection state is a connection state of an interface in a switching module in a gateway device obtained at a preset time interval; S500, matching the interface configuration of the switch module in the gateway device according to the target connection state, wherein the interface configuration of the switch module in the gateway device is a LAN port or a WAN port.
2. The method for matching gateway device interface configuration according to claim 1, characterized in that: In S303, the target identifier is obtained through the following steps: S3031, when the target network access mode is configured as DHCP and a DHCP service exists at the second network port connection end, the target identifier is obtained as "1", wherein the method for determining whether a DHCP service exists at the second network port connection segment is to detect it through the udhcpc tool; S3032, when the target network access mode is configured as DHCP and there is no DHCP service at the second network port connection end, the target identifier is obtained as "0"; S3033, when the target network access mode is configured as PPPoE and the second network port connection end has a PPPoE service, the target identifier is obtained as "1", wherein the method for determining whether the second network port connection end has a PPPoE service is to detect it through a PPPoe-discovery tool; S3034, when the target network access mode is configured as PPPoE and there is no PPPoE service at the second network port connection end, the target identifier is obtained as "0"; S3035, when the target network access mode is configured as a static IP and the second network port gateway IP is pinged, the target identifier is obtained as "1", wherein the second network port gateway IP is pinged by using a ping tool to detect the second network port gateway IP address obtained from the network configuration file; S3036: When the target network access mode is configured as a static IP and the second network port gateway IP cannot be pinged, the target identifier is obtained as "0".
3. The method for matching gateway device interface configuration according to claim 1, characterized in that: S500 also includes the following steps: S501, acquiring a first key interface ID list according to a target connection state, wherein the first key interface ID list includes a plurality of first key interface IDs, and the first key interface ID is a name corresponding to the first key interface; S502, processing the first key interface ID list in a first processing manner, obtaining an interface configuration corresponding to each first key interface ID to match the interface configuration of the switching module; S503, according to the target connection state, obtain a second key interface ID list, wherein the second key interface ID list includes a plurality of second key interface IDs, and the second key interface ID is a name corresponding to the second key interface; S504: Process the second key interface ID list in a second processing manner to obtain an interface configuration corresponding to each second key interface ID to match the interface configuration of the switch module.
4. The method for matching gateway device interface configuration according to claim 3, characterized in that: The first key interface is an interface obtained from all interfaces of the switching module except the candidate interface and whose target connection status indicates that the interface is connected.
5. The method for matching gateway device interface configuration according to claim 3, characterized in that: The second key interface is an interface whose target connection status is obtained and displayed as disconnected from among the candidate interfaces.
6. The method for matching gateway device interface configuration according to claim 3, characterized in that: S502 also includes the following steps: S1, when the target variable is not an empty set, keep the configuration of the first key interface unchanged to determine that the first key interface is configured as a LAN port; S2, when the target variable is an empty set, removing the first key interface corresponding to the first key interface ID from the bridge of the first network port, and configuring the first key interface corresponding to the first key interface ID with a second virtual local area network and binding it to the second network port; S3, obtaining a target network access method corresponding to the second network port from a network configuration file, wherein the target network access method is a method for the second network port in the gateway device to access the Internet; S4, obtaining a key identifier corresponding to the first key interface ID according to the target network access method; S5, when the key identifier is "1", the first key interface ID is saved in the target variable to obtain the interface configuration corresponding to the first key interface ID as a WAN port, wherein the target variable is a storage space for storing data; S6, when the key identifier is "0", configure the first key interface corresponding to the first key interface ID into a first virtual local area network and add the first key interface ID to the bridge of the first network port to obtain the interface corresponding to the first key interface ID configured as a LAN port.
7. The method for matching gateway device interface configuration according to claim 3, characterized in that: S504 also includes the following steps: S5041, when the second key interface ID is consistent with the interface ID recorded in the target variable, configure the first virtual local area network for the second key interface corresponding to the second key interface ID and add the second key interface ID to the bridge of the first network port, while clearing the target variable to obtain the target network interface type corresponding to the second key interface ID as a LAN port; S5042: When the second key interface ID is inconsistent with the interface ID recorded in the target variable, the second key interface configuration is kept unchanged to determine that the second key interface is configured as a LAN port.
8. A non-transitory computer-readable storage medium, characterized in that: The storage medium stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the method as claimed in any one of claims 1 to 7.
9. An electronic device, characterized in that: The invention comprises a processor and the non-transitory computer-readable storage medium as claimed in claim 8.
Citation Information
Patent Citations
Method and device for automatically recognizing LAN (Local Area Network) port and WAN (Wide Area Network) port
CN106341246A
Automatic adaption method for LAN interface and WAN interface and router
CN108667672A
Intelligent network connection method, system and device and storage medium
CN114640582A
Automatic LAN / WAN port detection
US20060159029A1
Business automatic classification method, device, and system in GPON system
WO2016062103A1