Data protection method and device based on firewall, equipment and storage medium
By obtaining the access frequency of access data packets in the communication device and generating current limiting rules, and delegating them to the data link layer for processing, it solves the problems of CPU consumption and business paralysis of traditional firewall devices in the face of frequent access attacks, and achieves efficient Current limiting and operation and maintenance efficiency are improved.
Patent Information
- Application Number
- CN202410880075.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-15
AI Technical Summary
When firewall equipment in traditional communication equipment faces frequent external access attacks, normal access will be abnormally slow or equipment will be abnormal. In addition, current limiting processing consumes a large amount of CPU resources in the data link layer copy, causing business paralysis.
By obtaining the access frequency of access data packets, current-limiting firewall rules are generated and transferred to the data link layer, where they are processed directly in the network card driver to avoid copying data packets to the network layer and implement restrictions on high-frequency access.
It improves equipment processing capabilities, reduces current limiting overhead, improves operation and maintenance efficiency, ensures that normal user services are not affected, and solves the problem of traditional equipment needing to shut down the server.
Smart Images

Figure CN118784302A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud security technology, and in particular to a firewall-based data protection method, device, equipment and storage medium. Background Art
[0002] The Linux processor firewall devices in traditional communication equipment are all aimed at whether a certain service is open to the outside world, such as whether to open web access, Telnet access, SSH access, etc. The restriction of various external services is realized at the mount point through the packet filter of Netfilter. Of course, some services are not completely prohibited from access, but the access traffic is restricted, such as limiting the number of ping packets, etc. This is also limited by IP tab es rules. Therefore, the existing technology often needs to be open to users for access, but it cannot avoid frequent external access attacks, resulting in abnormal slowness or even abnormality of normal access, and even abnormality of equipment. In addition, for limiting traffic with the three-layer network rules of the system, because the device receives packets from the hardware network card at the data link layer and forwards them to the network layer protocol stack, and then restricts traffic in the protocol stack Netfilter framework, the data packet has been copied at multiple layers. When the traffic is large, a large amount of CPU will be consumed, resulting in abnormal normal access and even no idle CPU to process normal access. Normal business is paralyzed.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a firewall-based data protection method, device, equipment and storage medium, which can improve the server operation and maintenance efficiency and reduce the server operation and maintenance expenses, while realizing the interception of abnormal access to data packets.
[0005] To achieve the above purpose, one aspect of an embodiment of the present application proposes a data protection method based on a firewall, the method comprising:
[0006] Obtaining an access data packet and setting an access frequency of the access data packet;
[0007] Generate a current limiting rule according to the access frequency of the access data packet to obtain a current limiting firewall rule;
[0008] The current limiting firewall rules are decentralized to the data link layer to limit the access of the access data packet through the data link layer.
[0009] In some embodiments, obtaining the access data packet and setting the access frequency of the access data packet includes:
[0010] Obtaining an access data packet and determining a source IP address of the access data packet;
[0011] According to the source IP address of the access data packet, a preset access number authority within a preset time period is granted to generate the access frequency of the access data packet.
[0012] In some embodiments, the current limiting firewall rule includes a first discard rule and a second discard rule, wherein:
[0013] The first discarding rule is that if the number of accesses within the preset time period exceeds the preset number of accesses, the access data packet is discarded;
[0014] The second discarding rule is that if the number of accesses within the preset time period exceeds the preset number of accesses, access data packets corresponding to the number of accesses exceeding the preset number of accesses will be discarded.
[0015] In some embodiments, the decentralizing the current limiting firewall rule to the data link layer to limit the access of the access data packet through the data link layer includes:
[0016] Decentralize the current limiting firewall rules to the data link layer;
[0017] Establishing a data sharing module based on the upper layer service of the data link layer and the network card driver of the data link layer, and storing the current limiting firewall rules;
[0018] Calling the current limiting firewall rule to monitor the access data packet;
[0019] If the access frequency of the access data packet meets the current limiting firewall rule, then the access data packet is allowed to access the access data packet;
[0020] If the access frequency of the access data packet does not satisfy the current limiting firewall rule, the access data packet is discarded.
[0021] In some embodiments, it also includes:
[0022] Set the discard reset time;
[0023] If the discarded time of the discarded access data packet reaches the discard reset time, performing a second monitoring on the access frequency of the access data packet;
[0024] If the access frequency of the access data packet does not satisfy the current limiting firewall rule, the access data packet is discarded for a second time;
[0025] If the access frequency of the access data packet meets the current limiting firewall rule, the access data packet is allowed to have access rights.
[0026] In some embodiments, it also includes:
[0027] storing the discarded access data packet in the data sharing module;
[0028] Obtain access information of the discarded access data packet, wherein the access information includes access time, source IP address, source MAC address, destination IP address, destination MAC address and access service;
[0029] Visually display and query the access information, and output the query results.
[0030] In some embodiments, it also includes:
[0031] Perform classification processing according to the operation and maintenance query results;
[0032] If the operation and maintenance query result shows that the number of discarded access data packets reaches the discarded number threshold, the access data packets are marked, and the marked access data packets have no access rights;
[0033] If the operation and maintenance query result shows that the number of discarded times of the access data packet does not meet the discarded times threshold, the access data packet is allowed access rights.
[0034] To achieve the above-mentioned purpose, another aspect of the embodiment of the present application provides a data protection device based on a firewall, the device comprising:
[0035] The first module is used to obtain an access data packet and set an access frequency of the access data packet;
[0036] The second module is used to generate a current limiting rule according to the access frequency of the access data packet to obtain a current limiting firewall rule;
[0037] The third module is used to delegate the current limiting firewall rules to the data link layer to limit the access of the access data packet through the data link layer.
[0038] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.
[0039] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0040] The embodiments of the present application include at least the following beneficial effects: The present application provides a data protection method, apparatus, device and storage medium based on a firewall. The scheme obtains access data packets and sets the access frequency of the access data packets, generates current limiting rules according to the access frequency of the access data packets, and restricts high-frequency users in a targeted manner to ensure that the services of normal users are not affected when attacked, thereby solving the traditional problem of shutting down the server, and further delegating the current limiting firewall rules to the data link layer to limit the access of the access data packets through the data link layer. By lowering the current limiting processing to the network card driver packet receiving entry processing, the processing capability of the device is enhanced, the current limiting overhead is reduced, and the operation and maintenance efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flow chart of a data protection method based on a firewall provided in an embodiment of the present application;
[0042] Figure 2 It is a schematic diagram of the process framework of data protection provided by the embodiment of the present application;
[0043] Figure 3 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of systems and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0045] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0046] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0047] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0048] Reference Figure 1 , Figure 1 A flowchart of a data protection method based on a firewall provided in an embodiment of the present invention, referring to Figure 1 , the method comprises the following steps:
[0049] S100, obtaining an access data packet and setting an access frequency of the access data packet;
[0050] It should be noted that, in some embodiments, step S100 may include: S110, obtaining an access data packet and determining the source IP address of the access data packet; S120, granting a preset number of access permissions within a preset time period based on the source IP address of the access data packet, and generating an access frequency of the access data packet.
[0051] In some specific embodiments, for each service, if the user needs to be able to access it, it is not simply turned on directly, but the source IP accessing the service is monitored, and access frequency configuration is provided for the service. Each source IP access is only allowed to access a certain frequency, and those exceeding this frequency will be discarded or limited.
[0052] The following are some examples:
[0053] For telnet service;
[0054] Set the service name: telnet;
[0055] Set the access frequency: 1 access per second (i.e., each source IP can initiate a SYN connection once per second). S200, generate a current limiting rule based on the access frequency of the access data packet to obtain a current limiting firewall rule;
[0056] It should be noted that, in some embodiments, the current limiting firewall rules include a first discard rule and a second discard rule; the first discard rule is that if the number of accesses within a preset time period exceeds a preset access number, the access data packet will be discarded, and the second discard rule is that if the number of accesses within a preset time period exceeds a preset access number, the access data packets corresponding to the preset access number will be discarded.
[0057] The following are some examples:
[0058] Set overclocking action;
[0059] Set the first discard rule: Directly discard, that is, after exceeding the frequency, subsequent access to the IP address will be directly discarded;
[0060] Set the second discard rule: limit the access frequency, that is, discard only when it exceeds the configured frequency. For example, if there is one access per second, the user will only be allowed to access telnet once per second (initiate a syn connection to telnet). The part exceeding this within one second will be directly discarded, and access will be allowed once in the next second.
[0061] S300, decentralizing the current limiting firewall rules to the data link layer to limit access to the data packet through the data link layer;
[0062] It should be noted that if Figure 2 As shown, in some embodiments, step S300 may include: S310, decentralizing the current limiting firewall rules to the data link layer; S320, establishing a data sharing module based on the upper layer service of the data link layer and the network card driver of the data link layer, and storing the current limiting firewall rules; S330, calling the current limiting firewall rules to monitor the access data packets; S340, if the access frequency of the access data packets meets the current limiting firewall rules, opening access rights to the access data packets; S350, if the access frequency of the access data packets does not meet the current limiting firewall rules, discarding the access data packets.
[0063] In some specific embodiments, in view of the fact that the original current limiting is relatively CPU-consuming under the three-layer network framework, we put the current limiting action directly into the device's network card driver for processing, which is equivalent to delegating it to the data link layer for processing without sending it to the network layer. By directly establishing a data sharing module between the upper-layer service and the network card driver to store the current limiting configuration and rules, the network card driver applies for space to make a data sharing module, the upper-layer application is associated with the data sharing module through mmap call, the upper-layer service updates the current limiting rules to the data sharing module, the network card driver obtains the rules from the data sharing module, and matches the rules when the network card receives the packet according to the rules. If it matches the discard rule, it will be discarded directly. This reduces the copying and transmission overhead required to transmit network traffic data packets to the upper layer, and significantly improves efficiency.
[0064] Furthermore, it should be noted that it also includes setting a discard reset time, which is specifically, setting a discard reset time; if the discard time of the access data packet after being discarded reaches the discard reset time, the access frequency of the access data packet is monitored twice; if the access frequency of the access data packet does not meet the current limiting firewall rules, the access data packet is discarded twice; if the access frequency of the access data packet meets the current limiting firewall rules, the access data packet is opened to allow access rights.
[0065] In this embodiment, the discarding time is set. For example, when the overclocking action is discarding, the discarding time can be configured as permanent and a specific time such as 5 minutes. For example, if 5 minutes is configured, the IP access is allowed again after 5 minutes, but if it exceeds the limit again, access will be restricted for another 5 minutes.
[0066] Furthermore, it should be noted that it also includes visual display and operation and maintenance query of access data packets, which is specifically, storing the discarded access data packets in the data sharing module; obtaining access information of the discarded access data packets, the access information including access time, source IP address, source MAC address, destination IP address of the access, destination MAC address of the access and accessed service; visual display and operation and maintenance query of the access information, and outputting the operation and maintenance query results.
[0067] In this embodiment, a space in the data sharing module is used to store discarded information, including time, source IP, source MAC, destination IP visited, destination MAC, and visited services. For discarded illegal access flows, the upper-layer application obtains discarded information from the data sharing module, and displays the source IP and MAC of illegal access, the size of discarded traffic, and the discarded time period, etc., to facilitate operation and maintenance inquiries. For example, if the operation and maintenance finds that a certain IP often illegally accesses multiple services, and the accessed services are all over the limit, the IP or MAC can be directly banned at the entrance of the computer room to protect the safety of other equipment in the computer room. This improves the security of computer room operation and maintenance.
[0068] Furthermore, it should be noted that it also includes classifying the operation and maintenance query results, which is specifically classifying according to the operation and maintenance query results; if the operation and maintenance query results show that the number of discarded access data packets reaches the discarded number threshold, the access data packets will be marked, and the marked access data packets will have no access rights; if the operation and maintenance query results show that the number of discarded access data packets does not meet the discarded number threshold, the access data packets will be opened to allow access rights.
[0069] In this embodiment, a blacklist is established, and the blacklist does not allow a certain IP or MAC to access all services of the device; in addition, a whitelist can be established. For the IP or MAC that has been confirmed to be blocked by mistake for normal access, it can be placed in the whitelist, so that it can be unimpeded and not blocked by the firewall rules.
[0070] The embodiment of the present application further provides a data protection device based on a firewall, which can implement the above-mentioned data protection method based on a firewall, and the device includes:
[0071] The first module is used to obtain access data packets and set the access frequency of the access data packets;
[0072] The second module is used to generate a current limiting rule according to the access frequency of the access data packet to obtain a current limiting firewall rule;
[0073] The third module is used to delegate the current limiting firewall rules to the data link layer to restrict the access to data packets through the data link layer.
[0074] It can be understood that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0075] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the data protection method of the firewall when executing the computer program. The electronic device can be any smart terminal including a tablet computer, a car computer, etc.
[0076] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0077] See also Figure 3 , Figure 3 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0078] The processor 301 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0079] The memory 302 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 302 can store an operating system and other applications. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 302, and the processor 301 calls and executes the data protection method of the firewall of the embodiment of this application;
[0080] Input / output interface 303, used to implement information input and output;
[0081] The communication interface 304 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0082] A bus 305 that transmits information between the various components of the device (e.g., the processor 301, the memory 302, the input / output interface 303, and the communication interface 304);
[0083] The processor 301 , the memory 302 , the input / output interface 303 and the communication interface 304 are connected to each other in communication within the device via the bus 305 .
[0084] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the data protection method of the above-mentioned firewall is implemented.
[0085] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0086] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0087] The embodiments of the present application provide a data protection method based on a firewall, a data protection device based on a firewall, an electronic device and a storage medium, which obtain access data packets and set the access frequency of the access data packets; generate current limiting rules according to the access frequency of the access data packets to obtain current limiting firewall rules; and delegate the current limiting firewall rules to the data link layer to limit the access of the access data packets through the data link layer. The embodiments of the present application can improve the operation and maintenance efficiency of the server and reduce the operation and maintenance expenses of the server, while realizing the interception of abnormal access to data packets.
[0088] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0089] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0090] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0091] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0092] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A data protection method based on a firewall, It is characterized in that The method comprises the following steps: Obtaining an access data packet and setting an access frequency of the access data packet; Generate a current limiting rule according to the access frequency of the access data packet to obtain a current limiting firewall rule; The current limiting firewall rules are decentralized to the data link layer to limit the access of the access data packet through the data link layer.
2. The method according to claim 1, It is characterized in that The obtaining of the access data packet and setting the access frequency of the access data packet includes: Obtaining an access data packet and determining a source IP address of the access data packet; According to the source IP address of the access data packet, a preset access number authority within a preset time period is granted to generate the access frequency of the access data packet.
3. The method according to claim 1, It is characterized in that The current limiting firewall rule includes a first discard rule and a second discard rule, wherein: The first discarding rule is that if the number of accesses within the preset time period exceeds the preset number of accesses, the access data packet is discarded; The second discarding rule is that if the number of accesses within the preset time period exceeds the preset number of accesses, access data packets corresponding to the number of accesses exceeding the preset number of accesses will be discarded.
4. The method according to claim 1, It is characterized in that The step of delegating the current limiting firewall rule to the data link layer to limit access to the access data packet through the data link layer includes: Decentralize the current limiting firewall rules to the data link layer; Establishing a data sharing module based on the upper layer service of the data link layer and the network card driver of the data link layer, and storing the current limiting firewall rules; Calling the current limiting firewall rule to monitor the access data packet; If the access frequency of the access data packet meets the current limiting firewall rule, then the access data packet is allowed to access the access data packet; If the access frequency of the access data packet does not satisfy the current limiting firewall rule, the access data packet is discarded.
5. The method according to claim 4, It is characterized in that Also includes: Set the discard reset time; If the discarded time of the discarded access data packet reaches the discard reset time, performing a second monitoring on the access frequency of the access data packet; If the access frequency of the access data packet does not satisfy the current limiting firewall rule, the access data packet is discarded for a second time; If the access frequency of the access data packet meets the current limiting firewall rule, the access data packet is allowed to have access rights.
6. The method according to claim 4, It is characterized in that Also includes: storing the discarded access data packet in the data sharing module; Obtain access information of the discarded access data packet, wherein the access information includes access time, source IP address, source MAC address, destination IP address, destination MAC address and access service; Visually display and query the access information, and output the query results.
7. The method according to claim 4, It is characterized in that Also includes: Perform classification processing according to the operation and maintenance query results; If the operation and maintenance query result shows that the number of discarded access data packets reaches the discarded number threshold, the access data packets are marked, and the marked access data packets have no access rights; If the operation and maintenance query result shows that the number of discarded times of the access data packet does not meet the discarded times threshold, the access data packet is allowed access rights.
8. A data protection device based on a firewall, It is characterized in that The device comprises: The first module is used to obtain an access data packet and set an access frequency of the access data packet; The second module is used to generate a current limiting rule according to the access frequency of the access data packet to obtain a current limiting firewall rule; The third module is used to delegate the current limiting firewall rules to the data link layer to limit the access of the access data packet through the data link layer.
9. An electronic device, It is characterized in that include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
