A method, system, device, and medium for automatically generating IPsec security policies.
By applying the DBSCAN algorithm and multicast probes to IPsec gateway devices, IPsec security policies are automatically generated, solving the problem of low efficiency in traditional manual configuration and achieving automatic adaptation and service continuity in dynamic network environments.
Patent Information
- Application Number
- CN202611618963.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-20
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional IPsec gateway devices rely heavily on manual configuration of security policies, resulting in low configuration efficiency, poor timeliness, inability to adapt to dynamic network scenarios, and easy occurrence of missing or incorrect configurations leading to service interruptions.
The algorithm employs a density-based clustering algorithm (DBSCAN) combined with a multicast probe mechanism to automatically identify the local protected subnet and negotiate with the peer IPsec gateway device. It automatically generates IPsec security policies and dynamically adapts to network changes by periodically sending multicast probe packets and clustering source IP addresses in network traffic.
It enables automated construction of security policies, improves configuration efficiency and network adaptability, reduces manual intervention, and lowers the risk of business interruption. In particular, it improves network segment identification capabilities and business continuity in sparse traffic and small sample scenarios.
Smart Images

Figure CN123123034A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network communication and information security technology, specifically to a method, system, device, and medium for automatically generating IPsec security policies. Background Technology
[0002] IPsec (Internet Protocol Security) gateway devices are primarily used to protect network data transmission from eavesdropping and tampering. They encrypt and process network data through configured security policies. Typically, a security policy consists of two core components: the protection subnets of the IPsec gateway devices on both sides of the communication, and the IP address of the peer IPsec gateway device. Specifically, when an IPsec gateway device receives an IP packet, it extracts the address information and matches it with the protection subnet in the security policy. When the policy requires encryption, it also relies on the IP address of the peer gateway to initiate negotiation and establish a Security Association (SA).
[0003] Traditional IPsec gateway devices heavily rely on network administrators to manually configure security policies. Users need to extract configuration information based on complex network topologies and interconnection requirements, and then log in to each IPsec gateway device to issue commands. Due to the complexity of the security policy's logic, this manual operation mode has significant drawbacks: First, configuration efficiency is low; when the network is large, the workload increases exponentially. Second, it lacks automatic adaptation capabilities; once the enterprise network topology changes dynamically (such as adding network segments or migrating nodes), network administrators must check and manually modify all IPsec gateway devices that have interconnection relationships with the changed nodes. This mode has extremely poor timeliness and is prone to service interruptions due to missed or incorrect configurations, making it unsuitable for today's highly dynamic network scenarios. Summary of the Invention
[0004] The purpose of this invention is to address the problems of traditional IPsec gateway devices relying heavily on manual configuration of security policies, resulting in low configuration efficiency, poor timeliness, large workload, and inability to automatically adapt to dynamically changing network scenarios. This invention provides a method, system, device, and medium for automatically generating IPsec security policies. Based on multicast, it automatically detects the IP address of the peer IPsec gateway device and uses a density-based clustering algorithm (DBSCAN) to intelligently extract the local protected subnet. By combining these two methods, it automatically generates IPsec security policies, achieving IPsec networking and interoperability without manual intervention and dynamic adaptation to network topology changes.
[0005] The technical solution of the present invention is as follows: A method for automatically generating IPsec security policies, applied to a local IPsec gateway device, includes: Periodically send multicast probe messages and receive multicast probe messages sent by other IPsec gateway devices, and parse the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device; Based on the IP address information, an IKE SA is established through negotiation with the corresponding peer IPsec gateway device. The system continuously receives IP packets from the intranet, obtains the source IP address corresponding to the IP packet, and inputs it as a sample into the density-based clustering algorithm DBSCAN module for clustering processing. If the number of source IP address samples input to the DBSCAN module meets a preset clustering threshold, the local protection subnet is obtained through the clustering process. If the number of samples does not meet the preset clustering threshold, the source IP address is directly used as the local protection subnet, wherein the local protection subnet is in the form of a single IP address. The IKE SA informs the peer IPsec gateway device of the local protection subnet and obtains the peer protection subnet fed back by the peer IPsec gateway device. Based on the local protection subnet and the peer protection subnet, an IPsec security policy is automatically generated.
[0006] Further, the source IP address corresponding to the IP packet is obtained and used as a sample input to the density-based clustering algorithm DBSCAN module for clustering processing, including: The IP packets are cleaned to remove invalid packets and retain valid IP packets. The source IP addresses of the valid IP packets are extracted to construct the IP dataset to be analyzed. The IP address quantization conversion method is adopted to take the source IP address in the IP dataset to be analyzed as a four-segment IP address, and convert the four-segment IP address into a decimal long integer value to construct a one-dimensional IP feature vector composed of the decimal long integer value. The one-dimensional IP feature vector is input into the DBSCAN module for clustering calculation. The four segments of the four-segment IP address, from left to right, are denoted as follows: , , and The four-segment IP address is converted into a decimal long integer value. The conversion formula is: .
[0007] Furthermore, before inputting the one-dimensional IP feature vector into the DBSCAN module for clustering calculation, the following steps are also included: The core parameters of the DBSCAN module are optimized and configured, including the neighborhood radius Eps and the minimum number of samples MinPts. The neighborhood radius Eps is set according to the IP value interval of the standard network segment so that the source IP addresses within the same continuous network segment are divided into the same neighborhood. Set the minimum number of samples, MinPts, to a sparse sample adaptation threshold that matches the current network traffic data volume.
[0008] Further, the one-dimensional IP feature vector is input into the DBSCAN module for clustering calculation, including: Based on the neighborhood radius Eps and the minimum number of samples MinPts, the one-dimensional IP feature vector is traversed, and each of the decimal long integer values in the one-dimensional IP feature vector is taken as a data point to identify the core points that meet the density requirements. Starting from the unvisited core point, recursively traverse all density-reachable data points to form independent IP clusters, each of which corresponds to a continuous network segment. For data points that do not meet the density reachability condition and have no associated core points, they are treated as isolated data points and marked as noise data.
[0009] Furthermore, the local protection subnet is obtained through the clustering process, including: The IP clusters are processed in reverse to extract the maximum and minimum values of the decimal long integer values contained in each IP cluster. Convert the maximum and minimum values back to dotted decimal IP address ranges; The optimal subnet mask is calculated based on the continuity of IP addresses within the IP address range, and the IP clusters are converted into a standard network segment format. Filter the noise data and output all the standard network segment formats as the local protection subnet.
[0010] Furthermore, it also includes the gradual revision and improvement process of security strategies: When the local IPsec gateway device receives the first IP packet, since the number of samples of the source IP address does not meet the preset clustering threshold, the source IP address of the IP packet is extracted and directly used as the local protection subnet in the form of a single IP address, and an initial IPsec security policy is generated to ensure service communication. After continuous network traffic input and the number of samples of the source IP address meets the preset clustering threshold, the local protection subnet is generated through the DBSCAN module, and the updated peer protection subnet is obtained to regenerate and correct the final IPsec security policy.
[0011] Furthermore, it periodically sends multicast probe messages and receives multicast probe messages sent by other IPsec gateway devices, and parses the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device, including: Periodically construct and send multicast probe packets with a destination IP address of a specific multicast address, and simultaneously listen to the specific multicast address; When a multicast probe packet is received from another IPsec gateway device, the IP address of the multicast initiator device and the identity information in the multicast probe packet are recorded to obtain the IP address information of the peer IPsec gateway device.
[0012] This invention also proposes a system for automatically generating IPsec security policies, applied to a local IPsec gateway device, for implementing the method described above for automatically generating IPsec security policies, including: The multicast probe module is used to periodically send multicast probe messages and receive multicast probe messages sent by other IPsec gateway devices, and parse the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device. The negotiation establishment module is used to establish an IKE SA with the corresponding peer IPsec gateway device through negotiation based on the IP address information; The clustering processing module is used to continuously receive IP packets from the intranet, obtain the source IP address corresponding to the IP packet, and input it as a sample to the density-based clustering algorithm DBSCAN module for clustering processing: if the number of source IP address samples input to the DBSCAN module meets a preset clustering threshold, then the local protection subnet is obtained through the clustering processing; if the number of samples does not meet the preset clustering threshold, then the source IP address is directly used as the local protection subnet, wherein the local protection subnet is in the form of a single IP address; The subnet interaction module is used to inform the peer IPsec gateway device of the local protection subnet through the IKE SA, and to obtain the peer protection subnet fed back by the peer IPsec gateway device; The policy generation module is used to automatically generate IPsec security policies based on the local protection subnet and the peer protection subnet.
[0013] The present invention also proposes an electronic device, comprising: At least one processor; and a memory communicatively connected to said at least one processor; The memory stores instructions that can be executed by the at least one processor. By executing the instructions stored in the memory, the at least one processor performs the method for automatically generating IPsec security policies as described above.
[0014] The present invention also proposes a computer-readable storage medium for storing instructions that, when executed, enable the method for automatically generating IPsec security policies as described above.
[0015] Compared with existing technologies, the advantages of this invention are: 1. Automated Construction of Security Policies: This invention applies the DBSCAN algorithm to IPsec gateway devices. By clustering and analyzing the source IP addresses of intercepted network packets, it automatically identifies the local protected subnet and obtains information about peer devices using a multicast probing mechanism. Based on this, it automates the entire process from network information collection and protected subnet extraction to SA negotiation and security policy generation, reducing manual configuration and maintenance workload and improving the IPsec gateway's adaptability to dynamic network environments and the efficiency of security policy configuration.
[0016] 2. Improve network segment identification capability under small sample sparse traffic: To address the problem that the traditional DBSCAN algorithm, when using fixed parameters, easily identifies IP addresses in valid network segments as noise points in network cold start and sparse traffic scenarios, this invention dynamically adjusts the neighborhood radius Eps and the minimum number of samples MinPts, enabling the clustering parameters to adapt to different traffic sample distributions. This reduces the possibility of inaccurate identification of valid network segments due to insufficient sample quantity, thereby improving the network segment identification capability under small sample and sparse traffic conditions, and facilitating the differentiation between valid network segments and abnormal isolated IP addresses.
[0017] 3. Improved Business Continuity Through Progressive Policy Correction: Addressing the issue of insufficient traffic samples and difficulty in directly extracting protected subnets during the network cold start phase, this invention employs a progressive policy correction mechanism. In the initial stage, an initial security policy is generated using a single IP address as the protected object, enabling relevant services to obtain corresponding security policy support before the clustering results are formed. As subsequent network traffic samples accumulate, and after meeting the clustering conditions, the DBSCAN algorithm is used to extract protected subnets and update existing security policies. This reduces the risk of business communication delays or interruptions caused by waiting for complete protected subnet identification, improving business continuity and communication reliability during the automatic security policy generation process. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in the embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0019] Figure 1 A flowchart illustrating a method for automatically generating IPsec security policies, provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0020] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0021] The features and performance of the present invention will be further described in detail below with reference to embodiments.
[0022] Example 1 Traditional IPsec gateway devices rely on manual configuration of security policies. Users generate configuration information based on network topology and interconnection requirements, and then configure each IPsec gateway device individually. Because security policies are complex (including protected subnets for both communicating parties and peer IP addresses), configuration efficiency is low. When the network is large and its topology changes dynamically, modifications need to be made to each device individually, resulting in poor timeliness.
[0023] To address the aforementioned issues of low configuration efficiency and lack of automation, this embodiment provides a configuration-free automation solution by applying a density-based clustering algorithm (DBSCAN) to the IPsec gateway. Specifically, in conjunction with... Figure 1 This embodiment provides a method for automatically generating IPsec security policies, applied to a local IPsec gateway device, including the following steps: Periodically send multicast probe messages and receive multicast probe messages sent by other IPsec gateway devices, and parse the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device; Based on the IP address information, an IKE SA is established through negotiation with the corresponding peer IPsec gateway device. The system continuously receives IP packets from the intranet, obtains the source IP address corresponding to the IP packet, and inputs it as a sample into the density-based clustering algorithm DBSCAN module for clustering processing. If the number of source IP address samples input to the DBSCAN module meets a preset clustering threshold, the local protection subnet is obtained through the clustering process. If the number of samples does not meet the preset clustering threshold, the source IP address is directly used as the local protection subnet, wherein the local protection subnet is in the form of a single IP address. The IKE SA informs the peer IPsec gateway device of the local protection subnet and obtains the peer protection subnet fed back by the peer IPsec gateway device. Based on the local protection subnet and the peer protection subnet, an IPsec security policy is automatically generated.
[0024] Specifically, the above process can be broken down into the following detailed execution steps: Phase 1: Automatic detection of peer IPsec gateway devices based on multicast Combination Figure 1 The process includes "device network access," "periodic sending of multicast probe messages," and "receiving of multicast probe messages." In one specific embodiment, the periodic sending of multicast probe messages, receiving multicast probe messages from other IPsec gateway devices, and parsing the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device includes: Periodically construct and send multicast probe packets with a destination IP address of a specific multicast address, and simultaneously listen to the specific multicast address; When a multicast probe packet is received from another IPsec gateway device, the IP address of the multicast initiator device and the identity information in the multicast probe packet are recorded to obtain the IP address information of the peer IPsec gateway device. The IP address information and identity information of the peer IPsec gateway device are then synchronously updated in the local peer device information database (e.g., ...). Figure 1 The "update peer device information database" step provides a verification basis for the subsequent establishment of IKE SA.
[0025] Those skilled in the art will understand that the aforementioned specific multicast address can be an unused multicast address allocated by IANA specifically for gateway discovery, or it can be a private multicast address defined within the enterprise intranet; the identity information can include, but is not limited to, device serial number (SN), device name, or digital certificate, as long as it can uniquely identify the peer gateway. After obtaining the peer's IP address, both ends initiate negotiation to establish an IKE SA (Security Association), which is a mature standard key exchange mechanism in this field used to provide a secure channel.
[0026] Phase Two: Network Traffic Data Preprocessing In practical network communication, it is necessary to extract the actual subnet range connected to the gateway. Combined with... Figure 1 The steps of "obtaining the source IP address and using it as a sample" and performing "DBSCAN module clustering processing" are as follows. In one specific embodiment, obtaining the source IP address corresponding to the IP packet and inputting it as a sample into the density-based clustering algorithm DBSCAN module for clustering processing includes: The IP packets are cleaned to remove invalid packets and retain valid ones. The source IP addresses of the valid IP packets are extracted to construct the IP dataset to be analyzed. To address the issue that dotted-decimal format of IP addresses cannot be directly used in clustering calculations, an IP address quantization conversion method is employed. The source IP addresses in the IP dataset to be analyzed are treated as four-segment IP addresses, and these four-segment IP addresses are converted into decimal long integer values to construct a one-dimensional IP feature vector composed of these decimal long integer values. This one-dimensional IP feature vector is then input into the DBSCAN module for clustering calculations. The four segments of the four-segment IP address, from left to right, are denoted as follows: , , and The step of converting the four-segment IP address into a decimal long integer value. The conversion formula is:
[0027] Specific example: Suppose the extracted valid source IP address is `192.168.1.10`, and its four segments are as follows: , , , Substituting into the above formula, we can calculate... This standardized transformation enables the digital feature mapping of IP addresses, providing perfectly matched one-dimensional input data for subsequent density clustering.
[0028] Phase 3: Algorithm Parameter Optimization and Clustering Implementation Because the small amount of network traffic captured when the gateway first starts up is sparse and has a small sample size, directly using the default parameters of traditional DBSCAN can lead to network segmentation failure (for example, small effective network segments may be misclassified as noise). Therefore, in one specific implementation, before inputting the one-dimensional IP feature vector into the DBSCAN module for clustering calculation, the following steps are also included: The core parameters of the DBSCAN module are specifically optimized and configured, including the neighborhood radius Eps and the minimum number of samples MinPts. The neighborhood radius Eps is set according to the IP value interval of the standard network segment to match the address span of common subnet segments, so that the source IP addresses within the same continuous network segment are classified into the same neighborhood. Specifically, the neighborhood radius Eps represents the maximum interval value between IP addresses that are allowed to be classified into the same cluster. For example, if the expected target subnet is a continuous network segment with a mask length of 24 bits (i.e., / 24), the neighborhood radius Eps can be set to 128. At the same time, the algorithm's hard requirement for data density is weakened, and the minimum number of samples MinPts is reduced and set to a sparse sample adaptation threshold that matches the current network traffic data volume. The minimum number of samples MinPts represents the minimum number of neighboring samples required to form an independent cluster. In a cold start or low-sample traffic environment, the sparse sample adaptation threshold can be set to 2 (i.e., clustering can be started with only 2 source IP samples); in contrast, in a normal network traffic environment, the threshold can be dynamically adjusted to 5.
[0029] Based on the optimized parameters described above, the step of inputting the one-dimensional IP feature vector into the DBSCAN module for clustering calculation includes: Based on the neighborhood radius Eps and the minimum number of samples MinPts, the algorithm traverses the one-dimensional IP feature vector and treats each decimal long integer value in the one-dimensional IP feature vector as a data point, determining the type of each data point to identify the core point that meets the density requirement; starting from the unvisited core point, it recursively traverses all density-reachable data points to form independent IP clusters, each IP cluster corresponding to a continuous network segment; for data points that do not meet the density-reachability condition and have no associated core point, they are treated as isolated data points and directly marked as noise data.
[0030] By using adaptive parameter matching, the problem of insufficient clustering sensitivity of the traditional DBSCAN algorithm under sparse data is solved. The entire clustering process does not require manual intervention to preset the number and range of network segments, and automatically separates effective network segments from abnormal and isolated IPs based entirely on the density distribution of the IP data itself.
[0031] Phase Four: Reverse DNS Lookup and Output After clustering, the long integer values need to be restored to a subnet format recognizable by the device. In one specific embodiment, obtaining the local protection subnet through the clustering process includes: The IP clusters are processed in reverse to extract the maximum and minimum values of the decimal long integers contained in each IP cluster; the maximum and minimum values are converted back into dotted decimal IP address ranges; the optimal subnet mask is calculated based on the continuity of IP addresses in the IP address ranges, and the IP clusters are converted into standard network segment formats; at the same time, the noise data is filtered, and all the standard network segment formats are output as the local protection subnet under the current traffic.
[0032] Assuming the minimum value extracted from a certain IP cluster is restored to `192.168.1.1` and the maximum value to `192.168.1.254`, calculating their continuous coverage range yields the optimal subnet mask as `255.255.255.0`. Finally, this numericalized IP cluster is converted to the standard network segment format `192.168.1.0 / 24`, thus completing the fully automatic generation of the protection subnet. For subnets of any shape and size, this method can derive the matching optimal mask through extreme value calculation.
[0033] Phase 5: A Gradual Correction Mechanism for Addressing Business Cold Start The prerequisite for intelligent extraction of user subnets based on the DBSCAN algorithm is a certain amount of network traffic (i.e., the number of samples must meet the standard). In a real network, if we wait until the complete protection subnet is extracted before establishing a security policy, it will inevitably lead to some users' services being unable to communicate in a timely manner in the early stages.
[0034] To avoid impacting user business communications, this invention provides a seamless, gradual mechanism. In one specific embodiment, the method further includes a gradual modification and improvement process for security policies: When the local IPsec gateway device receives the first IP packet, because the number of samples of the source IP address does not meet the preset clustering threshold (e.g., Figure 1 If the "Does the number of samples meet the preset clustering threshold?" branch is "No", the source IP address of the IP packet is extracted and directly used as the local protection subnet in the form of a single IP address (e.g., Figure 1 The text describes a process that involves using the source IP address as a single IP address for local protection (e.g., generating a single IP protection policy with a / 32 mask), and quickly generating an initial IPsec security policy to ensure the normal operation of current user business communications. As time progresses, with continuous network traffic input and the number of samples of the source IP addresses meeting the preset clustering threshold (e.g., ... Figure 1If the "Sample count meets the preset clustering threshold?" branch is "Yes", the sample library is full. Then, the DBSCAN module is used to cluster and generate a complete local protection subnet (e.g., a ` / 24` segment), and then... Figure 1 The process of "informing the local protection subnet via IKE SA" is used to obtain the updated peer protection subnet, thereby regenerating and correcting the final IPsec security policy. In actual operation, the local IPsec gateway device will continuously execute this process. Figure 1 The process involves steps such as "continuously receiving IP packets from the internal network", "obtaining source IP addresses and using them as samples", "DBSCAN module clustering", "informing the local end about the protected subnet via IKESA", and "automatically generating IPsec security policies", thereby forming and continuously maintaining the final security policy.
[0035] Combination Figure 1 This method stores multiple protection subnets of the peer IPsec gateway device (such as IPsec gateway 1: protection subnet 1, protection subnet 2; IPsec gateway 2: protection subnet 1, etc.) in the local IPsec peer protection subnet database, thereby completely eliminating the tedious work of traditional manual table lookup configuration and greatly improving the adaptability and timeliness of dynamic networks.
[0036] Example 2 Based on the same inventive concept as the foregoing embodiments, this invention also provides a system for automatically generating IPsec security policies. Since the principle by which this system solves the problem is similar to the method in the foregoing Embodiment 1, the implementation of this system can refer to the implementation of the foregoing method, and repeated details will not be elaborated further.
[0037] Specifically, this embodiment provides a system for automatically generating IPsec security policies, applied to a local IPsec gateway device, including: a multicast detection module, a negotiation establishment module, a clustering processing module, a subnet interaction module, and a policy generation module. Wherein: The multicast probe module is used to periodically send multicast probe messages and receive multicast probe messages sent by other IPsec gateway devices, and parse the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device. The negotiation establishment module is communicatively connected to the multicast detection module and is used to establish an IKE SA with the corresponding peer IPsec gateway device through negotiation based on the IP address information. The clustering processing module is used to continuously receive IP packets from the intranet, obtain the source IP address corresponding to the IP packet, and input it as a sample to the density-based clustering algorithm DBSCAN module for clustering processing: if the number of source IP address samples input to the DBSCAN module meets a preset clustering threshold, then the local protection subnet is obtained through the clustering processing; if the number of samples does not meet the preset clustering threshold, then the source IP address is directly used as the local protection subnet, wherein the local protection subnet is in the form of a single IP address; The subnet interaction module is communicatively connected to the negotiation establishment module and the clustering processing module, and is used to inform the peer IPsec gateway device of the local protection subnet through the IKE SA, and obtain the peer protection subnet fed back by the peer IPsec gateway device; The policy generation module is communicatively connected to the subnet interaction module and is used to automatically generate IPsec security policies based on the local protection subnet and the peer protection subnet.
[0038] Optionally, the clustering processing module further includes a data preprocessing submodule, used to clean the IP packets, remove invalid packets to retain valid IP packets, extract the source IP addresses of the valid IP packets to construct an IP dataset to be analyzed; employing an IP address quantization conversion method, the source IP addresses in the IP dataset to be analyzed are treated as four-segment IP addresses, and the four-segment IP addresses are converted into decimal long integer values to construct a one-dimensional IP feature vector composed of the decimal long integer values; wherein, the conversion formula for converting the four-segment IP addresses into decimal long integer values is: the first segment value × 256³ + the second segment value × 256² + the third segment value × 256 + the fourth segment value, that is: .
[0039] Optionally, the clustering processing module further includes a network segment restoration submodule, used to perform reverse processing on each IP cluster, extract the maximum and minimum values of the decimal long integer values contained in each IP cluster; restore the maximum and minimum values to dotted decimal IP address ranges; calculate the optimal subnet mask based on the continuity of IP addresses in the IP address ranges, and convert the IP clusters into standard network segment formats; filter noise data, and output all the standard network segment formats as the local protection subnet.
[0040] It should be noted that the specific working process of each module and its sub-module, the parameter optimization configuration process (such as the setting of neighborhood radius Eps and minimum sample number MinPts), and the gradual correction mechanism to deal with business cold start are all consistent with the corresponding method steps in the aforementioned Embodiment 1. Those skilled in the art can deduce them without any doubt after reading Embodiment 1. In order to keep the specification concise, they will not be elaborated here.
[0041] Based on the same technical concept, embodiments of the present invention also provide an electronic device that can implement the method flow for automatically generating IPsec security policies provided in the above embodiments of the present invention. In one embodiment, the electronic device can be a server, a terminal device, or other electronic devices. Figure 2 As shown, the electronic device may include: At least one processor and a memory connected to the at least one processor. In this embodiment of the invention, the specific connection medium between the processor and the memory is not limited. Figure 2 The example used is the connection between the processor and memory via a bus. The bus... Figure 2 The connections between other components are indicated by thick lines and are for illustrative purposes only, not as limiting information. Buses can be divided into address buses, data buses, control buses, etc., but for ease of representation, [the specific bus type is not shown here]. Figure 2 The processor is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, a processor can also be called a controller; there are no restrictions on the name.
[0042] In this embodiment of the invention, the memory stores instructions executable by at least one processor. By executing the instructions stored in the memory, the at least one processor can perform a method for automatically generating IPsec security policies as described above. The processor can implement... Figure 2 The functions of each module in the device shown.
[0043] The processor is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory and calling data stored in memory, it can monitor the device's various functions and process data, thereby enabling overall monitoring of the device.
[0044] In an alternative design, the processor may include one or more processing units. The processor may integrate an application processor and a modem processor, wherein the application processor primarily handles the operating system, user interface, and applications, while the modem processor primarily handles wireless communication. It is understood that the modem processor may also not be integrated into the processor. In some embodiments, the processor and memory may be implemented on the same chip; in some embodiments, they may also be implemented separately on separate chips.
[0045] The processor can be a general-purpose processor, such as a CPU, digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method for automatically generating IPsec security policies disclosed in the embodiments of this invention can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.
[0046] Memory, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory, static random access memory, programmable read-only memory, read-only memory, electrically erasable programmable read-only memory, magnetic memory, magnetic disk, optical disk, etc. Memory is any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In embodiments of the present invention, memory can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0047] By designing and programming the processor, the code corresponding to the method for automatically generating IPsec security policies described in the foregoing embodiments can be embedded into the chip, enabling the chip to execute the steps of the method described in the foregoing embodiments during runtime. How to design and program a processor is a technique well-known to those skilled in the art and will not be elaborated upon here.
[0048] Based on the same inventive concept, embodiments of the present invention also provide a storage medium storing computer instructions that, when executed on a computer, cause the computer to perform a method for automatically generating an IPsec security policy as described above.
[0049] In some alternative embodiments, the present invention also provides a method for automatically generating IPsec security policies that can also be implemented as a program product comprising program code that, when the program product is run on a device, causes the control device to perform the steps in the method for automatically generating IPsec security policies according to various exemplary embodiments of the present invention described above.
[0050] It should be noted that although several units or sub-units of the apparatus have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of the invention, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units. Furthermore, although the operation of the method of the invention is described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0051] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media containing computer-usable program code.
[0052] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a server, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0053] Program code for performing the operations of this invention can be written using any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0054] In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0055] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0056] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0057] The embodiments described above merely illustrate specific implementation methods of this application, and while the descriptions are detailed and specific, they should not be construed as limiting the scope of protection of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the technical solution of this application, and these modifications and improvements all fall within the scope of protection of this application.
Claims
1. A method for automatically generating IPsec security policies, applied to a local IPsec gateway device, characterized in that, include: Periodically send multicast probe messages and receive multicast probe messages sent by other IPsec gateway devices, and parse the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device; Based on the IP address information, an IKE SA is established through negotiation with the corresponding peer IPsec gateway device. The system continuously receives IP packets from the intranet, obtains the source IP address corresponding to the IP packet, and inputs it as a sample into the density-based clustering algorithm DBSCAN module for clustering processing. If the number of source IP address samples input to the DBSCAN module meets a preset clustering threshold, the local protection subnet is obtained through the clustering process. If the number of samples does not meet the preset clustering threshold, the source IP address is directly used as the local protection subnet, wherein the local protection subnet is in the form of a single IP address. The IKE SA informs the peer IPsec gateway device of the local protection subnet and obtains the peer protection subnet fed back by the peer IPsec gateway device. Based on the local protection subnet and the peer protection subnet, an IPsec security policy is automatically generated.
2. The method for automatically generating IPsec security policies according to claim 1, characterized in that, Obtain the source IP address corresponding to the IP packet and input it as a sample into the density-based clustering algorithm DBSCAN module for clustering processing, including: The IP packets are cleaned to remove invalid packets and retain valid IP packets. The source IP addresses of the valid IP packets are extracted to construct the IP dataset to be analyzed. The IP address quantization conversion method is adopted to take the source IP address in the IP dataset to be analyzed as a four-segment IP address, and convert the four-segment IP address into a decimal long integer value to construct a one-dimensional IP feature vector composed of the decimal long integer value. The one-dimensional IP feature vector is input into the DBSCAN module for clustering calculation. The four segments of the four-segment IP address, from left to right, are denoted as follows: , , and The four-segment IP address is converted into a decimal long integer value. The conversion formula is: .
3. The method for automatically generating IPsec security policies according to claim 2, characterized in that, Before inputting the one-dimensional IP feature vector into the DBSCAN module for clustering calculation, the following steps are also included: The core parameters of the DBSCAN module are optimized and configured, including the neighborhood radius Eps and the minimum number of samples MinPts. The neighborhood radius Eps is set according to the IP value interval of the standard network segment so that the source IP addresses within the same continuous network segment are divided into the same neighborhood. Set the minimum number of samples, MinPts, to a sparse sample adaptation threshold that matches the current network traffic data volume.
4. The method for automatically generating IPsec security policies according to claim 3, characterized in that, The one-dimensional IP feature vector is input into the DBSCAN module for clustering calculation, including: Based on the neighborhood radius Eps and the minimum number of samples MinPts, the one-dimensional IP feature vector is traversed, and each of the decimal long integer values in the one-dimensional IP feature vector is taken as a data point to identify the core points that meet the density requirements. Starting from the unvisited core point, recursively traverse all density-reachable data points to form independent IP clusters, each of which corresponds to a continuous network segment. For data points that do not meet the density reachability condition and have no associated core points, they are treated as isolated data points and marked as noise data.
5. The method for automatically generating IPsec security policies according to claim 4, characterized in that, The local protection subnet is obtained through the clustering process, including: The IP clusters are processed in reverse to extract the maximum and minimum values of the decimal long integer values contained in each IP cluster. Convert the maximum and minimum values back to dotted decimal IP address ranges; The optimal subnet mask is calculated based on the continuity of IP addresses within the IP address range, and the IP clusters are converted into a standard network segment format. Filter the noise data and output all the standard network segment formats as the local protection subnet.
6. The method for automatically generating IPsec security policies according to claim 1, characterized in that, It also includes the gradual revision and improvement process of security strategies: When the local IPsec gateway device receives the first IP packet, since the number of samples of the source IP address does not meet the preset clustering threshold, the source IP address of the IP packet is extracted and directly used as the local protection subnet in the form of a single IP address, and an initial IPsec security policy is generated to ensure service communication. After continuous network traffic input and the number of samples of the source IP address meets the preset clustering threshold, the local protection subnet is generated through the DBSCAN module, and the updated peer protection subnet is obtained to regenerate and correct the final IPsec security policy.
7. The method for automatically generating IPsec security policies according to claim 1, characterized in that, The system periodically sends multicast probe messages and receives multicast probe messages from other IPsec gateway devices. It parses these multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device, including: Periodically construct and send multicast probe packets with a destination IP address of a specific multicast address, and simultaneously listen to the specific multicast address; When a multicast probe packet is received from another IPsec gateway device, the IP address of the multicast initiator device and the identity information in the multicast probe packet are recorded to obtain the IP address information of the peer IPsec gateway device.
8. A system for automatically generating IPsec security policies, applied to a local IPsec gateway device, characterized in that, A method for automatically generating IPsec security policies as described in any one of claims 1-7, comprising: The multicast probe module is used to periodically send multicast probe messages and receive multicast probe messages sent by other IPsec gateway devices, and parse the multicast probe messages to obtain the IP address information of at least one peer IPsec gateway device. The negotiation establishment module is used to establish an IKE SA with the corresponding peer IPsec gateway device through negotiation based on the IP address information; The clustering processing module is used to continuously receive IP packets from the intranet, obtain the source IP address corresponding to the IP packet, and input it as a sample to the density-based clustering algorithm DBSCAN module for clustering processing: if the number of source IP address samples input to the DBSCAN module meets a preset clustering threshold, then the local protection subnet is obtained through the clustering processing; if the number of samples does not meet the preset clustering threshold, then the source IP address is directly used as the local protection subnet, wherein the local protection subnet is in the form of a single IP address; The subnet interaction module is used to inform the peer IPsec gateway device of the local protection subnet through the IKE SA, and to obtain the peer protection subnet fed back by the peer IPsec gateway device; The policy generation module is used to automatically generate IPsec security policies based on the local protection subnet and the peer protection subnet.
9. An electronic device, characterized in that, include: At least one processor; and a memory communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the at least one processor executes the instructions stored in the memory to perform the method for automatically generating IPsec security policies as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store instructions that, when executed, enable the method for automatically generating an IPsec security policy as described in any one of claims 1-7.
