Method and device for automatically identifying internet access port, electronic equipment and storage medium

By generating virtual network cards in the router and using the ARP table and the switch's MAC address table to identify port information, the problem of routers needing multiple physical network ports is solved, achieving more efficient use of physical network ports and reducing maintenance costs.

CN121585641APending Publication Date: 2026-02-27HUIZHOU GAOSHENGDA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511456711.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-13
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

In existing technologies, routers need to map physical network ports to network cards one by one, resulting in a large number of network ports required, which increases maintenance costs.

Method used

By mapping the router's physical network ports to switch ports, a virtual network card is generated. The port information is then identified through the ARP table and the switch's MAC address table, enabling automatic identification of WAN and LAN ports and reducing the number of physical network ports.

Benefits of technology

The number of physical network ports was reduced, the effective utilization rate of physical network ports was improved, and maintenance costs were reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121585641A_ABST
    Figure CN121585641A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for automatically identifying an internet access port of a router, electronic equipment and a storage medium. The method for automatically identifying the internet access port of the router comprises the following steps: mapping an internet access and a switch port, and outputting a plurality of virtual network cards; the method comprises the following steps: performing primary division processing on a switch port, and outputting an LAN virtual network card and a WAN virtual network card; acquiring network cable insertion information, performing identification processing on the network cable insertion information, and outputting port information; and according to the port information, carrying out secondary division processing on the switch port, outputting a WAN port and an LAN port, binding the WAN port with a WAN virtual network card, and binding the LAN port with an LAN virtual network card. According to the scheme provided by the invention, the number of physical network ports can be reduced, the effective utilization rate of the physical network ports is improved, and the maintenance cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of network, in particular to a method and device for automatically identifying an online port of a router, electronic equipment and storage medium. BACKGROUND

[0002] In the related art, most router products implement an automatic identification of an online port function, and an implementation scheme thereof is to try to obtain an IP through a dhcp mode on a corresponding network card, set the network card obtaining the IP as a network wan, that is, an online port. However, this mode needs to correspond the physical network port of the router to the network card one by one, and needs more network ports, thereby increasing maintenance costs. SUMMARY

[0003] The present application aims at overcoming the deficiencies in the prior art, and provides a method and device for automatically identifying an online port of a router, electronic equipment and storage medium, which can reduce the number of physical network ports, improve the effective utilization rate of the physical network ports, and reduce maintenance costs.

[0004] The present application is achieved by the following technical solutions. The first aspect of the present application provides a method for automatically identifying an online port of a router, comprising: mapping a network port and a switch port, and outputting a plurality of virtual network cards; performing a primary division on the switch port, and outputting a LAN virtual network card and a WAN virtual network card; collecting network cable insertion information, performing identification processing on the network cable insertion information, and outputting port information; performing a secondary division on the switch port according to the port information, and outputting a WAN port and a LAN port; binding the WAN port and the WAN virtual network card; and binding the LAN port and the LAN virtual network card.

[0005] The identification processing on the network cable insertion information comprises: obtaining a superior route IP address, obtaining a superior route MAC address from a router ARP table according to the superior route IP address; obtaining a switch MAC address table, and obtaining the port information according to the superior route MAC address.

[0006] The method further comprises: connecting the LAN port to a network bridge.

[0007] The method further comprises: connecting the WAN port to a network bridge.

[0008] The second aspect of the application provides a device for automatically identifying a router online port, comprising: a mapping module, configured to perform first mapping processing on a plurality of network ports corresponding to a physical network card and a switch port, and output a first port unit; a first solving module, configured to perform initial division processing on the switch port, and output a LAN virtual network card and a WAN virtual network card; a collection module, configured to collect network cable insertion information, perform identification processing on the network cable insertion information, and output port information; and a second solving module, configured to perform secondary division processing on the switch port according to the port information, output a WAN port and a LAN port, bind the WAN port with the WAN virtual network card, and bind the LAN port with the LAN virtual network card.

[0009] The collection module comprises an identification unit, which is configured to obtain a superior route IP address, obtain a superior route MAC address from a router ARP table according to the superior route IP address, obtain a switch MAC address table, and obtain the port information according to the superior route MAC address.

[0010] The device further comprises a network bridge access module, which is configured to access the LAN port to a network bridge.

[0011] The network bridge access module is further configured to access the WAN port to the network bridge.

[0012] The third aspect of the application provides an electronic device, comprising: a processor; and a memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method described above.

[0013] The fourth aspect of the application provides a computer-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, causes the processor to perform the method described above.

[0014] Compared with the prior art, the application has at least the following advantages: The application aims to map the physical network port of a router to a switch port, and then convert a plurality of ports on a plurality of switches into two virtual network cards, so as to reduce the number of physical network ports and reduce maintenance costs. BRIEF DESCRIPTION OF DRAWINGS

[0015] In order to more clearly illustrate the technical solutions of the embodiments of the application, the drawings needed in the embodiments will be briefly introduced as follows.

[0016] Figure 1 The method flowchart of the method for automatically identifying a router online port in an embodiment of the application; Figure 2 Method flow chart for another implementation of the method for automatically identifying the online port of a router in an embodiment of the present application; Figure 3 Functional module chart for the device for automatically identifying the online port of a router in an embodiment of the present application; Figure 4 Structure schematic diagram of the electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0017] Embodiments of the present application will be described in more detail with reference to the drawings. Although the embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present application will be thorough and complete, and will fully convey the scope of the present application to those skilled in the art.

[0018] It should be understood that although the terms "first", "second", "third", etc. are used to describe various information in the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information without departing from the scope of the present application. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise explicitly specified and limited.

[0019] Unless otherwise explicitly specified and limited, the terms "mounting", "connecting", "connecting", "fixing" and the like should be understood in a broad sense, for example, it can be fixedly connected, or it can be detachably connected or integrated; it can be mechanically connected, or it can be electrically connected; it can be directly connected, or it can be indirectly connected through an intermediate medium; it can be the internal communication of two elements or the interaction relationship between two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0020] Most router products implement the function of automatically identifying the online port, and the implementation scheme is to try to obtain IP on the corresponding network card by dhcp, and the network card that obtains IP is set as the network wan, that is, the online port. But this way needs to correspond the physical network port on the router with the network card one by one, needs more network ports, thereby increasing the maintenance cost.

[0021] To solve the above problems, the embodiment of the application provides a method, device, electronic equipment and storage medium for automatically identifying an online port of a router, which can reduce the number of physical network ports, improve the effective utilization rate of the physical network ports, and reduce the maintenance cost.

[0022] The technical solutions of the embodiments of the application are described in detail below with reference to the drawings.

[0023] Figure 1 FIG. 1 is a flowchart of a method for automatically identifying an online port of a router according to an embodiment of the application.

[0024] Referring to Figure 1 A method for automatically identifying an online port of a router comprises the following steps. Step S101: mapping a network port with a switch port, and outputting a plurality of virtual network cards.

[0025] It should be noted that the switch is integrated in the router, the switch has a plurality of ports, and the router backend maps a plurality of physical network ports with the switch ports. Further, after the mapping is completed, the router backend generates a plurality of virtual network cards according to the number of the switch ports.

[0026] Step S102: performing a primary division on the switch ports, and outputting a LAN virtual network card and a WAN virtual network card.

[0027] It should be noted that the switch divides all the ports thereof into VLAN1 through VLAN division. The router backend adjusts the number of the virtual network cards to two according to VLAN1, one of which is a LAN virtual network card and the other of which is a WAN virtual network card. The WAN virtual network card does not have a corresponding switch port, in other words, all the ports in VLAN1 currently correspond to the LAN virtual network card.

[0028] Step S103: collecting network cable insertion information, identifying the network cable insertion information, and outputting port information.

[0029] It should be noted that when a network cable is inserted into the router, the router backend actively sends a message about the inserted network cable to a monitoring process of the router to start network port identification, so as to obtain which online physical network port of the router is, that is, the above-mentioned port information.

[0030] Step S104: performing a secondary division on the switch ports according to the port information, outputting a WAN port and a LAN port, binding the WAN port with the WAN virtual network card, and binding the LAN port with the LAN virtual network card.

[0031] It should be noted that the switch will perform secondary division on the ports in VLAN1, and according to the port information, it is obtained which port is the WAN port for online, and then the WAN port is bound with the WAN virtual network card, and the LAN port is bound with the LAN virtual network card.

[0032] In summary, compared with the traditional one-to-one designation of the virtual network card corresponding to the network port, if the network is to be configured, multiple network cards need to be operated simultaneously. However, the present application directly abstracts the virtual network card into two LAN virtual network cards and WAN virtual network cards, and directly operates at the switch level, which can automatically identify the WAN port, that is, the same network port on the router can be a LAN port or a WAN port, thereby reducing the number of network ports.

[0033] Figure 2 For Figure 1 In a more detailed embodiment, a method for automatically identifying the network port of a router comprises: Step S201, mapping the network port with the switch port, and outputting a plurality of virtual network cards.

[0034] This step can refer to step S101, which will not be described here.

[0035] Step S202, performing primary division on the switch port, and outputting LAN virtual network cards and WAN virtual network cards.

[0036] This step can refer to step S102, which will not be described here.

[0037] Step S203, collecting the network cable insertion information, obtaining the upper-level route IP address, and obtaining the upper-level route MAC address through the router ARP table according to the upper-level route IP address. Obtain the switch MAC address table, and obtain the port information according to the upper-level route MAC address.

[0038] It's important to note that the upstream router can be an optical modem or a gateway. The router's ARP table can be used to obtain the upstream router's MAC address from its IP address. Next, the switch's MAC address table is accessed, and the port number is determined based on the upstream router's MAC address. Specifically, when a computer on the network (e.g., PC A) needs to communicate with a device at another IP address, it follows these steps to determine the target: PC A checks if the target IP address is on the same network segment as itself. If not, it sends the data packet to the pre-configured default gateway. Although PC A knows the IP address to be sent to the router, within the local area network, the data ultimately needs to be encapsulated into an Ethernet frame for transmission, and the frame header requires the target's MAC address. At this point, PC A sends an ARP request packet. This packet is essentially a broadcast query, roughly stating: "Device with IP address XXX.XXX.XXX.XXX, what is your MAC address?" The destination MAC address of this ARP request frame is FF-FF-FF-FF-FF-FF, i.e., the broadcast address. When this broadcast frame arrives at the switch, the switch performs a flooding operation, forwarding it from all ports except the receiving port. The upstream router receives this ARP request from the port it's connected to on the switch. Recognizing that its IP address has been queried, it sends an ARP reply packet containing its own MAC address. This reply is sent directly to PC A. When the router's ARP reply frame enters the switch through a port, the switch checks the frame's source MAC address and immediately learns that a device with that MAC address is connected to this port. The switch then creates or updates the mapping between the router's MAC address and the corresponding port in its MAC address table.

[0039] Step S204: Based on the port information, perform secondary partitioning of the switch ports to output WAN and LAN ports, bind the WAN port to the WAN virtual network card, and bind the LAN port to the LAN virtual network card.

[0040] This step can be referred to as step S104, and will not be repeated here.

[0041] Step S205: Connect the LAN port to the bridge or connect the WAN port to the bridge.

[0042] It should be noted that connecting the LAN or WAN port to a bridge allows the router to communicate with other electronic devices.

[0043] Furthermore, in another embodiment, a method for automatically identifying a router's internet access port further includes: Acquire and store information about each virtual network interface card and switch port; Configure mapping rules to automatically match each virtual network card with the switch port based on the information of each virtual network card and the switch port information, and output the second port unit.

[0044] It should be noted that a virtual network interface card (NIC) information collection module is deployed at the back end of the router to collect key information for each virtual NIC, including but not limited to the virtual NIC identifier, virtual machine identifier, IP address, MAC address, and virtual network to which the virtual NIC belongs. The collected virtual NIC information is stored in a pre-defined network resource database, which may be a relational or non-relational database. An association index is established between the virtual NIC identifier and other information to facilitate subsequent queries and retrieval. By comprehensively collecting key information from the virtual NICs, accurate foundational data is provided for subsequent mapping and matching, avoiding mapping errors due to missing information. Establishing an association index improves information retrieval efficiency and ensures a rapid mapping process. Furthermore, a switch port information collection module is deployed at the back end of the router. This module establishes a communication connection with the physical switch via a network management protocol. It collects key information for each switch port, including but not limited to the switch identifier, port identifier, VLAN ID, port speed, port duplex mode, current port status, MAC addresses of connected devices, and physical server connection information. The collected switch port information is stored in the aforementioned network resource database, separated from the virtual network interface card (NIC) information in a separate table. An index is established linking switch identifiers, port identifiers, and other information, while also establishing a relationship between switch ports and physical servers. This allows for comprehensive information on switch ports, clarifying the attributes and connection status of each port, providing a basis for matching with virtual NICs. Information is collected through multiple protocols to ensure its comprehensiveness and accuracy, while the established relationships facilitate precise matching later.

[0045] It should also be noted that the basic mapping rules include, but are not limited to: VLAN-based matching rules: matching the VLAN ID of the virtual network interface card (NIC) with the VLAN ID of the switch port, establishing an initial association between virtual NICs with the same VLAN ID and the switch port; MAC address-based matching rules: if the virtual machine corresponding to the NIC is already connected to the switch port through a physical server, the MAC address of the connected devices on the switch port is queried and matched with the MAC address of the virtual NIC to establish an association; physical server-based association rules: based on the physical server to which the NIC belongs, the switch port connected to that physical server is found, establishing an association between the virtual NIC and the corresponding switch port. When multiple basic mapping rules are triggered simultaneously, the final mapping relationship is determined according to a preset priority. For example, the priority from high to low is: MAC address matching rules > physical server association rules > VLAN matching rules. Administrators can adjust the priority order according to the actual network environment. In this way, by flexibly configuring multiple mapping rules, the mapping needs of different network scenarios can be met; setting priority rules can solve rule conflict problems and ensure the uniqueness and accuracy of the mapping relationship; dynamic rule adjustment is supported, improving the adaptability and flexibility of the method.

[0046] Specifically, according to the configured mapping rule priority, the virtual network interface card (NIC) information and switch port information are matched sequentially: First, the MAC address matching rule is applied: the MAC address of the virtual NIC is queried, and the switch port information is searched for ports with the same MAC address as the connected devices. If a unique matching port is found, the mapping relationship is initially determined; if multiple matching ports are found or no matching port is found, the process proceeds to the next priority rule matching. Second, the physical server association rule is applied: the physical server information to which the virtual NIC belongs is obtained, and the switch port information is searched for ports connected to that physical server. If a unique matching port is found, the mapping relationship is determined; if multiple ports are connected to the same physical server, the VLAN ID of the virtual NIC is used for further filtering to find ports with the same VLAN ID; if no match is found, the process proceeds to the next priority rule. Finally, the VLAN matching rule is applied: the switch port with the same VLAN ID as the virtual NIC is searched; if multiple such ports are found, the port is filtered based on its operating status and port speed to determine the final mapped port; if no matching port is found, a matching failure log is generated, and an alarm is triggered. In this way, the mapping efficiency is improved by replacing manual configuration through an automated matching process; the mapping relationship is ensured by matching step by step according to priority rules; and the mapping relationship is stored and indexed to facilitate subsequent querying, management and monitoring.

[0047] Corresponding to the aforementioned application function implementation method embodiments, this application also provides a device, electronic device, and corresponding embodiments for automatically identifying the Internet access port of a router.

[0048] Figure 3 This is a functional block diagram of a device for automatically identifying the Internet access port of a router, as shown in an embodiment of this application.

[0049] See Figure 3 A device for automatically identifying router internet access ports includes a mapping module 100, a first calculation module 200, a data acquisition module 300, and a second calculation module 400. The mapping module 100 performs a first mapping process between several network ports corresponding to physical network cards and switch ports, outputting a first port unit. The first calculation module 200 performs an initial partitioning process on the switch ports, outputting LAN virtual network cards and WAN virtual network cards. The data acquisition module 300 collects network cable insertion information, identifies the network cable insertion information, and outputs port information. The second calculation module 400 performs a secondary partitioning process on the switch ports based on the port information, outputting WAN ports and LAN ports, binding the WAN ports to WAN virtual network cards, and binding the LAN ports to LAN virtual network cards.

[0050] Furthermore, in one embodiment, the acquisition module 200 includes an identification unit, which is used to obtain the IP address of the upstream router, obtain the MAC address of the upstream router based on the IP address of the upstream router through the router's ARP table, and obtain the MAC address table of the switch to obtain port information based on the MAC address of the upstream router.

[0051] Furthermore, in one embodiment, a bridge access module is also included, which is used to connect the LAN port to the bridge.

[0052] Furthermore, in one embodiment, the bridge access module is also used to connect the WAN port to the bridge.

[0053] Regarding the system in the above embodiments, the specific ways in which each module performs operations have been described in detail in the embodiments related to the method, and will not be elaborated further here.

[0054] Figure 4 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application.

[0055] See Figure 4 The electronic device 1000 includes a memory 1010 and a processor 1020.

[0056] The processor 1020 can be a central processing unit (CPU), or it can be an integrated circuit composed of other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be any conventional processor that can run the Linux kernel.

[0057] Memory 1010 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. ROM may store static data or instructions required by processor 1020 or other modules of the computer. Permanent storage devices may be read-write storage devices. Permanent storage devices may be non-volatile storage devices that retain stored instructions and data even when the computer is powered off. In some embodiments, permanent storage devices use mass storage devices (e.g., magnetic or optical disks, flash memory) as permanent storage devices. In other embodiments, permanent storage devices may be removable storage devices (e.g., floppy disks, optical drives). System memory may be a read-write storage device or a volatile read-write storage device, such as dynamic random access memory. System memory may store some or all of the instructions and data required by the processor during operation. Furthermore, memory 1010 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (e.g., DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, the memory 1010 may include a removable storage device that is readable and / or writable, such as a laser disc (CD), a read-only digital multifunction optical disc (e.g., DVD-ROM, dual-layer DVD-ROM), a read-only Blu-ray disc, an ultra-high density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not contain carrier waves or transient electronic signals transmitted wirelessly or via wired connections.

[0058] The memory 1010 stores executable code, which, when processed by the processor 1020, can cause the processor 1020 to execute part or all of the methods described above.

[0059] Furthermore, the method according to this application can also be implemented as a computer program or computer program product, which includes computer program code instructions for performing some or all of the steps in the method described above.

[0060] Alternatively, this application may be implemented as a computer-readable storage medium (or a non-transitory machine-readable storage medium or a machine-readable storage medium) storing executable code (or computer program or computer instruction code) thereon, which, when executed by a processor of an electronic device (or server, etc.), causes the processor to perform part or all of the steps of the methods described above according to this application.

[0061] The solution of this application has been described in detail above with reference to the accompanying drawings. In the above embodiments, the descriptions of each embodiment have different focuses; for parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. Those skilled in the art should also understand that the actions and modules involved in the specification are not necessarily essential to this application. Furthermore, it is understood that the steps in the method of this application embodiment can be adjusted, combined, and deleted according to actual needs, and the modules in the device of this application embodiment can be combined, divided, and deleted according to actual needs. The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for automatically identifying the internet access port of a router, characterized in that, include: Map the network port to the switch port to output several virtual network cards; The switch ports are initially partitioned to output LAN virtual network cards and WAN virtual network cards. Collect network cable insertion information, identify and process the network cable insertion information, and output port information; Based on the port information, the switch port is further divided into WAN and LAN ports. The WAN port is bound to the WAN virtual network card, and the LAN port is bound to the LAN virtual network card.

2. The method for automatically identifying the internet access port of a router according to claim 1, characterized in that, The process of identifying the network cable insertion information includes: Obtain the IP address of the upstream router, and then use the router's ARP table to obtain the MAC address of the upstream router based on the IP address of the upstream router. Obtain the switch's MAC address table and retrieve the port information based on the upstream router's MAC address.

3. The method for automatically identifying the internet access port of a router according to claim 1, characterized in that, The method further includes: Connect the LAN port to the bridge.

4. The method for automatically identifying the internet access port of a router according to claim 1, characterized in that, The method further includes: Connect the WAN port to the bridge.

5. A device for automatically identifying the internet access port of a router, characterized in that, include: The mapping module is used to perform a first mapping process between several network ports corresponding to the physical network card and switch ports, and output the first port unit. The first solution module is used to perform initial partitioning of the switch ports and output LAN virtual network cards and WAN virtual network cards. The acquisition module is used to acquire network cable insertion information, identify and process the network cable insertion information, and output port information; The second calculation module is used to perform secondary division processing of the switch port according to the port information, output WAN port and LAN port, bind the WAN port to the WAN virtual network card, and bind the LAN port to the LAN virtual network card.

6. The device for automatically identifying the internet access port of a router according to claim 5, characterized in that, The acquisition module includes an identification unit, which is used to obtain the IP address of the upstream router and obtain the MAC address of the upstream router based on the IP address of the upstream router through the router's ARP table. Obtain the switch's MAC address table and retrieve the port information based on the upstream router's MAC address.

7. The device for automatically identifying the internet access port of a router according to claim 5, characterized in that, It also includes a bridge access module, which is used to connect the LAN port to the bridge.

8. The device for automatically identifying the internet access port of a router according to claim 7, characterized in that, The bridge access module is also used to connect the WAN port to the bridge.

9. An electronic device, characterized in that, include: processor; as well as A memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1-4.

10. A computer-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1-4.