Traffic control method and device involving NAT (Network Address Translation) and electronic equipment
By implementing fine-grained flow control of equipment, applications, domain names and time on NAT devices, the load problem of NAT devices during peak traffic is solved, network stability and resource utilization efficiency are improved, complex environments are adapted to, and security risks are reduced.
Patent Information
- Application Number
- CN202411211875.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-06
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
During peak network traffic, the existing NAT technology fails to refine the traffic management, resulting in excessive load on NAT equipment, reduced processing speed and unstable service.
Using fine-grained NAT conversion control method based on devices, applications, domain names and time, by capturing data packets, extracting target device identification, application type and domain name information, determining traffic processing rules based on preset matching strategies, adjusting traffic flow direction, and realizing intelligent traffic scheduling.
It improves the stability of network performance and resource utilization efficiency, adapts to complex and changeable network environments, realizes fine-grained access management for specific applications or services, and reduces security risks.
Smart Images

Figure CN119094462A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a flow control method, device and electronic device involving NAT conversion. Background Art
[0002] With the continuous advancement of network technology and the surge in the number of Internet users, the shortage of IP address resources has become an issue that cannot be ignored. In order to effectively manage and utilize limited IP address resources, Network Address Translation (NAT) technology came into being. NAT translation allows multiple devices to share a public IP address for Internet access, rather than each device requiring a unique public IP address. This method greatly reduces the demand for public IP addresses, while also making the structure of the internal network invisible to the external network, enhancing the privacy of the network.
[0003] At present, NAT technology in related technologies mainly adopts a unified traffic processing mechanism, and all data flows are processed in the same way, regardless of their specific type or priority. This method fails to manage traffic in detail, and as a result, during peak network traffic hours, NAT devices may encounter excessive loads, resulting in a decrease in processing speed, which in turn leads to service instability.
[0004] Therefore, there is an urgent need for a flow control method, device and electronic device involving NAT conversion. Summary of the invention
[0005] The present application provides a traffic control method, device and electronic device involving NAT conversion, which realizes fine-grained NAT conversion control based on device, application, domain name and time, and improves the stability of overall network performance.
[0006] In a first aspect of the present application, a flow control method involving NAT conversion is provided, the method comprising: capturing a data packet flowing through; extracting the data packet to obtain a corresponding target device identifier, wherein the target device identifier is the source IP address of the data packet; identifying the data packet to obtain a target application type and a target domain name information corresponding to the data packet, wherein the target application type is a specific application category or service category represented by the data packet, and the target domain name information is the domain name of a server that a user is about to access; determining a corresponding preset matching strategy according to the target device identifier, the target application type, and the target domain name information, and determining a flow processing rule corresponding to the data packet according to the preset matching strategy, wherein the preset matching strategy includes device access control, application access control, domain name access control, and time flow control; and adjusting the flow direction of the data packet according to the flow processing rule.
[0007] By adopting the above technical solution, fine-grained traffic control based on devices, applications, domain names and time is realized. By extracting and identifying information such as the source IP address, application type, and target domain name of the data packet, the method can perform differentiated NAT conversion and control on the traffic of different devices, different applications, and different domain names according to the preset matching strategy. This fine-grained traffic management can more accurately meet the needs of different users and applications within the organization and improve the utilization efficiency of network resources. This method enables the NAT device to have a certain intelligent decision-making ability through multi-dimensional identification and analysis of data packets. The NAT device is no longer a simple address translation gateway, but can autonomously select the optimal conversion method and path according to the characteristics of the traffic and the preset strategy. This intelligent traffic scheduling realizes fine-grained access management for specific applications or services, which can better adapt to complex and changing network environments and improve network stability.
[0008] Optionally, capturing data packets passing through specifically includes: setting a network adapter of a network interface to a promiscuous mode; monitoring data traffic on the network interface to capture data packets passing through the network interface, the data packets including data packets pointing to a MAC address of the network adapter; and storing the captured data packets.
[0009] By adopting the above technical solution, by setting the network adapter to promiscuous mode, the network interface can receive all data packets transmitted to the interface, not just the data packets whose destination MAC address matches the local machine. Even if the destination of the data packet is not the local machine, the network interface can capture and process these data packets. This comprehensive data packet capture provides a complete data foundation for subsequent traffic analysis and management.
[0010] Optionally, the data packet is extracted to obtain a corresponding target device identifier, specifically including: extracting header information of the data packet to obtain a source address IP corresponding to the data packet, wherein the source address IP is a network address of a device sending the data packet.
[0011] By adopting the above technical solution, by extracting the source IP address of the data packet, the solution can uniquely identify the device that sent the data packet. As the logical address of the device in the network, the source IP address can reflect the network location and identity of the device. By tracking and analyzing the source IP address, the source of the data packet can be understood and the initiator of the communication can be determined, providing key information for subsequent device management and behavior analysis.
[0012] Optionally, in the traffic processing rules corresponding to the data packet determined according to the preset matching strategy, the traffic processing rules corresponding to the data packet are determined according to the device access control, specifically including: determining whether the target device identifier is a preset device; if the target device identifier is a preset device, determining multiple available application types and multiple accessible domain names corresponding to the preset device; if the target device identifier is not a preset device, prohibiting traffic forwarding of the data packet.
[0013] By adopting the above technical solution, by determining whether the device corresponding to the data packet is a preset device, and further determining the available application types and accessible domain names of the preset device, the solution realizes refined access control for specific devices. This device-based access control can more accurately limit the network activities of unauthorized devices and reduce security risks, while also providing more flexible and convenient access services for authorized devices.
[0014] Optionally, in determining the traffic processing rules corresponding to the data packet according to the preset matching strategy, the traffic processing rules corresponding to the data packet are determined according to application access control and domain name access control, specifically including: judging whether the target application type is any one of the multiple available application types, and judging whether the target domain name information is any one of the multiple accessible domain names; if the target application type is any one of the multiple available application types and the target domain name information is any one of the multiple accessible domain names, then determining that the data packet meets the preset matching strategy.
[0015] By adopting the above technical solution, the application type and domain name are used as independent dimensions of access control, and flexible matching strategies are supported, which improves the flexibility and adaptability of the access control strategy. The available application types and accessible domain names can be configured separately according to actual needs.
[0016] Optionally, if the target application type is any one of the multiple available application types and the target domain name information is any one of the multiple accessible domain names, then after determining that the data packet meets the preset matching strategy, the method includes: obtaining the capture time of the data packet and using the capture time as the target time; determining the corresponding transmission bandwidth based on the target time and the target application type.
[0017] By adopting the above technical solution, the capture time is introduced as a consideration of the target time. Combined with the target application type, the flow control can be more refined. Appropriate transmission bandwidth is allocated for different types of applications. The target application type, target domain name information, and capture time are comprehensively considered to achieve intelligent management and adjustment of network traffic. This method can better meet users' needs for different applications and services, and provide more personalized and optimized network services.
[0018] Optionally, the traffic direction of the data packet is adjusted according to the traffic processing rules, and the data packet is subjected to corresponding NAT conversion, specifically including: adjusting the traffic flow of the traffic packet according to the transmission bandwidth; converting the source IP address and port number of the data packet into the corresponding public IPv4 address and port number.
[0019] By adopting the above technical solution, the secure isolation and intercommunication between the internal and external networks are realized. By converting the private source IP address and port number of the data packet into a public IP address and port number, the solution realizes the secure isolation and effective intercommunication between the internal network and the external network. NAT conversion shields the topology and address information of the internal network, preventing external attackers from directly accessing or scanning internal hosts, and improving network security.
[0020] In a second aspect of the present application, a flow control device involving NAT conversion is provided, the device comprising: a capture module and a processing module; the capture module is used to capture a data packet flowing through; the processing module is used to extract the data packet and obtain a corresponding target device identifier, wherein the target device identifier is the source IP address of the data packet; the processing module is also used to identify the data packet and obtain a target application type and a target domain name information corresponding to the data packet, wherein the target application type is a specific application category or service category represented by the data packet, and the target domain name information is a domain name of a server that a user is about to access; the processing module is also used to determine a corresponding preset matching strategy according to the target device identifier, the target application type and the target domain name information, and determine a flow processing rule corresponding to the data packet according to the preset matching strategy, wherein the preset matching strategy includes device access control, application access control, domain name access control and time flow control; the processing module is also used to adjust the flow direction of the data packet according to the flow processing rule, and perform corresponding NAT conversion on the data packet.
[0021] In the third aspect of the present application, an electronic device is provided, including a processor, a memory, a user interface and a network interface, the memory is used to store instructions, the user interface and the network interface are used to communicate with other devices, and the processor is used to execute the instructions stored in the memory so that the electronic device executes any one of the above methods.
[0022] In a fourth aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions. When the instructions are executed, the method steps shown above are executed.
[0023] In summary, one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages: 1. Implemented fine-grained traffic control based on devices, applications, domain names, and time. By extracting and identifying information such as the source IP address, application type, and target domain name of the data packet, the method can perform differentiated NAT conversion and control on traffic of different devices, different applications, and different domain names according to the preset matching strategy. This fine-grained traffic management can more accurately meet the needs of different users and applications within the organization and improve the utilization efficiency of network resources. This method enables NAT devices to have certain intelligent decision-making capabilities through multi-dimensional identification and analysis of data packets. NAT devices are no longer simple address translation gateways, but can autonomously select the optimal conversion method and path based on the characteristics of the traffic and preset strategies. This intelligent traffic scheduling implements fine-grained access management for specific applications or services, which can better adapt to complex and changing network environments and improve network stability.
[0024] 2. By setting the network adapter to promiscuous mode, the network interface can receive all data packets transmitted to the interface, not just the data packets whose destination MAC address matches the local machine. Even if the destination of the data packet is not the local machine, the network interface can capture and process these data packets. This comprehensive data packet capture provides a complete data foundation for subsequent traffic analysis and management.
[0025] 3. By determining whether the device corresponding to the data packet is a preset device, and further determining the available application types and accessible domain names of the preset device, the solution implements refined access control for specific devices. This device-based access control can more accurately limit the network activities of unauthorized devices and reduce security risks, while also providing more flexible and convenient access services for authorized devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 It is a scenario diagram of a flow control method involving NAT conversion provided by an embodiment of the present application; Figure 2 It is a flow chart of a flow control method involving NAT conversion provided by an embodiment of the present application; Figure 3 It is a module schematic diagram of a flow control device involving NAT conversion provided in an embodiment of the present application; Figure 4 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0027] Explanation of the reference numerals: 301, capture module; 302, processing module; 400, electronic device; 401, processor; 402, communication bus; 403, user interface; 404, network interface; 405, memory. DETAILED DESCRIPTION
[0028] In order to enable technicians in this field to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments.
[0029] In the description of the embodiments of the present application, words such as "for example" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design scheme described as "for example" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "for example" or "for example" is intended to present related concepts in a specific way.
[0030] In the description of the embodiments of the present application, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized.
[0031] The technical solution provided by this application is to optimize the management and processing of network traffic according to specific rules and policies in NAT conversion. Figure 1As shown in the scenario diagram, host A wants to access a video streaming service (for example, the target domain name information is streaming-service.com) at a specific time. The data packet of host A is first captured by the NAT device, which checks whether host A has permission to access this service and confirms whether the current time is within the time range for allowed traffic. If host A is allowed to access, the NAT device will adjust the transmission bandwidth based on the current network traffic and the preset bandwidth rules, and perform NAT conversion to map the private IP address of host A to a public IPv4 address and port number. The adjusted data packet is then sent to the target server through the private network and the Internet, and the server responds to the request based on the public IPv4 address and port number. The data packet in response to host A's request will also undergo a similar NAT conversion process and be returned to host A.
[0032] The present application provides a flow control method involving NAT conversion, referring to Figure 2 , Figure 2 1 is a flow chart of a flow control method involving NAT conversion provided in an embodiment of the present application. The method is applied to a server and includes steps S201 to S204, which are as follows: Step S201: Capture the passing data packets.
[0033] In step S201, the network adapter of the network interface is set to promiscuous mode to facilitate the reception of data packets transmitted to the network interface; the data traffic on the network interface is monitored to capture data packets passing through the network interface, including data packets pointing to the MAC address of the network adapter; and the captured data packets are stored.
[0034] Specifically, promiscuous mode is a mode of operation of a network adapter in which it receives all packets transmitted over the network medium to which it is connected, rather than only those packets whose destination MAC address matches the network adapter's own MAC address. This allows network administrators to monitor and analyze all traffic on the network, rather than just traffic arriving at a specific device. Setting promiscuous mode is usually done through the operating system's network configuration tools. Monitoring (also known as capturing or sniffing) data traffic on a network interface refers to using specific software tools to observe and record data packets transmitted through a network interface. These tools are able to read and display detailed information about data packets, including the addresses of the sender and receiver, the size of the packet, the protocol being transmitted, and the data itself.
[0035] Step S202: extract the data packet to obtain the corresponding target device identifier, where the target device identifier is the source IP address of the data packet.
[0036] In step S202, the header information of the data packet is extracted to obtain the source IP address corresponding to the data packet, where the source IP address is the network address of the device sending the data packet.
[0037] Specifically, when a data packet arrives at the intelligent NAT device, the device will first store it in the buffer. Then, the data packet parsing module of the device will perform in-depth parsing on the data packet. During the parsing process, the module will locate the position of the data packet header according to the protocol type of the data packet (such as TCP / IP, UDP, etc.). Taking the common TCP / IP data packet as an example, its header contains many key fields, such as source IP address, destination IP address, source port number, destination port number, protocol type, etc. The intelligent NAT device will accurately locate the source IP address field in the header and extract it. The length of the IPv4 address field is fixed at 32 bits, while the IPv6 address field is 128 bits. The intelligent NAT device will accurately obtain the source IP address of the corresponding length according to the different IP protocol versions. The extracted source IP address is a binary value. In order to facilitate subsequent processing and reading, the intelligent NAT device will convert it into a dotted decimal representation.
[0038] For example, host A (private IP 192.168.1.10) in a local area network wants to access server B (public IP 203.0.113.20) on the Internet. Host A will send a data packet, with its own private IP 192.168.1.10 in the source IP address field and server B's public IP 203.0.113.20 in the destination IP address field. When the data packet reaches the intelligent NAT device, the device extracts its source IP address 192.168.1.10 and identifies it as the address of the internal host A. This lays the foundation for subsequent address translation.
[0039] Step S203: Identify the data packet to obtain the target application type and target domain name information corresponding to the data packet. The target application type is the specific application category or service category represented by the data packet, and the target domain name information is the domain name of the server that the user is about to access.
[0040] In step S203, when the intelligent NAT device identifies the target application type, the intelligent NAT device analyzes various parts of the data packet, especially the application layer data, to find key information that can identify the application type. For example, for an HTTP data packet, the application identification module will check the HTTP header fields in its application layer data, such as "Host", "User-Agent", "Content-Type", etc. These fields usually contain information such as website domain name, browser type, content type, etc., which can be used to infer the application type to which the data packet belongs, such as Web browsing. When the intelligent NAT device identifies the target domain name information, the target domain name information refers to the domain name of the server that the user attempts to access, which reflects the final destination of the data packet. When the intelligent NAT device identifies the target domain name information, it mainly analyzes the application layer data in the data packet in depth. Different application layer protocols carry domain name information in different ways in data packets, so the intelligent NAT device needs to adopt a corresponding analysis method according to the application type to which the data packet belongs. For HTTP / HTTPS data packets, the server will check the request header therein. In HTTP / 1.1 and above versions, the request header usually contains a "Host" field, which clearly specifies the target domain name of the request. For example, if a user tries to access "http: / / www.example.com / index.html", the corresponding HTTP request header will contain "Host: www.example.com". The server can directly extract the value of this field to obtain the target domain name information. For HTTPS packets, the domain name information is usually included in the encrypted application layer data. In order to obtain this information, the server needs to decrypt the packet. During the HTTPS handshake phase, the client sends the target domain name to the server as part of the ServerName Indication (SNI) extension. The server can extract the target domain name by parsing the SNI extension in the ClientHello message without fully decrypting the application layer data.
[0041] For other text-based application layer protocols, such as FTP, SMTP, POP3, etc., the server can obtain the target domain name by parsing the corresponding protocol commands. For example, in the FTP protocol, the client will send the "HOST" command to specify the server domain name to connect to; in the SMTP protocol, the client will send the "HELO" or "EHLO" command, which contains the client's own domain name. The server can extract the target domain name information by matching the parameters of these commands.
[0042] In some cases, the data packet may not contain explicit domain name information. In this case, the server can try to obtain the corresponding domain name based on the target IP address of the data packet in combination with a reverse DNS lookup. Specifically, the server will use the target IP address as a parameter to query the DNS server and request the return of the domain name associated with the IP address.
[0043] For example, the intelligent NAT device captures a data packet and extracts its source IP address as 192.168.1.10. The intelligent NAT device begins to analyze the data packet. The intelligent NAT device finds that the data packet uses the TCP protocol, the destination port is 80, and the application layer data contains HTTP request headers, such as "GET / index.html HTTP / 1.1", "Host: www.example.com", etc. Based on these features, the intelligent NAT device determines that the application type to which the data packet belongs is Web browsing. When analyzing the data packet, the intelligent NAT device finds that its application layer data contains HTTP request headers, which has a key field "Host: www.example.com". At the same time, the intelligent NAT device can directly extract the target domain name information, that is, "www.example.com", by parsing the "Host" field. The HTTP protocol stipulates that when sending a request, the client must clearly specify the domain name of the target server in the request header. The "Host" field is specifically used to carry this information. Specifically, the intelligent NAT device will identify the HTTP request header and analyze it field by field. When encountering the "Host" field, the intelligent NAT device extracts the content after the colon and obtains the target domain name information "www.example.com".
[0044] Step S204: Determine a corresponding preset matching strategy based on the target device identifier, the target application type and the target domain name information, and determine a traffic processing rule corresponding to the data packet based on the preset matching strategy, wherein the preset matching strategy includes device access control, application access control, domain name access control and time traffic control.
[0045] In step S204, the corresponding traffic processing rules corresponding to the data packet are determined according to the device access control, specifically including: determining whether the target device identifier is a preset device; if the target device identifier is a preset device, determining multiple available application types and multiple accessible domain names corresponding to the preset device.
[0046] Specifically, the intelligent NAT device determines whether the target device is a preset device by querying the device access control list, and obtains the available application types and accessible domain names of the preset device. The intelligent NAT device needs to determine whether the target device identifier (source IP address) of the data packet belongs to the preset device. The preset device refers to a device that has an access control policy pre-configured on the intelligent NAT device. At the same time, the access control policy defines the application types (available application types) and domain names (accessible domain names) that the preset device can use.
[0047] For example, in an enterprise, marketing department devices can access CRM systems, mail servers, and external social media sites; R&D department devices can access code repositories, development tools, and technical forums; and finance department devices can access financial management systems and bank websites, but not social media.
[0048] In a possible implementation, in determining the target NAT conversion method corresponding to the data packet according to a preset matching strategy, determining the traffic processing rules corresponding to the data packet according to application access control and domain name access control, specifically includes: determining whether the target application type is any one of the multiple available application types, and determining whether the target domain name information is any one of the multiple accessible domain names; if the target application type is any one of the multiple available application types and the target domain name information is any one of the multiple accessible domain names, then determining that the data packet meets the preset matching strategy.
[0049] Specifically, after the intelligent NAT device determines the available application types and accessible domain names of the preset device, it is necessary to determine whether the data packet meets the preset matching strategy based on the application access control and domain name access control policies to determine the corresponding NAT conversion method. The intelligent NAT device will determine whether the target application type of the data packet belongs to the range of available application types of the preset device. Available application types refer to the types of applications or services that are explicitly allowed to be used by the preset device in the device access control list in the preset matching policy, such as Web browsing, email, VoIP, etc. At the same time, the intelligent NAT device will also determine whether the target domain name of the data packet belongs to the range of accessible domain names of the preset device. Accessible domain names refer to the domain names of websites or servers that are explicitly allowed to be accessed by the device in the ACL, such as internal company websites, partner websites, etc. Only when the target application type and target domain name of the data packet meet the conditions at the same time, that is, they belong to the range of available application types and accessible domain names of the preset device respectively, will the intelligent NAT device consider that the data packet meets the preset matching strategy.
[0050] In a possible implementation, if the target application type is any one of multiple available application types and the target domain name information is any one of multiple accessible domain names, then after determining that the data packet meets the preset matching strategy, the method includes: obtaining the capture time of the data packet and using the capture time as the target time; determining the corresponding transmission bandwidth based on the target time and the target application type.
[0051] Specifically, after the intelligent NAT device determines that the data packet meets the preset matching strategy, it can further dynamically adjust its transmission bandwidth according to the capture time and application type of the data packet to achieve more refined traffic control and optimization. First, the intelligent NAT device will obtain the capture time of the data packet, that is, the time point when the device captures and starts processing the data packet. This time information can be obtained from the metadata of the data packet or the timestamp of the device. The intelligent NAT device will use this time as the "target time" of the data packet for subsequent transmission bandwidth determination. Secondly, the intelligent NAT device will query the pre-configured transmission bandwidth policy table from the preset matching strategy based on the target time and the target application type of the data packet. The transmission bandwidth policy table defines the transmission bandwidth that should be allocated to traffic of different application types in different time periods. The transmission bandwidth policy table is formulated by the network administrator based on the time pattern and application priority of network use. For example, the transmission bandwidth policy table can stipulate that during working hours (9:00-18:00), the transmission bandwidth of Web browsing applications is 10Mbps, while during non-working hours, the bandwidth can be increased to 20Mbps; for email applications, the transmission bandwidth is limited to 5Mbps throughout the day; and for real-time applications such as video conferencing, the transmission bandwidth is 20Mbps during working hours and reduced to 10Mbps during non-working hours. The intelligent NAT device will match the target time of the data packet with the time period in the transmission bandwidth policy table, and determine the corresponding transmission bandwidth according to the target application type of the data packet. Traffic of the same application type may obtain different transmission bandwidths in different time periods, thus realizing dynamic adjustment based on time.
[0052] For example, suppose the intelligent NAT device captures a data packet, and its capture time is "2023-05-10 14:30:00", and the target application type is web browsing. The device first matches the time with the policy table and finds that it belongs to the working time range. Then, the device searches the policy table for the transmission bandwidth corresponding to the web browsing application during working hours, and the result is 10Mbps. Therefore, the transmission bandwidth of the data packet is determined to be 10Mbps. For another example, if the capture time of the data packet is "2023-05-10 20:00:00", and the target application type is video conferencing, the intelligent NAT device will determine that it belongs to non-working hours, and search the policy table to obtain the transmission bandwidth corresponding to the video conferencing application during non-working hours is 10Mbps. Therefore, the transmission bandwidth of the data packet is determined to be 10Mbps.
[0053] Step S205: adjusting the flow direction of the data packet according to the flow processing rule.
[0054] In step S205, the flow rate of the traffic packet is adjusted according to the transmission bandwidth; and the source IP address and port number of the data packet are converted into corresponding public IPv4 addresses and port numbers.
[0055] Specifically, the intelligent NAT device performs address translation and flow control on the data packet according to the determined target NAT conversion method, and sends the converted data packet to the target network. First, the intelligent NAT device extracts the source IP address and port number of the data packet. The source IP address is usually the private IP address of the device sending the data packet in the internal network, such as 192.168.xx. The port number identifies the specific application or service on the device. Then, the intelligent NAT device converts the source IP address and port number into the corresponding public IPv4 address and port number according to the preset NAT conversion rules. These public IPv4 addresses and port numbers are the legal identification of the intelligent NAT device in the external network, and are used to represent the internal device to communicate with the outside world. The specific conversion process can be divided into the following situations: Static NAT translation: The intelligent NAT device pre-assigns a fixed public IP address to a specific private IP address of an internal device. When the private IP address is matched, the intelligent NAT device directly replaces it with the corresponding public IP address.
[0056] Dynamic NAT translation: The intelligent NAT device maintains a public IP address pool. When an internal device initiates a communication request, the intelligent NAT device dynamically allocates an available public IP address from the address pool and establishes a mapping relationship between the private IP address and the public IP address.
[0057] Port Address Translation (PAT): When public IP address resources are limited, intelligent NAT devices can use PAT to map the private IP addresses of multiple internal devices to different ports on the same public IP address. Intelligent NAT devices will modify the source port number of the data packet and record the correspondence between the private IP address, private port number and public port number.
[0058] Regardless of the conversion method used, the intelligent NAT device will replace the source IP address of the data packet with the assigned public IP address and modify the source port number as needed. In this way, the data packet is transmitted in the external network as a public IP address and port number, hiding the real information of the internal device. After completing the address translation, the intelligent NAT device will control the flow of the converted data packet according to the previously determined transmission bandwidth. The transmission bandwidth reflects the maximum network bandwidth that the data packet is allowed to occupy. The intelligent NAT device will ensure that it does not exceed the preset bandwidth limit by limiting the sending rate of the data packet. Finally, the intelligent NAT device will send the converted data packet to the target network with the preset transmission bandwidth. The target network can be the external public Internet or other subnets within the organization. The data packet will carry the converted public IP address and port number, follow the routing rules of the target network, and finally reach the target device.
[0059] For example, suppose the intelligent NAT device receives a data packet with a source IP address of 192.168.1.10, a source port number of 1234, and a target application type of Web browsing. The device first converts the source IP address to the pre-assigned public IP address 202.1.1.1, and modifies the source port number to 5678. Then, the device performs flow control on the converted data packet based on the preset transmission bandwidth of 10Mbps for the Web browsing application to ensure that its transmission rate does not exceed 10Mbps. Finally, the device sends the converted data packet to the target network with a source IP address of 202.1.1.1 and a source port number of 5678. The target device responds and communicates based on this information.
[0060] Reference Figure 3The present application also provides a flow control device involving NAT conversion, which is an intelligent NAT device, and the intelligent NAT device includes a capture module 301 and a processing module 302; the capture module 301 is used to capture the data packets flowing through; the processing module 302 is used to extract the data packets and obtain the corresponding target device identifier, and the target device identifier is the source address IP of the data packet; the processing module 302 is also used to identify the data packets and obtain the target application type and target domain name information corresponding to the data packets, the target application type is the specific application category or service category represented by the data packet, and the target domain name information is the domain name of the server that the user is about to access; the processing module 302 is also used to determine the corresponding preset matching strategy according to the target device identifier, the target application type and the target domain name information, and determine the flow processing rules corresponding to the data packets according to the preset matching strategy, and the preset matching strategy includes device access control, application access control, domain name access control and time flow control; the processing module 302 is also used to adjust the flow direction of the data packets according to the flow processing rules, and perform corresponding NAT conversion on the data packets.
[0061] In one possible implementation, the capture module 301 captures the data packets passing through, specifically including: the processing module 302 sets the network adapter of the network interface to a promiscuous mode; the processing module 302 monitors the data traffic on the network interface to capture the data packets passing through the network interface, the data packets including the data packets pointing to the MAC address of the network adapter; the processing module 302 stores the captured data packets.
[0062] In a possible implementation, the processing module 302 extracts the data packet to obtain the corresponding target device identifier, specifically including: the processing module 302 extracts the header information of the data packet to obtain the source address IP corresponding to the data packet, and the source address IP is the network address of the device sending the data packet.
[0063] In a possible implementation, the processing module 302 determines the traffic processing rules corresponding to the data packet according to the preset matching strategy, and determines the corresponding traffic processing rules corresponding to the data packet according to the device access control, specifically including: the processing module 302 determines whether the target device identifier is a preset device; if the target device identifier is a preset device, the processing module 302 determines multiple available application types and multiple accessible domain names corresponding to the preset device.
[0064] In a possible implementation, the processing module 302 determines the traffic processing rule corresponding to the data packet according to the preset matching strategy. The processing module 302 determines the traffic processing rule corresponding to the data packet according to application access control and domain name access control, specifically including: the processing module 302 determines whether the target application type is any one of multiple available application types, and determines whether the target domain name information is any one of multiple accessible domain names; if the target application type is any one of multiple available application types and the target domain name information is any one of multiple accessible domain names, the processing module 302 determines that the data packet meets the preset matching strategy.
[0065] In a possible implementation, if the target application type is any one of multiple available application types and the target domain name information is any one of multiple accessible domain names, then after the processing module 302 determines that the data packet meets the preset matching strategy, the method includes: the capture module 301 obtains the capture time of the data packet and uses the capture time as the target time; the processing module 302 determines the corresponding transmission bandwidth based on the target time and the target application type.
[0066] In a possible implementation, the processing module 302 adjusts the traffic direction of the data packet according to the traffic processing rule, and performs corresponding NAT conversion on the data packet, specifically including: the processing module 302 adjusts the traffic flow of the traffic packet according to the transmission bandwidth; the processing module 302 converts the source IP address and port number of the data packet into the corresponding public IPv4 address and port number.
[0067] It should be noted that: when the device provided in the above embodiment realizes its function, only the division of the above functional modules is used as an example. In actual application, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0068] The present application also provides an electronic device. Figure 4 , Figure 4 The electronic device 400 may include: at least one processor 401 , at least one network interface 404 , a user interface 403 , a memory 405 , and at least one communication bus 402 .
[0069] The communication bus 402 is used to realize the connection and communication between these components.
[0070] The user interface 403 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 403 may also include a standard wired interface and a wireless interface.
[0071] In one possible implementation, the network interface 404 may include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0072] Among them, the processor 401 may include one or more processing cores. The processor 401 uses various interfaces and lines to connect various parts in the entire server, and executes various functions of the server and processes data by running or executing instructions, programs, code sets or instruction sets stored in the memory 405, and calling data stored in the memory 405. Optionally, the processor 401 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 401 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 401, and it can be implemented separately through a chip.
[0073] Among them, the memory 405 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 405 includes a non-transitory computer-readable storage medium. The memory 405 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 405 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 405 may optionally also be at least one storage device located away from the aforementioned processor 401. Refer to Figure 4 , the memory 405 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program involving a traffic control method for NAT conversion.
[0074] exist Figure 4 In the electronic device 400 shown, the user interface 403 is mainly used to provide an input interface for the user and obtain the data input by the user; and the processor 401 can be used to call an application program stored in the memory 405 involving a flow control method for NAT conversion, and when executed by one or more processors 401, the electronic device 400 executes one or more of the methods described in the above embodiments. It should be noted that for the aforementioned method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described order of actions, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required for the present application.
[0075] The present application also provides a computer-readable storage medium, which stores instructions. When executed by one or more processors 401, the electronic device 400 executes one or more of the methods described in the above embodiments.
[0076] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0077] In the several embodiments provided in this application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0078] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0079] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0080] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: various media that can store program codes, such as USB flash drives, mobile hard drives, magnetic disks or optical disks.
[0081] The above is only an exemplary embodiment of the present disclosure and cannot be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure are still within the scope of the present disclosure. After considering the disclosure of the specification and the truth of practice, those skilled in the art will easily think of other embodiments of the present disclosure.
[0082] This application is intended to cover any variation, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art not described in the present disclosure. The description and examples are to be regarded as exemplary only, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A flow control method involving NAT conversion, characterized in that: The method comprises: Capture the packets passing through; Extract the data packet to obtain a corresponding target device identifier, where the target device identifier is the source IP address of the data packet; Identify the data packet to obtain target application type and target domain name information corresponding to the data packet, wherein the target application type is a specific application category or service category represented by the data packet, and the target domain name information is a domain name of a server that the user is about to access; Determine a corresponding preset matching strategy according to the target device identifier, the target application type and the target domain name information, and determine a flow processing rule corresponding to the data packet according to the preset matching strategy, wherein the preset matching strategy includes device access control, application access control, domain name access control and time flow control; The flow direction of the data packet is adjusted according to the flow processing rule.
2. The method according to claim 1, characterized in that The captured data packets specifically include: Set the network adapter of the network interface to promiscuous mode; Monitoring data traffic on the network interface to capture data packets passing through the network interface, the data packets including data packets directed to the MAC address of the network adapter; The captured data packets are stored.
3. The method according to claim 1, characterized in that The extracting of the data packet to obtain the corresponding target device identification specifically includes: The header information of the data packet is extracted to obtain the source IP address corresponding to the data packet, where the source IP address is the network address of the device sending the data packet.
4. The method according to claim 1, characterized in that In the determining the traffic processing rule corresponding to the data packet according to the preset matching strategy, determining the traffic processing rule corresponding to the data packet according to the device access control specifically includes: Determine whether the target device identifier is a preset device; If the target device is identified as a preset device, determining a plurality of available application types and a plurality of accessible domain names corresponding to the preset device; If the target device is not identified as a preset device, traffic forwarding of the data packet is prohibited.
5. The method according to claim 4, characterized in that In the determining the traffic processing rule corresponding to the data packet according to the preset matching strategy, the traffic processing rule corresponding to the data packet is determined according to application access control and domain name access control, specifically including: Determine whether the target application type is any one of the multiple available application types, and determine whether the target domain name information is any one of the multiple accessible domain names; If the target application type is any one of the multiple available application types and the target domain name information is any one of the multiple accessible domain names, it is determined that the data packet meets the preset matching strategy.
6. The method according to claim 1, characterized in that If the target application type is any one of the multiple available application types and the target domain name information is any one of the multiple accessible domain names, after determining that the data packet meets the preset matching strategy, the method includes: Obtaining the capture time of the data packet, and using the capture time as the target time; A corresponding transmission bandwidth is determined according to the target time and the target application type.
7. The method according to claim 6, characterized in that The adjusting the flow direction of the data packet according to the flow processing rule and performing corresponding NAT conversion on the data packet specifically includes: According to the transmission bandwidth, adjusting the flow rate of the traffic packet; The source IP address and port number of the data packet are converted to a corresponding public IPv4 address and port number.
8. A flow control device involving NAT conversion, characterized in that: The device comprises: a capturing module (201) and a processing module (202); The capture module (201) is used to capture the data packets flowing through; The processing module (202) is used to extract the data packet to obtain a corresponding target device identifier, where the target device identifier is the source IP address of the data packet; The processing module (202) is further used to identify the data packet and obtain the target application type and target domain name information corresponding to the data packet, wherein the target application type is the specific application category or service category represented by the data packet, and the target domain name information is the domain name of the server that the user is about to access; The processing module (202) is further used to determine a corresponding preset matching strategy according to the target device identifier, the target application type and the target domain name information, and determine a flow processing rule corresponding to the data packet according to the preset matching strategy, wherein the preset matching strategy includes device access control, application access control, domain name access control and time flow control; The processing module (202) is also used to adjust the flow direction of the data packet according to the flow processing rule.
9. An electronic device, characterized in that: The electronic device (300) comprises a processor (301), a memory (305), a user interface (303) and a network interface (304), wherein the memory (305) is used to store instructions, the user interface (303) and the network interface (304) are used to communicate with other devices, and the processor (301) is used to execute the instructions stored in the memory (305) so that the electronic device (300) executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and when the instructions are executed, the method according to any one of claims 1 to 7 is executed.
