Automatic recommendation methods, devices, electronic equipment, and media for available IP addresses and ports.
By obtaining work order requests to determine the scenario type, matching scenario rules and generating NAT work order policies, and automatically recommending available IPs and ports, the system solves the problem of low operational efficiency in enterprise network address translation and achieves efficient and accurate IP and port utilization.
Patent Information
- Application Number
- CN202310001735.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-03
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-01-03
AI Technical Summary
During the network address translation process, enterprises often struggle to efficiently and accurately determine the IP and port usage of deployed applications, leading to low operational efficiency.
By obtaining work order requests, determining the scenario type, matching scenario rules, obtaining the address mapping table, and generating NAT work order policies according to preset rules, the system automatically recommends available IPs and ports.
It achieves efficient and accurate network address translation, improves operational efficiency, and ensures the rational use of IP addresses and ports.
Smart Images

Figure CN116132399B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer network security technology, and in particular to a method, apparatus, electronic device, and medium for automatically recommending available IPs and ports based on a scenario. Background Technology
[0002] Most enterprises need to deploy applications externally, and some may even have many different applications. However, due to the limited number of public IP addresses, enterprises typically do not use a single public IP address for each application. Instead, different applications reuse the same public IP address on different ports. In the initial planning stages, enterprises often have a preliminary plan for converting IP addresses from different regions or network segments to specific IP ranges. However, as time goes on, the number of converted addresses and ports increases, making it extremely difficult to manually identify which IP addresses and ports are already in use and which can be reused—it's like finding a needle in a haystack.
[0003] In actual operation and maintenance, the maintenance of NAT rules and IP addresses is quite complex, and there is no effective means to monitor historical rules and IP usage. Network administrators usually manage them by manually recording, which is inefficient and inaccurate.
[0004] Therefore, how to automatically identify published applications, filter reusable IPs and ports, and provide administrators with accurate and usable external publishing addresses to achieve efficient and accurate operation and maintenance is an urgent problem to be solved. Summary of the Invention
[0005] In view of this, it is necessary to provide a method, device, electronic device and medium for automatically recommending available IPs and ports based on scenarios, so as to automatically analyze the remaining available IPs and ports and recommend them to users, so as to achieve the purpose of efficient and accurate operation and maintenance.
[0006] To achieve the above objectives, in a first aspect, the present invention provides a method for automatically recommending available IP addresses and ports, comprising:
[0007] Obtain work order requests and determine the scenario type that needs to be configured based on the request relationships in the work order requests;
[0008] Match the corresponding scenario rules based on the work order content in the work order request;
[0009] Obtain the corresponding address mapping table based on the scenario rules;
[0010] A NAT ticket policy is generated from the scenario rules and the address mapping table according to preset generation rules, wherein the NAT ticket policy includes recommended available IPs and ports.
[0011] Furthermore, determining the scenario type to be configured based on the request relationship in the work order request includes:
[0012] If the request relationship is from the internal network to the external network, the scenario type that needs to be configured is source NAT, where source NAT includes one-to-one source NAT and many-to-one source NAT;
[0013] If the request relationship is from the external network to the internal network, the scenario type that needs to be configured is Destination NAT;
[0014] The scenario rules for matching the work order content in the work order request include:
[0015] Matching the corresponding scenario rules based on the five-tuple information in the work order content.
[0016] Furthermore, obtaining the corresponding address mapping table based on the scenario rules includes:
[0017] Based on the scenario rules, the network address translation device that needs to be configured with the NAT work order policy is determined;
[0018] The address mapping table is obtained by parsing the running-config in the network address translation device.
[0019] Furthermore, if the scenario type to be configured is one-to-one source NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes:
[0020] Obtain the first source IP that intersects the work order content with the scenario rules, and query the address mapping table based on the first source IP;
[0021] If the first source IP has a mapping relationship in the address mapping table, the mapping relationship is reused as the first source NAT ticket policy.
[0022] If the first source IP does not have a mapping relationship in the address mapping table, an unused IP is obtained from the converted source IPs included in the scenario rules, and a second source NAT work order policy is generated based on the unused IP.
[0023] Furthermore, if the scenario type to be configured is many-to-one source NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes:
[0024] Determine whether there is a second source IP that intersects with the scenario rules and the address mapping table;
[0025] If there is a second source IP that intersects with the scenario rule and the address mapping table, then the mapping relationship corresponding to the second source IP is edited as the third source NAT work order policy;
[0026] If the scenario rule and the address mapping table do not have a second source IP, then a fourth source NAT work order policy is generated based on the third source IP in the work order content.
[0027] Furthermore, if the scenario type to be configured is destination NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes:
[0028] Obtain the first destination IP and port at the intersection of the work order content and the scenario rules, and query the address mapping table based on the first destination IP and port;
[0029] If the first destination IP and port both exist in the address mapping table, obtain the mapping relationship including the first destination IP and port, and reuse the mapping relationship as the first destination NAT ticket policy;
[0030] If the port exists in the address mapping table and the first destination IP does not exist in the address mapping table, then the usable IP is obtained from the second destination IP included in the scenario rules, and a second destination NAT ticket policy is generated in combination with the port.
[0031] If the first destination IP exists in the address mapping table, but the port does not exist in the address mapping table, then the port included in the scenario rule is obtained, and a third destination NAT ticket policy is generated in combination with the first destination IP.
[0032] Furthermore, after generating the NAT ticket policy, the method also includes:
[0033] The NAT ticket policy is distributed to the network address translation devices that need to configure the NAT ticket policy.
[0034] Generate relevant security policies on the network address translation device;
[0035] The NAT ticket policy and related security policies are simulated on the network address translation device.
[0036] Secondly, the present invention also provides an automatic recommendation device for available IP addresses and ports, comprising:
[0037] The scenario type determination module is used to obtain work order requests and determine the scenario type that needs to be configured based on the request relationships in the work order requests.
[0038] The scenario rule matching module matches the corresponding scenario rules based on the work order content in the work order request;
[0039] The address mapping table acquisition module is used to acquire the corresponding address mapping table based on the scenario rules.
[0040] The NAT ticket policy generation module is used to generate NAT ticket policies from the scenario rules and the address mapping table according to preset generation rules, wherein the NAT ticket policy includes recommended available IPs and ports.
[0041] Thirdly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps in the above-described automatic recommendation method for available IP addresses and ports.
[0042] Fourthly, the present invention also provides a computer storage medium storing a computer program that, when executed by a processor, implements the steps in the above-described method for automatically recommending available IP addresses and ports.
[0043] The beneficial effects of using the above embodiments are:
[0044] This invention determines the scenario type that needs to be configured by the request relationship in the work order request, matches the corresponding scenario rules based on the work order content in the work order request, further narrows the scope of data analysis and improves analysis efficiency; then, it obtains the corresponding address mapping table based on the scenario rules, that is, by parsing the existing mapping relationship in the network and combining it with the initial network planning, it automatically analyzes the remaining available IPs and ports according to the preset generation rules, thereby achieving efficient and accurate operation and maintenance. Attached Figure Description
[0045] Figure 1 A flowchart illustrating an embodiment of the automatic recommendation method for available IP addresses and ports provided by the present invention;
[0046] Figure 2 This is a schematic diagram of a process for generating a NAT work order strategy according to an embodiment of the present invention;
[0047] Figure 3 This is a flowchart illustrating another strategy for generating NAT work orders according to an embodiment of the present invention.
[0048] Figure 4 This is a flowchart illustrating another strategy for generating NAT work orders according to an embodiment of the present invention.
[0049] Figure 5 A schematic diagram of an embodiment of the automatic recommendation device for available IPs and ports provided by the present invention;
[0050] Figure 6 A schematic diagram of an embodiment of the electronic device provided by the present invention. Detailed Implementation
[0051] Preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which form part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0052] In the description of this invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. Furthermore, "a plurality of" means two or more, unless otherwise explicitly specified. The reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0053] This invention provides a method, apparatus, electronic device, and medium for automatically recommending available IP addresses and ports. By parsing existing mapping relationships in the current network and combining them with the initial network planning, it automatically analyzes the remaining available IP addresses and ports and recommends them to users, thereby achieving efficient and accurate operation and maintenance.
[0054] Before describing the embodiments, the relevant terms are defined as follows:
[0055] Network Address Translation (NAT) is used when hosts within a private network, already assigned local IP addresses (i.e., private addresses used only within that network), want to communicate with hosts on the internet (without encryption). This method, using a small number of public IP addresses to represent a larger number of private IP addresses, helps alleviate the depletion of available IP address space. This approach typically requires a NAT-enabled firewall or router between the private network and the internet, which can be configured with one or more public IP addresses.
[0056] Source NAT: When all hosts using internal network addresses communicate with the Internet, their internal network addresses must be translated into public IP addresses on a NAT device in order to connect to the Internet. This scenario is called source NAT.
[0057] Destination NAT: When some application servers are set up on the internal network and it is desired to provide access to the external network, since the internal network servers use internal network addresses, external network users cannot directly access them. At this time, address translation is required to map the router's external network address to the internal network server. When external network users access the router's external network address, it can be mapped to the internal network server, thereby achieving the purpose of accessing internal network applications. This scenario is called destination NAT.
[0058] The specific embodiments are described in detail below:
[0059] Please see Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the automatic recommendation method for available IP addresses and ports provided by the present invention. A specific embodiment of the present invention discloses an automatic recommendation method for available IP addresses and ports, comprising:
[0060] Step S101: Obtain the work order request and determine the scenario type that needs to be configured based on the request relationship in the work order request;
[0061] Step S102: Match the corresponding scenario rules based on the work order content in the work order request;
[0062] Step S103: Obtain the corresponding address mapping table based on the scenario rules;
[0063] Step S104: Generate a NAT ticket policy from the scenario rules and address mapping table according to the preset generation rules. The NAT ticket policy includes recommended available IPs and ports.
[0064] This invention determines the scenario type that needs to be configured by the request relationship in the work order request, matches the corresponding scenario rules based on the work order content in the work order request, further narrows the scope of data analysis and improves analysis efficiency; then, it obtains the corresponding address mapping table based on the scenario rules, that is, by parsing the existing mapping relationship in the network and combining it with the initial network planning, it automatically analyzes the remaining available IPs and ports according to the preset generation rules, thereby achieving efficient and accurate operation and maintenance.
[0065] In one embodiment of the present invention, determining the scenario type to be configured based on the request relationship in the work order request includes:
[0066] If the request relationship is from the internal network to the external network, the scenario type that needs to be configured is source NAT, where source NAT includes one-to-one source NAT and many-to-one source NAT;
[0067] If the request relationship is from the external network to the internal network, the scenario type that needs to be configured is Destination NAT;
[0068] First, it's important to clarify that a work order request refers to a request submitted by a business user for service to be activated. For example, if the operations department needs to launch a public portal website, they might submit a work order request to the maintenance department. The content of a work order request typically includes: source IP, destination IP, service, effective date, applicant, and a description of the purpose of the work order.
[0069] When receiving a work order request, the required scenario type can be determined based on the request relationship within the work order request. For example, an access relationship between a source IP and a destination IP can be defined. Based on this access relationship, it can be determined whether source NAT or destination NAT needs to be configured. Specifically, when accessing the external network from the internal network, the scenario type to be configured is source NAT. Source NAT includes one-to-one source NAT and many-to-one source NAT, and many-to-one source NAT will be tagged with an Internet label. When accessing the internal network from the external network, the scenario type to be configured is destination NAT.
[0070] Understandably, during the initial network planning phase, network administrators will pre-define areas or network segments within the network that have internet access needs or require external service deployment. This invention refers to these defined rules as scenario rules. Administrators need to plan the mapped address pools on the boundary firewall in advance according to different scenarios. By transferring the planned rules and data to the online platform for maintenance, the platform can easily perform subsequent analysis based on this foundational data.
[0071] Specifically, the content of the scenario rules includes: firewall information, five-tuple information, and scenario type. The five-tuple information includes source IP, source port, destination IP, destination port, and transport layer protocol, i.e., service. Scenario types include source one-to-one translation, source many-to-one translation, source to outgoing interface translation, destination one-to-one translation, destination one-to-many translation, bidirectional NAT translation, etc.
[0072] Matching scenario rules based on the content of the work order request, including:
[0073] Matching the corresponding scenario rules based on the five-tuple information in the work order content.
[0074] As is understandable, a work order includes information such as the source IP, destination IP, service, effective date, applicant, and a description of the work order's purpose. Similarly, the scenario rules also include the type of conversion, relevant firewall information, and the five-tuple information. Therefore, the corresponding scenario rules can be matched based on the work order content. The specific matching rule logic is as follows:
[0075] It should be noted that during the establishment of scenario rules, to ensure the accuracy of IP mapping, no overlap is allowed between scenario rules; and a match is successful when the five-tuple information of the work order content is completely contained within the five-tuple information of the scenario rule. It should also be noted that the priority of scenario rule matching is as follows: DNAT, re-origin NAT, and NAT of the same type.
[0076] Once a scenario rule is matched, it is necessary to further determine the address mapping table corresponding to the scenario rule in order to recommend available IPs and ports for work order requests.
[0077] In one embodiment of the present invention, obtaining the corresponding address mapping table based on scenario rules includes:
[0078] Based on the scenario rules, determine the network address translation devices that require NAT work order policy configuration;
[0079] Parse the running-config file in the network address translation device to obtain the address mapping table.
[0080] Understandably, the scenario rules also include the network address translation device name. By matching the source address of the work order with the internal and external IPs in the scenario mapping pool, the network device that needs to be configured with NAT, i.e., the network address translation device, can be obtained. Then, by parsing the running config in the network device, the address mapping table corresponding to the network device can be obtained.
[0081] It should be noted that network address translation devices include firewalls, routers, and load balancers. Taking firewalls as an example, the basic data of a firewall consists of IP and port automatic recommendation prerequisites. By connecting to the network device via the SSH protocol, the running configuration of the network device is captured in the command line, parsed, and standardized into a fixed-format routing table list, object (address, service) list, policy (ACL, security|NAT) list, interface list, subnet list, etc., to obtain the published address mapping relationship on the network device.
[0082] Once a scenario rule is matched and the address mapping table corresponding to the scenario rule is determined, the available IPs and ports recommended for the work order request will be introduced according to different scenario types.
[0083] In one embodiment of the present invention, please refer to Figure 2 , Figure 2 This is a flowchart illustrating a NAT ticket generation strategy according to an embodiment of the present invention. If the scenario type to be configured is one-to-one source NAT, a NAT ticket strategy is generated from the scenario rules and address mapping table according to preset generation rules, including:
[0084] Step S201: Obtain the first source IP that is the intersection of the work order content and the scenario rules, and query the address mapping table based on the first source IP;
[0085] Step S202: If the first source IP has a mapping relationship in the address mapping table, reuse the mapping relationship as the first source NAT ticket policy;
[0086] Step S203: If the first source IP does not have a mapping relationship in the address mapping table, obtain the unused IP from the converted source IP included in the scenario rules, and generate the second source NAT work order policy based on the unused IP.
[0087] Understandably, if the scenario type to be configured is one-to-one source NAT, it is first necessary to determine whether the work order content is included in the scenario rules. If it matches but is not included, no NAT translation is needed. If the work order content matches and is included in the scenario rules, the intersection of the work order content and the scenario rule table is extracted, i.e., the first source IP. The NAT mapping table is then queried to determine whether the first source IP already has a mapping relationship in the NAT mapping table. If a mapping relationship exists, it is reused; otherwise, an unused IP address is extracted from the source IPs after translation by the scenario rules and used as the source NAT translated address, ultimately resulting in a source NAT work order policy.
[0088] Table 1a - Scene Rule 1
[0089]
[0090] Table 1b - Work Order Contents 1
[0091] Source IP destination IP Serve 1.1.1.1 Any Any
[0092] Table 1c - NAT Mapping Table 1
[0093] type equipment Source IP Source IP after conversion One-to-one source NAT Device1 1.1.1.1 202.1.1.1
[0094] For example, please refer to Tables 1a, 1b, and 1c. It can be seen that the source IP, destination IP, and service in Table 1b completely match the source IP, destination IP, and service in Table 1a. Therefore, the address mapping table for the device name can be further determined based on the device name in Table 1a, i.e., Table 1c. From Table 1c, it can be seen that the intersection of scenario rule 1 and work order content 1, the first source IP exists in Table 1. Therefore, the mapping relationship of the first source IP can be reused as the first source MAT work order strategy.
[0095] In one embodiment of the present invention, please refer to Figure 3 , Figure 3This is a schematic diagram illustrating another process for generating NAT work order strategies according to an embodiment of the present invention. If the scenario type to be configured is many-to-one source NAT, a NAT work order strategy is generated from the scenario rules and address mapping table according to preset generation rules, including:
[0096] Step S301: Determine whether there is a second source IP that intersects with the scenario rules and the address mapping table;
[0097] Step S302: If there is a second source IP that intersects with the scenario rule and the address mapping table, then edit the mapping relationship corresponding to the second source IP as the third source NAT work order policy;
[0098] Step S303: If there is no second source IP that intersects with the scenario rules and the address mapping table, then generate a fourth source NAT work order policy based on the third source IP in the work order content.
[0099] It should be noted that source NAT includes not only one-to-one source NAT and many-to-one source NAT, but also outgoing interfaces. Since the calculation logic of many-to-one source NAT is the same as that of outgoing interfaces, and only the generated command line is different, it will not be explained separately here.
[0100] Understandably, if the scenario type to be configured is many-to-one source NAT, it is first necessary to determine whether the work order content is included in the scenario rules. If it matches but is not included, then no NAT translation is required.
[0101] If the work order content is matched and contained by the scenario rule, then determine whether there is a second source IP that intersects with the scenario rule and the address mapping table.
[0102] If it exists, the existing mapping relationship is edited, and the source IP of the work order is added to the source IP of the existing mapping table as the third-source NAT work order policy; if it does not exist, a new NAT mapping relationship is automatically generated on the network device based on the third-source IP in the work order content.
[0103] Table 2a - Scene Rule 2
[0104]
[0105]
[0106] Table 2b - Work Order Contents 2
[0107] Source IP destination IP Serve 1.1.1.2 Any Any
[0108] Table 2c - NAT Mapping Table 2
[0109] type equipment Source IP Source IP after conversion Many-to-one source NAT Device1 1.1.1.1 202.1.1.1
[0110] For example, please refer to Tables 2a, 2b, and 2c. It can be seen that the work order content 2 in Table 2b matches and is included in scenario rule 2 in Table 2a. Therefore, the address mapping table for the device name can be further determined based on the device name in Table 2a, i.e., Table 2c. Through Table 2c, it can be seen that there is an intersection between the source IP in NAT mapping table 2 and the source IP of the scenario rule. Then, the existing mapping relationship is edited, that is, the source IP of work order content 2 is added to the source IP of the existing NAT mapping table 2. For example, in the above example, the source IP in the NAT mapping table changes from 1.1.1.1 to 1.1.1.1 and 1.1.1.2, which are used as the third source NAT work order strategy.
[0111] If the source IP in NAT mapping table 2 does not intersect with the source IP in scenario rule 2, the system automatically generates a new NAT mapping relationship on network device 1 as the fourth source NAT ticket policy. The mapping relationship of the fourth source NAT ticket policy can be found in Table 2d:
[0112] Table 2d - NAT Mapping Table 3
[0113] type equipment Source IP Source IP after conversion Many-to-one source NAT Device1 1.1.1.2 202.1.1.1
[0114] In one embodiment of the present invention, please refer to Figure 4 , Figure 4 This is a flowchart illustrating another method for generating NAT work order policies according to an embodiment of the present invention. If the scenario type to be configured is destination NAT, a NAT work order policy is generated from the scenario rules and address mapping table according to preset generation rules, including:
[0115] Step S401: Obtain the first destination IP and port at the intersection of the work order content and the scenario rules, and query the address mapping table based on the first destination IP and port;
[0116] Step S402: If the first destination IP and port both exist in the address mapping table, obtain the mapping relationship including the first destination IP and port, and reuse the mapping relationship as the NAT ticket policy for the first destination;
[0117] Step S403: If the port exists in the address mapping table and the first destination IP does not exist in the address mapping table, then obtain the usable IP from the second destination IP included in the scenario rules, and generate the second destination NAT ticket policy in combination with the port.
[0118] Step S404: If the first destination IP exists in the address mapping table but the port does not exist in the address mapping table, then obtain the port included in the scenario rules and generate the third destination NAT ticket policy in combination with the first destination IP.
[0119] Understandably, if the scenario type to be configured is destination NAT, it is first necessary to determine whether the work order content is included in the scenario rules. If it matches but is not included, then no NAT translation is required.
[0120] If the work order content is matched and included by the scenario rules, the intersection of the work order content and the scenario rule table is extracted, that is, the first destination IP and port (service), and the address mapping ratio is queried, that is, NAT mapping table 4. If the first destination IP and port both exist in the address mapping table, the mapping relationship including the first destination IP and port is obtained, and the mapping relationship is reused as the first destination NAT work order policy.
[0121] Table 3a - Scene Rule 3
[0122]
[0123]
[0124] Table 3b - Work Order Contents 3
[0125] Source IP destination IP Serve 200.200.200.200 202.1.1.1 TCP: 80
[0126] Table 3c - NAT Mapping Table 4
[0127]
[0128] For example, please refer to Tables 3a, 3b and 3c. It can be seen that the work order content 3 in Table 3b matches and is included in scenario rule 3 in Table 3a. Therefore, the address mapping table of the device name can be further determined based on the device name in Table 3a, i.e. Table 3c. It can be seen from Table 3c that there is an intersection between work order content 3 and scenario rule 3. Then, the first destination IP and port of the intersection part of work order content 3 and scenario rule 3 are taken, and the NAT mapping table 4 is queried.
[0129] If the first destination IP and port exist in NAT mapping table 4, the mapping relationship is indicated and reused; if the port exists but the first destination IP does not exist, an available IP is taken from scenario rule 3 and combined with the port to generate a new destination NAT policy; if the first destination IP exists but the port does not exist, the IP is reused and combined with the reused IP and port to generate a new destination NAT policy.
[0130] In addition, it should be noted that if the network device type is load balancing, it can be determined whether the port in the work order content is the same as the actual port in the address mapping table. If they are different, a new destination IP and port are created from the address planning pool, and the port should be kept consistent with the one before the conversion as much as possible. If they are the same, it can be determined whether the destination IP in the work order content is the same as the actual destination IP in the address mapping table. If they are the same, the mapping relationship of the destination IP is reused. If they are different, the public IP address and port in the address mapping table are reused.
[0131] In one embodiment of the present invention, after generating the NAT ticket policy, the above method further includes:
[0132] Send the NAT ticket policy to the network address translation devices that need to be configured with NAT ticket policies;
[0133] Generate relevant security policies on the network address translation device;
[0134] Simulation was performed on the network address translation device based on NAT ticket policy and related security policies.
[0135] Understandably, during the simulation activation, the NAT policy generated based on a specific device is simulated onto that device by default, and added to the MongoDB database in the background, assuming the policy already exists on the firewall. During route calculation simulation, the system uses cached data from the MongoDB database. Therefore, if a NAT relationship is found on the device from the MongoDB database, the system continues route simulation using the addresses before and after NAT translation (the IP address used for the query path varies depending on the NAT type) until all devices requiring policy rules are located, and the relevant security policies are generated on these devices. Then, on all devices requiring rules, the security policies and the generated NAT policies are simultaneously distributed to the corresponding devices. At this point, the automatic NAT translation relationship finding and automatic simulation are complete.
[0136] To better implement the automatic recommendation method for available IPs and ports in the embodiments of the present invention, based on the automatic recommendation method for available IPs and ports, please refer to the corresponding documentation. Figure 5 , Figure 5 This is a schematic diagram of an embodiment of the automatic recommendation device for available IP addresses and ports provided by the present invention. The embodiment of the present invention provides an automatic recommendation device 500 for available IP addresses and ports, comprising:
[0137] The scenario type determination module 501 is used to obtain work order requests and determine the scenario type that needs to be configured based on the request relationships in the work order requests.
[0138] The scene rule matching module 502 matches the corresponding scene rules based on the work order content in the work order request.
[0139] Address mapping table acquisition module 503 is used to acquire the corresponding address mapping table based on scenario rules;
[0140] The NAT ticket policy generation module 504 is used to generate NAT ticket policies from scenario rules and address mapping tables according to preset generation rules. The NAT ticket policy includes recommended available IPs and ports.
[0141] It should be noted that the device 500 provided in the above embodiments can implement the technical solutions described in the above method embodiments. The specific implementation principles of the above modules or units can be found in the corresponding content in the above method embodiments, and will not be repeated here.
[0142] Based on the above-described automatic recommendation method for available IPs and ports, this invention also provides an electronic device, including: a processor and a memory, and a computer program stored in the memory and executable on the processor; when the processor executes the computer program, it implements the steps in the automatic recommendation method for available IPs and ports as described in the above embodiments.
[0143] Figure 6 The diagram shows a structural schematic of an electronic device 600 suitable for implementing embodiments of the present invention. The electronic device in the embodiments of the present invention may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of the present invention.
[0144] The electronic device includes a memory and a processor, wherein the processor may be referred to as processing device 601 below, and the memory may include at least one of read-only memory (ROM) 602, random access memory (RAM) 603 and storage device 608 below, as detailed below:
[0145] like Figure 6As shown, electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 601, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 602 or a program loaded from storage device 608 into random access memory (RAM) 603. RAM 603 also stores various programs and data required for the operation of electronic device 600. Processing device 601, ROM 602, and RAM 603 are interconnected via bus 604. Input / output (I / O) interface 605 is also connected to bus 604.
[0146] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows electronic device 600 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 600 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0147] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory 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 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, it performs the functions defined in the methods of the embodiments of the present invention.
[0148] Based on the above-described automatic recommendation method for available IPs and ports, this embodiment of the invention also provides a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement the steps in the automatic recommendation method for available IPs and ports as described in the above embodiments.
[0149] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0150] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. An automatic recommendation method for available IP addresses and ports, characterized in that, include: Obtain a work order request and determine the scenario type to be configured based on the request relationship in the work order request, including: if the request relationship is from internal network to external network, the scenario type to be configured is source NAT, and the source NAT includes one-to-one source NAT and many-to-one source NAT; if the request relationship is from external network to internal network, the scenario type to be configured is destination NAT. Match the corresponding scenario rules based on the work order content in the work order request; Based on the scenario rules, the network address translation device that needs to be configured with the NAT work order policy is determined; Parse the running-config in the network address translation device to obtain the address mapping table; A NAT ticket policy is generated from the scenario rules and the address mapping table according to preset generation rules, wherein the NAT ticket policy includes recommended available IPs and ports; The NAT ticket policy is distributed to the network address translation devices that need to configure the NAT ticket policy. Generate relevant security policies on the network address translation device; Simulation is performed on the network address translation device based on the NAT ticket policy and the related security policies; If the scenario type to be configured is one-to-one source NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes: Obtain the first source IP that intersects the work order content with the scenario rules, and query the address mapping table based on the first source IP; If the first source IP has a mapping relationship in the address mapping table, the mapping relationship is reused as the first source NAT ticket policy. If the first source IP does not have a mapping relationship in the address mapping table, an unused IP is obtained from the converted source IPs included in the scenario rules, and a second source NAT work order policy is generated based on the unused IP. If the scenario type to be configured is many-to-one source NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes: Determine whether there is a second source IP that intersects with the scenario rules and the address mapping table; If there is a second source IP that intersects with the scenario rule and the address mapping table, then the mapping relationship corresponding to the second source IP is edited as the third source NAT work order policy; If the scenario rule and the address mapping table do not have a second source IP, then a fourth source NAT work order policy is generated based on the third source IP in the work order content. If the scenario type to be configured is destination NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes: Obtain the first destination IP and port at the intersection of the work order content and the scenario rules, and query the address mapping table based on the first destination IP and port; If the first destination IP and port both exist in the address mapping table, obtain the mapping relationship including the first destination IP and port, and reuse the mapping relationship as the first destination NAT ticket policy; If the port exists in the address mapping table and the first destination IP does not exist in the address mapping table, then the usable IP is obtained from the second destination IP included in the scenario rules, and a second destination NAT ticket policy is generated in combination with the port. If the first destination IP exists in the address mapping table, but the port does not exist in the address mapping table, then the port included in the scenario rule is obtained, and a third destination NAT ticket policy is generated in combination with the first destination IP.
2. The automatic recommendation method for available IP addresses and ports according to claim 1, characterized in that, The scenario rules for matching the work order content in the work order request include: Matching the corresponding scenario rules based on the five-tuple information in the work order content.
3. An automatic recommendation device for available IP addresses and ports, characterized in that, include: The scenario type determination module is used to obtain work order requests and determine the scenario type to be configured based on the request relationship in the work order request, including: if the request relationship is from internal network to external network, the scenario type to be configured is source NAT, and the source NAT includes one-to-one source NAT and many-to-one source NAT; if the request relationship is from external network to internal network, the scenario type to be configured is destination NAT. The scenario rule matching module matches the corresponding scenario rules based on the work order content in the work order request; The address mapping table acquisition module is used to determine the network address translation device that needs to be configured with the NAT work order policy based on the scenario rules. The address mapping table is obtained by parsing the running-config in the network address translation device; The NAT ticket policy generation module is used to generate NAT ticket policies from the scenario rules and the address mapping table according to preset generation rules, wherein the NAT ticket policy includes recommended available IPs and ports; If the scenario type to be configured is one-to-one source NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes: Obtain the first source IP that intersects the work order content with the scenario rules, and query the address mapping table based on the first source IP; If the first source IP has a mapping relationship in the address mapping table, the mapping relationship is reused as the first source NAT ticket policy. If the first source IP does not have a mapping relationship in the address mapping table, an unused IP is obtained from the converted source IPs included in the scenario rules, and a second source NAT work order policy is generated based on the unused IP. If the scenario type to be configured is many-to-one source NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes: Determine whether there is a second source IP that intersects with the scenario rules and the address mapping table; If there is a second source IP that intersects with the scenario rule and the address mapping table, then the mapping relationship corresponding to the second source IP is edited as the third source NAT work order policy; If the scenario rule and the address mapping table do not have a second source IP, then a fourth source NAT work order policy is generated based on the third source IP in the work order content. If the scenario type to be configured is destination NAT, the step of generating a NAT work order policy from the scenario rules and the address mapping table according to preset generation rules includes: Obtain the first destination IP and port at the intersection of the work order content and the scenario rules, and query the address mapping table based on the first destination IP and port; If the first destination IP and port both exist in the address mapping table, obtain the mapping relationship including the first destination IP and port, and reuse the mapping relationship as the first destination NAT ticket policy; If the port exists in the address mapping table and the first destination IP does not exist in the address mapping table, then the usable IP is obtained from the second destination IP included in the scenario rules, and a second destination NAT ticket policy is generated in combination with the port. If the first destination IP exists in the address mapping table, but the port does not exist in the address mapping table, then the port included in the scenario rule is obtained, and a third destination NAT ticket policy is generated in combination with the first destination IP.
4. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory is used to store a program; and the processor is coupled to the memory for executing the program stored in the memory to implement the steps in the automatic recommendation method for available IPs and ports as described in any one of claims 1 to 2.
5. A computer-readable storage medium, characterized in that, Used to store computer-readable programs or instructions, which, when executed by a processor, are capable of implementing the steps in the automatic recommendation method for available IP addresses and ports as described in any one of claims 1 to 2.
Citation Information
Patent Citations
Method and device for arranging strategies
CN112839045A
