Switch mac address and vlan management method, device and equipment and storage medium

By using access control list rule matching and VLAN access control, the complexity and security deficiencies of static configuration in the management of MAC address and VLAN binding relationships of switches are resolved, achieving efficient and flexible network management and security control.

CN120639740BActive Publication Date: 2026-11-24SHENZHEN FENGRUNDA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510693224.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-27
Publication Date
2026-11-24
Estimated Expiration
2045-05-27

AI Technical Summary

Technical Problem

In existing technologies, the management method of binding MAC addresses and VLANs of switches has problems such as easy error in static configuration, high maintenance cost, lack of flexibility and insufficient security. It cannot efficiently, flexibly and securely manage the binding relationship between MAC addresses and VLANs.

Method used

By obtaining access control list rules and source MAC addresses in data packets, matching results are generated based on the rules. The target VLAN identifier of the data packet is determined based on the matching results, and VLAN access control is performed, including dynamic updates and fine-grained security policy management.

Benefits of technology

It simplifies network management, improves network flexibility and security, ensures the correct forwarding of data packets and network robustness, and prevents unauthorized device access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120639740B_ABST
    Figure CN120639740B_ABST
Patent Text Reader

Abstract

This application discloses a method, apparatus, device, and storage medium for managing MAC addresses and VLANs of a switch, relating to the field of network communication technology. This application simplifies network management and improves network security and flexibility by obtaining access control list rules and source MAC addresses in data packets; performing rule matching on the source MAC addresses based on the access control list rules to generate matching results; determining the target VLAN identifier of the data packet based on the matching results; and performing VLAN access control based on the target VLAN identifier.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of network communication, and in particular to a method, apparatus, device and storage medium for managing switch MAC addresses and VLANs. Background Technology

[0002] In the field of network communication, switches, as core devices, undertake the important tasks of data packet forwarding and network isolation.

[0003] Currently, MAC (Media Access Control Address) based virtual LAN (VLAN) functionality typically relies on static configuration or protocol-based methods to allocate and manage the binding of MAC addresses to VLANs. However, this approach has significant drawbacks. First, static configuration requires network administrators to manually set the mapping relationship between MAC addresses and VLANs, which is not only prone to errors but also extremely costly to configure and maintain in large-scale networks. Second, traditional methods lack flexibility and cannot dynamically adjust the binding relationship between MAC addresses and VLANs based on actual traffic, limiting the network's adaptive capabilities. Furthermore, existing MAC address and VLAN binding methods often lack fine-grained security policy control, potentially allowing unauthorized devices to access the network and threatening network security.

[0004] Therefore, as network scale expands and complexity increases, how to efficiently, flexibly, and securely manage the binding relationship between switch MAC addresses and VLANs is a problem that urgently needs to be solved. Summary of the Invention

[0005] The main purpose of this application is to provide a method, device, equipment and storage medium for managing MAC addresses and VLANs of a switch, aiming to solve the technical problem of how to efficiently, flexibly and securely manage the binding relationship between MAC addresses and VLANs of a switch.

[0006] To achieve the above objectives, this application proposes a method for managing MAC addresses and VLANs of a switch, the method comprising:

[0007] Retrieve access control list rules and source MAC addresses from data packets;

[0008] Based on the access control list rules, the source MAC address is matched to generate a matching result;

[0009] The target VLAN identifier of the data packet is determined based on the matching result;

[0010] VLAN access control is performed based on the target VLAN identifier.

[0011] In one embodiment, the step of obtaining access control list rules includes:

[0012] Obtain rule priority, device type matching conditions, traffic type matching conditions, and time type matching conditions;

[0013] Access control list rules are obtained based on the rule priority, the device type matching condition, the traffic type matching condition, and the time type matching condition.

[0014] In one embodiment, the step of obtaining access control list rules based on the rule priority, the device type matching condition, the traffic type matching condition, and the time type matching condition includes:

[0015] The device type matching conditions, traffic type matching conditions, and time type matching conditions are sorted according to the rule priority to generate a sorted priority rule set.

[0016] The device type matching logic is obtained based on the device type matching conditions.

[0017] The filtering parameters are obtained based on the traffic type matching conditions, and the filtering parameters include protocol type and bandwidth threshold.

[0018] The effective time corresponding to different rules is obtained based on the time type matching conditions;

[0019] Access control list rules are generated based on the priority rule set, the device type matching logic, the filtering parameters, and the effective time.

[0020] In one embodiment, the step of performing rule matching on the source MAC address based on the access control list rules to generate a matching result includes:

[0021] Obtain the current time, device type, and traffic type from the data packet;

[0022] The access control list rules are parsed to obtain matching elements, which include source MAC address range, priority identifier, effective time, device type range, and traffic type range.

[0023] The access control list rules are sorted based on the priority identifier to generate a priority sorting queue;

[0024] The matching result is obtained by matching the source MAC address, the current time, the device type, and the traffic type according to the priority sorting queue and the matching elements.

[0025] In one embodiment, the step of matching the source MAC address, the current time, the device type, and the traffic type according to the priority sorting queue and the matching elements to obtain a matching result includes:

[0026] Each rule is traversed sequentially in descending order of the priority sorting queue, and a matching judgment is performed on the traversed rules.

[0027] If any one of the following conditions is met: the source MAC address belongs to the source MAC address range of the rule, the current time is within the effective time of the rule, the device type of the data packet matches the device type range of the rule, or the traffic type matches the traffic type range of the rule, the matching result is determined to be a successful match, and the traversal is terminated.

[0028] If none of the following conditions are met: the source MAC address belongs to the source MAC address range of the rule, the current time is within the effective time of the rule, the device type of the data packet matches the device type range of the rule, and the traffic type matches the traffic type range of the rule, and no rule meets the matching conditions after traversal, the matching result is determined to be a matching failure.

[0029] In one embodiment, the step of determining the target VLAN identifier of the data packet based on the matching result includes:

[0030] When the matching result is a successful match, the target rule that is successfully matched is obtained, and the VLAN identifier bound in the target rule is extracted as the target VLAN identifier;

[0031] When the matching result is a failure, a preset default VLAN identifier or upper-layer configuration policy is obtained, and the target VLAN identifier is determined according to the default VLAN identifier or upper-layer configuration policy.

[0032] In one embodiment, the step of performing VLAN access control based on the target VLAN identifier includes:

[0033] Obtain the target MAC address from the data packet;

[0034] When the target MAC address matches the target VLAN identifier, the data packet is forwarded to the target VLAN according to the target VLAN identifier;

[0035] When the target MAC address does not match the target VLAN identifier, the transmission of the data packet is prohibited and a security alarm log is generated.

[0036] Furthermore, to achieve the above objectives, this application also proposes a switch MAC address and VLAN management device, the device comprising:

[0037] The data extraction module is used to obtain the source MAC address from access control list rules and data packets;

[0038] The rule matching module is used to perform rule matching on the source MAC address based on the access control list rules to generate matching results;

[0039] The VLAN allocation module is used to determine the target VLAN identifier of the data packet based on the matching result;

[0040] The access control module is used to perform VLAN access control based on the target VLAN identifier.

[0041] In addition, to achieve the above objectives, this application also proposes a switch MAC address and VLAN management device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the switch MAC address and VLAN management method described above.

[0042] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the switch MAC address and VLAN management method described above.

[0043] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the switch MAC address and VLAN management method described above.

[0044] This application provides a method for managing MAC addresses and VLANs on a switch. The method includes: obtaining access control list rules and source MAC addresses from data packets; performing rule matching on the source MAC addresses based on the access control list rules to generate a matching result; determining the target VLAN identifier of the data packet based on the matching result; and performing VLAN access control based on the target VLAN identifier. In summary, this application simplifies network management and improves network security and flexibility through steps such as access control list configuration, MAC address learning, VLAN allocation, and access control. Attached Figure Description

[0045] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0046] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 This is a flowchart illustrating the first embodiment of the switch MAC address and VLAN management method of this application;

[0048] Figure 2 This is a flowchart illustrating the second embodiment of the switch MAC address and VLAN management method of this application;

[0049] Figure 3 This is a flowchart illustrating the third embodiment of the switch MAC address and VLAN management method of this application;

[0050] Figure 4 This is a schematic diagram of the module structure of the switch MAC address and VLAN management device in an embodiment of this application;

[0051] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the switch MAC address and VLAN management method in this embodiment of the application.

[0052] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0053] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0054] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0055] The main solution of this application embodiment is: to obtain access control list rules and source MAC addresses in data packets; to perform rule matching on the source MAC addresses based on the access control list rules to generate matching results; to determine the target VLAN identifier of the data packets based on the matching results; and to perform VLAN access control based on the target VLAN identifier.

[0056] In the field of network communication, switches, as core devices, undertake the important tasks of data packet forwarding and network isolation.

[0057] Currently, MAC (Media Access Control Address) based virtual LAN (VLAN) functionality typically relies on static configuration or protocol-based methods to allocate and manage the binding of MAC addresses to VLANs. However, this approach has significant drawbacks. First, static configuration requires network administrators to manually set the mapping relationship between MAC addresses and VLANs, which is not only prone to errors but also extremely costly to configure and maintain in large-scale networks. Second, traditional methods lack flexibility and cannot dynamically adjust the binding relationship between MAC addresses and VLANs based on actual traffic, limiting the network's adaptability. Furthermore, existing MAC address and VLAN binding methods often lack fine-grained security policy control, potentially allowing unauthorized devices to access the network and threatening network security. Therefore, as network scale and complexity increase, how to efficiently, flexibly, and securely manage the binding relationship between MAC addresses and VLANs on switches is a pressing issue that needs to be addressed.

[0058] This application simplifies network management and improves network security and flexibility through steps such as access control list configuration, MAC address learning, VLAN allocation, and access control.

[0059] It should be noted that the executing entity in this embodiment can be a switch MAC address and VLAN management system, a computing service device with data processing, network communication, and program execution functions, or an electronic device capable of implementing the aforementioned switch MAC address and VLAN management functions. This embodiment does not specifically limit it in this way. The following uses a switch MAC address and VLAN management system as an example to describe this embodiment and the following embodiments.

[0060] Based on this, this application provides a method for managing switch MAC addresses and VLANs, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the switch MAC address and VLAN management method of this application.

[0061] In this embodiment, the switch MAC address and VLAN management method includes steps S10 to S40:

[0062] Step S10: Obtain the access control list rules and the source MAC address in the data packet.

[0063] It should be noted that in this step, when the system receives a data packet, it first parses the packet to obtain its source MAC address. Simultaneously, the system retrieves configured access control list rules (ACL rules) from its internal storage. These rules are predefined by the network administrator through the system's configuration interface or command-line interface and include key information such as the source MAC address, VLAN identifier, priority, and type.

[0064] Additionally, it's important to note that the source MAC address refers to the MAC address of the data packet sender, used to uniquely identify the sending device within the network. Access control list rules are a series of rules configured on the switch to define which MAC address ranges should be assigned to which VLAN, as well as the priority and other relevant parameters of these assignments.

[0065] Step S20: Perform rule matching on the source MAC address based on the access control list rules to generate a matching result.

[0066] It should be noted that in this step, the system will match the obtained source MAC address with each of the retrieved ACL rules. The matching process will consider factors such as rule priority, type (e.g., device type matching, traffic type matching, time type matching), and effective time. If the source MAC address completely matches a certain ACL rule (including MAC address range, priority, type, and time conditions), a successful match result will be generated; otherwise, a failed match result will be generated.

[0067] Additionally, it should be noted that the matching result refers to the result after the source MAC address is matched with the ACL rule, including successful matching (a matching rule was found) and failed matching (no matching rule was found).

[0068] Step S30: Determine the target VLAN identifier of the data packet based on the matching result.

[0069] It's important to note that the target VLAN identifier refers to the unique identifier of the VLAN to which the data packet should be assigned. It's crucial information used by the switch to distinguish between different VLANs. In this step, the system determines the target VLAN identifier of the data packet based on the matching results. Specifically, it uses the VLAN identifier from the matched ACL rule as the target VLAN identifier.

[0070] Understandably, the purpose of this step is to determine which VLAN a data packet should be assigned to, thereby achieving effective isolation and management of network traffic. By determining the target VLAN identifier, the switch can ensure that data packets are forwarded within the correct VLAN, preventing unauthorized devices or traffic from accessing the network across VLANs.

[0071] In one feasible implementation, step S30 specifically includes:

[0072] Step S301: When the matching result is a successful match, obtain the target rule that has been successfully matched, and extract the VLAN identifier bound in the target rule as the target VLAN identifier.

[0073] It should be noted that when the system completes the matching of the source MAC address with the ACL rule and the matching result is successful, the switch will immediately locate the specific ACL rule that matched successfully, i.e., the target rule. This target rule contains the pre-defined source MAC address or MAC address range, as well as the VLAN identifier bound to it. The switch extracts the VLAN identifier from the target rule and uses it as the target VLAN identifier for the current data packet.

[0074] Additionally, it should be noted that the target rule refers to the specific rule in the ACL rule set that successfully matches the source MAC address. This rule contains the source MAC address or MAC address range, as well as the VLAN identifier bound to it.

[0075] Step S302: When the matching result is a failure, obtain the preset default VLAN identifier or upper-layer configuration policy, and determine the target VLAN identifier according to the default VLAN identifier or upper-layer configuration policy.

[0076] It's important to note that when the system completes a match between the source MAC address and the ACL rule, but the match fails, the system employs an alternative strategy to determine the target VLAN ID of the data packet. Specifically, the system first checks if a default VLAN ID is preset. If a default VLAN ID is preset, it is directly used as the target VLAN ID. If no default VLAN ID is preset, the switch further checks for the existence of an upper-layer configuration policy. Upper-layer configuration policies refer to policies or rules at a higher level than the current switch configuration in the network. These upper-layer configurations are set by the network administrator or network management system and are used to guide the switch's VLAN allocation behavior. This policy is based on various factors such as network topology, device type, and security requirements. Based on this upper-layer configuration policy, the switch determines a corresponding target VLAN ID.

[0077] Understandably, the purpose of this step is to provide a backup VLAN allocation scheme when the source MAC address of a data packet does not match the ACL rule, ensuring that the data packet can still be correctly forwarded to a certain VLAN. By presetting a default VLAN identifier or upper-layer configuration policies, the switch enhances the robustness and flexibility of the network, ensuring normal forwarding of network traffic even if the ACL rule configuration is incomplete or contains errors.

[0078] Step S40: Perform VLAN access control based on the target VLAN identifier.

[0079] It's important to note that in this step, the system performs VLAN access control on data packets based on the determined target VLAN identifier. This includes checking if the destination MAC address of the data packet matches the configured VLAN, and determining whether cross-VLAN communication is allowed based on ACL rules. If the destination VLAN of the data packet does not match the configuration, or if cross-VLAN communication does not comply with ACL rules, the data packet will be dropped or its forwarding will be restricted.

[0080] Additionally, it's important to note that as network topology changes (such as device relocation or IP address changes), the binding relationship between MAC addresses and VLANs will also change. The dynamic update module can automatically detect these changes in the network and update ACL rules and VLAN bindings as needed. Specifically, the system periodically scans the network status or detects device changes based on event-driven mechanisms. Once a device is detected joining a new VLAN or its IP address changes, the system automatically updates the ACL rules to adjust the MAC address and VLAN binding relationship.

[0081] Understandably, VLAN access control is a process of restricting and managing the forwarding behavior of data packets in a network based on the target VLAN identifier, aiming to ensure network security and compliance.

[0082] In one feasible implementation, step S40 specifically includes:

[0083] Step S401: Obtain the target MAC address in the data packet.

[0084] It's important to note that when the system receives a data packet, it first parses the packet's header information to extract the destination MAC address. The destination MAC address is the physical address of the device to which the data packet is intended to be delivered; the system needs this address to determine the packet's forwarding path. In essence, it refers to the physical address of the device specified in the packet's header. In an Ethernet environment, each network device has a unique MAC address used for communication within the local area network.

[0085] Step S402: When the target MAC address matches the target VLAN identifier, forward the data packet to the target VLAN according to the target VLAN identifier.

[0086] It should be noted that after obtaining the destination MAC address and destination VLAN identifier of the data packet, the system will check whether the destination MAC address belongs to the VLAN corresponding to the destination VLAN identifier. If the match is successful, that is, the destination MAC address does exist in the destination VLAN, the system will forward the data packet to the corresponding port within that VLAN according to the destination VLAN identifier, thereby achieving correct data packet transmission.

[0087] Step S403: When the target MAC address does not match the target VLAN identifier, the transmission of the data packet is prohibited and a security alarm log is generated.

[0088] It should be noted that if the switch finds during the inspection that the target MAC address does not match the target VLAN identifier (i.e., the target MAC address does not belong to the target VLAN), the switch will block the transmission of the data packet and generate a corresponding security alarm log. The security alarm log will record relevant information about the data packet, such as the source MAC address, the target MAC address, the target VLAN identifier, and the time of the transmission ban, so that network administrators can perform subsequent analysis and processing.

[0089] Understandably, this step serves to prevent unauthorized devices or traffic from accessing the network across VLANs, thereby improving network security.

[0090] This embodiment provides a method for managing MAC addresses and VLANs on a switch. The method includes: obtaining access control list rules and the source MAC address in a data packet; performing rule matching on the source MAC address based on the access control list rules to generate a matching result; determining the target VLAN identifier of the data packet based on the matching result; and performing VLAN access control based on the target VLAN identifier. In summary, this embodiment simplifies network management and improves network security and flexibility through steps such as access control list configuration, MAC address learning, VLAN allocation, and access control.

[0091] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the switch MAC address and VLAN management method of this application. The steps for obtaining access control list rules specifically include:

[0092] Step A10: Obtain rule priority, device type matching conditions, traffic type matching conditions, and time type matching conditions.

[0093] It's important to note that in this step, the system first reads the Access Control List (ACL) configuration information from its configuration store. During this process, the system focuses on four aspects of configuration information: rule priority, device type matching conditions, traffic type matching conditions, and time type matching conditions. Rule priority refers to the priority value extracted by the switch from the ACL configuration for each rule. These priority values ​​determine which rule will be applied first when multiple rules match simultaneously; a smaller priority value indicates a higher priority. Device type matching conditions refer to the switch parsing the ACL configuration and identifying conditions used to match device types, such as MAC address prefixes and vendor information. These conditions are used to determine whether a data packet originates from a specific type of device. Traffic type matching conditions refer to the switch extracting conditions from the ACL used to match traffic types, such as protocol type and port number. These conditions are used to identify the traffic characteristics of data packets. Time type matching conditions refer to the switch reading time-related conditions from the ACL configuration, such as the specific time period during which the rule takes effect. These conditions are used to control the applicability of rules across different time periods.

[0094] Step A20: Obtain the access control list rules based on the rule priority, the device type matching condition, the traffic type matching condition, and the time type matching condition.

[0095] It's important to note that in this step, the system constructs complete ACL rules based on the acquired matching conditions and priority values. Specifically, the switch combines the matching conditions and priority values ​​of each rule into a structured rule entry and stores it in the ACL rule base. These rule entries will be used for subsequent packet matching and processing. In essence, the purpose of this step is to combine matching conditions and priority values ​​into a structured rule entry to guide the switch's packet processing. These rule entries include fields such as source MAC address, destination MAC address, protocol type, port number, and priority, as well as corresponding processing actions (such as allow, deny, forward, etc.). The ACL rule base refers to the database or data structure within the switch used to store ACL rules. When processing a packet, the switch queries the rule entries in the ACL rule base to determine how to handle the packet.

[0096] In one feasible implementation, step A20 specifically includes:

[0097] Step A201: Sort the device type matching conditions, traffic type matching conditions, and time type matching conditions according to the rule priority to generate a sorted priority rule set.

[0098] It's important to note that in this step, the system reads the rule priority information from the configuration and then sorts the device type matching conditions, traffic type matching conditions, and time type matching conditions according to these priority values. The sorting is based on the priority value; the smaller the value, the higher the priority. After sorting, a rule set is generated, arranged from highest to lowest priority. This step ensures that when processing data packets, the switch applies rules according to a predetermined priority order, thereby guaranteeing that critical traffic and devices receive priority processing.

[0099] Step A202: Obtain the device type matching logic based on the device type matching conditions.

[0100] It should be noted that device type matching logic refers to the logical statements or combinations of conditions used to determine whether a data packet originates from a specific type of device. Specifically, in this step, the system extracts device type matching conditions from the ACL configuration, such as MAC address prefixes and vendor identifiers, and constructs the device type matching logic based on these conditions. The matching logic includes conditional statements used to determine whether a data packet originates from a specific type of device.

[0101] Step A203: Obtain filtering parameters based on the traffic type matching conditions. The filtering parameters include protocol type and bandwidth threshold.

[0102] It's important to note that in this step, the system extracts traffic type matching conditions from the ACL configuration, such as protocol type and port number, and determines the filtering parameters based on these conditions. Filtering parameters are used to restrict or allow specific types of traffic to pass through, including protocol type and bandwidth thresholds. Protocol type refers to the communication protocol used for packet transmission, such as TCP, UDP, and HTTPS. Bandwidth threshold refers to the upper limit of allowed traffic bandwidth, used to control network congestion and ensure the bandwidth requirements of critical applications.

[0103] Understandably, the purpose of this step is to enable the switch to implement fine-grained traffic control policies based on traffic type, ensuring the rational allocation and efficient utilization of network resources.

[0104] Step A204: Obtain the effective time corresponding to different rules based on the time type matching conditions.

[0105] It's important to note that the effective time refers to the specific time or period during which an ACL rule begins and ends its effective period. In this step, the system reads the time type matching conditions from the ACL configuration, such as the specific time period during which the rule takes effect (e.g., weekdays, holidays). Then, the system determines the effective time for different rules based on the time type matching conditions, ensuring that the rules are applied within the correct time period.

[0106] Understandably, the purpose of this step is to enable the switch to flexibly adjust the application of rules based on time factors, thereby achieving more refined traffic management.

[0107] Step A205: Generate access control list rules based on the priority rule set, the device type matching logic, the filtering parameters, and the effective time.

[0108] It's important to note that in this step, the system constructs a complete ACL rule based on the generated priority rule set, device type matching logic, filtering parameters, and effective time. These rules guide the switch on how to apply matching conditions, filtering parameters, and effective time when processing data packets, thereby achieving fine-grained traffic control and security management. For example, the system might construct a complete ACL rule based on the generated priority rule set (server traffic priority), device type matching logic (specific vendor server), filtering parameters (HTTPS protocol, 10Mbps bandwidth threshold), and effective time (8:00 AM to 12:00 AM). This rule will guide the switch to allow HTTPS traffic from a specific vendor server to pass through and give it high priority if the bandwidth does not exceed 10Mbps and is within the effective time.

[0109] Step A30: Obtain the source MAC address from the data packet.

[0110] It is understandable that this step is a breakdown of step S10. For content that is the same as or similar to step S10, please refer to the above description, which will not be repeated here.

[0111] In this embodiment, matching conditions are sorted by rule priority and an ACL rule set is constructed. Specific ACL rules are generated by combining device type, traffic type, and time type matching logic. This realizes dynamic and fine-grained control of MAC address and VLAN binding, solves the problems of complexity, poor flexibility, and insufficient security of traditional static configuration management, and improves the efficiency, flexibility, and security of network management.

[0112] Based on the first and second embodiments of this application, in the third embodiment of this application, the content that is the same as or similar to that in embodiments one and two above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 , Figure 3 This is a flowchart illustrating the third embodiment of the switch MAC address and VLAN management method of this application. Step S20 specifically includes:

[0113] Step S201: Obtain the current time, device type, and traffic type from the data packet.

[0114] It should be noted that when the system receives a data packet, it will first parse the header information of the data packet to extract the current time (obtained from the system clock), device type (identified by MAC address prefix, manufacturer identifier or predefined device type field), and traffic type (such as TCP, UDP, HTTPS and other protocol types).

[0115] Additionally, it should be noted that the current time refers to the system time when the switch received the data packet, used to match the effective time in the ACL rules. Device type refers to the type of device from which the data packet originated, such as a server, PC, or IP camera, identified by its MAC address or other identifiers. Traffic type refers to the communication protocol type used by the data packet, such as TCP, UDP, or HTTPS, used to match the traffic type in the ACL rules.

[0116] Step S202: Parse the access control list rules to obtain matching elements, which include source MAC address range, priority identifier, effective time, device type range, and traffic type range.

[0117] It's important to note that in this step, the system parses the matching elements of each rule from the stored ACL rules, including the source MAC address range, priority identifier, effective time, device type range, and traffic type range. The priority identifier indicates the execution priority of the ACL rule; the smaller the value, the higher the priority. The device type range refers to the device type or device type range specified in the ACL rule, used to match the device type in the data packet. The traffic type range refers to the traffic type range specified in the ACL rule, used to match the traffic type in the data packet.

[0118] Step S203: Sort the access control list rules based on the priority identifier to generate a priority sorting queue.

[0119] It's important to note that in this step, the system sorts all rules according to their priority identifiers in the ACL, generating a priority sorting queue. Higher-priority rules are placed at the front of the queue, ensuring they are applied first during matching. Understandably, by sorting, the switch ensures that the highest-priority rule is applied first when processing data packets, thereby meeting the processing needs of critical traffic and devices.

[0120] Step S204: Match the source MAC address, the current time, the device type, and the traffic type according to the priority sorting queue and the matching elements to obtain the matching result.

[0121] It should be noted that in this step, the system sorts the queue according to priority and matches the matching elements of each ACL rule (source MAC address range, effective time, device type range, traffic type range) with the source MAC address, current time, device type, and traffic type in the data packet. If a match is successful, a matching result is generated based on the matched ACL rule, including whether passage is allowed and the assigned target VLAN identifier (i.e., VLAN ID).

[0122] In one feasible implementation, step S204 specifically includes:

[0123] Step B10: Traverse each rule in descending order of the priority sorting queue and perform a matching judgment on the traversed rules.

[0124] It should be noted that in this step, after obtaining the priority sorting queue, the system will traverse each ACL rule in descending order (i.e., from highest to lowest priority). For each rule, the switch will perform a series of matching checks to determine whether the current data packet meets the matching conditions of that rule.

[0125] Step B20: When any one of the following conditions is met: the source MAC address belongs to the source MAC address range of the rule, the current time is within the effective time of the rule, the device type of the data packet matches the device type range of the rule, and the traffic type matches the traffic type range of the rule, the matching result is determined to be a successful match, and the traversal is terminated.

[0126] It's important to note that when iterating through each ACL rule, the system checks whether the source MAC address of the current data packet falls within the rule's source MAC address range, whether the current time is within the rule's effective period, whether the packet's device type matches the rule's device type range, and whether the traffic type matches the rule's traffic type range. If any one of these four conditions is met, the system determines that the current data packet matches the rule successfully and immediately terminates the iteration process. For example, suppose the switch is iterating through a high-priority ACL rule that requires the source MAC address to be within a specific range and the effective time to be a weekday. When the switch receives a data packet from that MAC address range, and the current time is a weekday, the switch determines that the match is successful and terminates the iteration.

[0127] Step B30: If none of the following conditions are met—that the source MAC address belongs to the source MAC address range of the rule, that the current time is within the effective time of the rule, that the device type of the data packet matches the device type range of the rule, and that the traffic type matches the traffic type range of the rule—and no rule meets the matching conditions after traversal, the matching result is determined to be a matching failure.

[0128] It's important to note that if, after iterating through all ACL rules, the switch finds that none of the matching conditions are met (i.e., the source MAC address does not belong to the source MAC address range of any rule, the current time is not within the effective time of any rule, the device type of the packet does not match the device type range of any rule, and the traffic type does not match the traffic type range of any rule), then the switch determines the matching result as a failure. For example, suppose the switch has three ACL rules, but the switch receives a packet whose source MAC address, current time, device type, and traffic type do not meet the matching conditions of any rule. After iterating through all rules, the switch determines the matching result as a failure.

[0129] In this embodiment, the switch can automatically obtain data packet information and parse access control list rules, and match and judge them sequentially according to priority order queues. This realizes the dynamic allocation of MAC addresses and VLAN binding based on traffic characteristics, which solves the problems of complex, inflexible and insecure traditional static configuration management, and improves the manageability, flexibility and security of the network.

[0130] This application also provides a switch MAC address and VLAN management device; please refer to... Figure 4 The switch MAC address and VLAN management device includes:

[0131] Data extraction module 10 is used to obtain access control list rules and source MAC addresses in data packets;

[0132] Rule matching module 20 is used to perform rule matching on the source MAC address based on the access control list rules to generate matching results;

[0133] VLAN allocation module 30 is used to determine the target VLAN identifier of the data packet based on the matching result;

[0134] Access control module 40 is used to perform VLAN access control based on the target VLAN identifier.

[0135] The switch MAC address and VLAN management device provided in this application, employing the switch MAC address and VLAN management method described in the above embodiments, can solve the technical problem of how to efficiently, flexibly, and securely manage the binding relationship between switch MAC addresses and VLANs. Compared with the prior art, the beneficial effects of the switch MAC address and VLAN management device provided in this application are the same as those of the switch MAC address and VLAN management method provided in the above embodiments, and other technical features in the switch MAC address and VLAN management device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0136] In one embodiment, the data extraction module 10 is further configured to obtain rule priority, device type matching condition, traffic type matching condition, and time type matching condition; and to obtain access control list rules based on the rule priority, device type matching condition, traffic type matching condition, and time type matching condition.

[0137] In one embodiment, the data extraction module 10 is further configured to sort the device type matching conditions, traffic type matching conditions, and time type matching conditions according to the rule priority, and generate a sorted priority rule set; obtain device type matching logic according to the device type matching conditions; obtain filtering parameters according to the traffic type matching conditions, the filtering parameters including protocol type and bandwidth threshold; obtain the effective time corresponding to different rules according to the time type matching conditions; and generate access control list rules based on the priority rule set, the device type matching logic, the filtering parameters, and the effective time.

[0138] In one embodiment, the rule matching module 20 is further configured to obtain the current time, device type, and traffic type in the data packet; parse the access control list rules to obtain matching elements, the matching elements including source MAC address range, priority identifier, effective time, device type range, and traffic type range; sort the access control list rules based on the priority identifier to generate a priority sorting queue; and match the source MAC address, the current time, the device type, and the traffic type according to the priority sorting queue and the matching elements to obtain a matching result.

[0139] In one embodiment, the rule matching module 20 is further configured to traverse each rule sequentially according to the descending order of the priority sorting queue, and perform matching judgment on the traversed rules; when any one of the following conditions is met—that the source MAC address belongs to the source MAC address range of the rule, that the current time is within the effective time of the rule, that the device type of the data packet matches the device type range of the rule, and that the traffic type matches the traffic type range of the rule—the matching result is determined to be a successful match, and the traversal is terminated; when none of the following conditions are met—that the source MAC address belongs to the source MAC address range of the rule, that the current time is within the effective time of the rule, that the device type of the data packet matches the device type range of the rule, and that the traffic type matches the traffic type range of the rule—and no rule meets the matching conditions after traversal, the matching result is determined to be a failed match.

[0140] In one embodiment, the VLAN allocation module 30 is further configured to, when the matching result is a successful match, obtain the target rule that has been successfully matched, and extract the VLAN identifier bound in the target rule as the target VLAN identifier; when the matching result is a failed match, obtain a preset default VLAN identifier or an upper-layer configuration policy, and determine the target VLAN identifier according to the default VLAN identifier or the upper-layer configuration policy.

[0141] In one embodiment, the access control module 40 is further configured to obtain the target MAC address in the data packet; when the target MAC address matches the target VLAN identifier, forward the data packet to the target VLAN according to the target VLAN identifier; when the target MAC address does not match the target VLAN identifier, prohibit the transmission of the data packet and generate a security alarm log.

[0142] This application provides a switch MAC address and VLAN management device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the switch MAC address and VLAN management method in the above embodiment 1.

[0143] The following is for reference. Figure 5 This document illustrates a structural diagram suitable for implementing a switch MAC address and VLAN management device in the embodiments of this application. The switch MAC address and VLAN management device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The switch MAC address and VLAN management device shown are merely examples and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0144] like Figure 5As shown, the switch MAC address and VLAN management device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to programs stored in ROM (Read Only Memory) 1002 or programs loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the switch MAC address and VLAN management device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the switch MAC address and VLAN management device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows switch MAC address and VLAN management devices with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented alternatively.

[0145] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0146] The switch MAC address and VLAN management device provided in this application, employing the switch MAC address and VLAN management method described in the above embodiments, can solve the technical problem of how to efficiently, flexibly, and securely manage the binding relationship between switch MAC addresses and VLANs. Compared with the prior art, the beneficial effects of the switch MAC address and VLAN management device provided in this application are the same as those of the switch MAC address and VLAN management method provided in the above embodiments, and other technical features of this switch MAC address and VLAN management device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0147] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0148] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0149] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the switch MAC address and VLAN management method in the above embodiments.

[0150] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0151] The aforementioned computer-readable storage medium may be included in the switch's MAC address and VLAN management device; or it may exist independently and not be assembled into the switch's MAC address and VLAN management device.

[0152] The aforementioned computer-readable storage medium carries one or more programs that, when executed by the switch MAC address and VLAN management device, cause the switch MAC address and VLAN management device to: obtain access control list rules and the source MAC address in the data packet; perform rule matching on the source MAC address based on the access control list rules to generate a matching result; determine the target VLAN identifier of the data packet based on the matching result; and perform VLAN access control based on the target VLAN identifier.

[0153] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0154] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0155] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0156] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described switch MAC address and VLAN management method. This solves the technical problem of how to efficiently, flexibly, and securely manage the binding relationship between a switch's MAC address and VLANs. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the switch MAC address and VLAN management method provided in the above embodiments, and will not be repeated here.

[0157] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the switch MAC address and VLAN management method described above.

[0158] The computer program product provided in this application can solve the technical problem of how to efficiently, flexibly and securely manage the binding relationship between MAC addresses and VLANs of a switch. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the switch MAC address and VLAN management method provided in the above embodiments, and will not be repeated here.

[0159] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. A method for managing MAC addresses and VLANs of a switch, characterized in that, The method includes: Retrieve access control list rules and source MAC addresses from data packets; Based on the access control list rules, the source MAC address is matched to generate a matching result; The target VLAN identifier of the data packet is determined based on the matching result; Perform VLAN access control based on the target VLAN identifier; The step of generating a matching result by performing rule matching on the source MAC address based on the access control list rules includes: Obtain the current time, device type, and traffic type from the data packet; The access control list rules are parsed to obtain matching elements, which include source MAC address range, priority identifier, effective time, device type range, and traffic type range. The access control list rules are sorted based on the priority identifier to generate a priority sorting queue; The matching results are obtained by matching the source MAC address, the current time, the device type, and the traffic type according to the priority sorting queue and the matching elements. The matching results include whether the operation is successful and the assigned target VLAN identifier. The step of matching the source MAC address, the current time, the device type, and the traffic type according to the priority sorting queue and the matching elements to obtain the matching result includes: Each rule is traversed sequentially in descending order of the priority sorting queue, and a matching judgment is performed on the traversed rules. If any one of the following conditions is met: the source MAC address belongs to the source MAC address range of the rule, the current time is within the effective time of the rule, the device type of the data packet matches the device type range of the rule, or the traffic type matches the traffic type range of the rule, the matching result is determined to be a successful match, and the traversal is terminated. If none of the following conditions are met: the source MAC address belongs to the source MAC address range of the rule, the current time is within the effective time of the rule, the device type of the data packet matches the device type range of the rule, and the traffic type matches the traffic type range of the rule, and no rule meets the matching conditions after traversal, the matching result is determined to be a matching failure.

2. The method as described in claim 1, characterized in that, The steps to obtain access control list rules include: Obtain rule priority, device type matching conditions, traffic type matching conditions, and time type matching conditions; Access control list rules are obtained based on the rule priority, the device type matching condition, the traffic type matching condition, and the time type matching condition.

3. The method as described in claim 2, characterized in that, The step of obtaining access control list rules based on the rule priority, the device type matching condition, the traffic type matching condition, and the time type matching condition includes: The device type matching conditions, traffic type matching conditions, and time type matching conditions are sorted according to the rule priority to generate a sorted priority rule set. The device type matching logic is obtained based on the device type matching conditions. The filtering parameters are obtained based on the traffic type matching conditions, and the filtering parameters include protocol type and bandwidth threshold. The effective time corresponding to different rules is obtained based on the time type matching conditions; Access control list rules are generated based on the priority rule set, the device type matching logic, the filtering parameters, and the effective time.

4. The method as described in claim 1, characterized in that, The step of determining the target VLAN identifier of the data packet based on the matching result includes: When the matching result is a successful match, the target rule that is successfully matched is obtained, and the VLAN identifier bound in the target rule is extracted as the target VLAN identifier; When the matching result is a failure, a preset default VLAN identifier or upper-layer configuration policy is obtained, and the target VLAN identifier is determined according to the default VLAN identifier or upper-layer configuration policy.

5. The method according to any one of claims 1 to 4, characterized in that, The step of performing VLAN access control based on the target VLAN identifier includes: Obtain the target MAC address from the data packet; When the target MAC address matches the target VLAN identifier, the data packet is forwarded to the target VLAN according to the target VLAN identifier; When the target MAC address does not match the target VLAN identifier, the transmission of the data packet is prohibited and a security alarm log is generated.

6. A switch MAC address and VLAN management device, characterized in that, The device includes: The data extraction module is used to obtain the source MAC address from access control list rules and data packets; The rule matching module is used to perform rule matching on the source MAC address based on the access control list rules to generate matching results; The VLAN allocation module is used to determine the target VLAN identifier of the data packet based on the matching result; The access control module is used to perform VLAN access control based on the target VLAN identifier; The rule matching module is further configured to obtain the current time, device type, and traffic type from the data packet; parse the access control list rules to obtain matching elements, the matching elements including source MAC address range, priority identifier, effective time, device type range, and traffic type range; sort the access control list rules based on the priority identifier to generate a priority sorting queue; and match the source MAC address, current time, device type, and traffic type according to the priority sorting queue and the matching elements to obtain a matching result, the matching result including whether the operation was successful and the assigned target VLAN identifier; The rule matching module is further configured to traverse each rule sequentially according to the descending order of the priority sorting queue, and perform matching judgment on the traversed rules; when any one of the following conditions is met—that the source MAC address belongs to the source MAC address range of the rule, that the current time is within the effective time of the rule, that the device type of the data packet matches the device type range of the rule, and that the traffic type matches the traffic type range of the rule—the matching result is determined to be a successful match, and the traversal is terminated; when none of the following conditions are met—that the source MAC address belongs to the source MAC address range of the rule, that the current time is within the effective time of the rule, that the device type of the data packet matches the device type range of the rule, and that the traffic type matches the traffic type range of the rule—and no rule meets the matching conditions after traversal, the matching result is determined to be a failed match.

7. A switch MAC address and VLAN management device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the switch MAC address and VLAN management method as described in any one of claims 1 to 5.

8. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the switch MAC address and VLAN management method as described in any one of claims 1 to 5.