Agent-based NAT (Network Address Translation) method and system
By adopting the proxy-based NAT conversion method in the industrial environment, using the proxy service program to detect reachability and forwarding bidirectional messages, the problem of external network host communication failure when the internal network device does not have a gateway address is solved, improving user experience and Degree of intelligence.
Patent Information
- Application Number
- CN202411192961.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-10-29
AI Technical Summary
In an industrial environment, when the internal network device is not configured with a gateway address, the external network host cannot actively establish communication with the internal network device. The existing NAT address translation method cannot meet the needs, resulting in communication failure and poor user experience.
The proxy-based NAT conversion method is used to establish port mapping from the external network to multiple proxy service programs in the gateway to detect the reachability of the internal and external hosts, and perform bidirectional packet forwarding after the identity authentication is passed to ensure External network hosts can actively communicate with internal network devices.
It realizes that the external network host can actively communicate with the internal network equipment without setting the gateway address, which improves the intelligence and user experience.
Smart Images

Figure CN118869652A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of communication networks, and in particular relates to a NAT conversion method and system based on a proxy. Background Art
[0002] NAT technology is used to convert intranet addresses and port numbers into legal external network addresses and port numbers, and establish a session to communicate with external hosts. Hosts outside the NAT cannot actively communicate with hosts inside the NAT, but must actively communicate with an IP address on the external network. The NAT gateway is responsible for establishing a mapping relationship to achieve data forwarding.
[0003] However, in an industrial environment, when the intranet device is not configured with a gateway address, the external host needs to actively establish communication with the intranet device. The existing NAT address conversion method cannot meet the demand and is therefore in urgent need of improvement. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the purpose of the present invention is to provide a proxy-based NAT conversion method and system, aiming to solve the problem that the prior art cannot provide an effective proxy-based NAT conversion method, resulting in the intranet device not being configured with a gateway address. Even if the NAT gateway is set up with port mapping and routing tables, the external network host actively initiates communication, the message cannot reach the intranet device, communication cannot be established, and the user experience is poor.
[0005] On the one hand, the present invention provides a proxy-based NAT conversion method, the method comprising the following steps:
[0006] Establish port mapping from external network to multiple proxy service programs in the gateway;
[0007] The messages sent by multiple external network hosts are sent to the corresponding proxy service programs through port mapping by the gateway;
[0008] The proxy service program detects the reachability between the intranet host and the extranet host; the reachability includes: reachable and unreachable;
[0009] If the proxy service program is unreachable with the intranet host or the extranet host, an alarm is issued;
[0010] If the proxy service program is reachable with both the intranet host and the extranet host, bidirectional message forwarding is performed.
[0011] Furthermore, before the bidirectional message forwarding is performed, the method includes:
[0012] The external network host is authenticated, and if the external network host passes the identity authentication, bidirectional message forwarding is performed, otherwise the message is discarded.
[0013] Preferably, before the identity authentication of the external network host, the method includes: presetting the identity information of the external network host;
[0014] The identity information of the external network host includes: one or more of an IP address, a MAC address, and an identification key.
[0015] Preferably, the preset identity information of the external network host includes:
[0016] A port mapping from the external network to the management port of the proxy service program is established in the gateway, and the identity information is added to the management port of the proxy service program by logging into the web page.
[0017] Furthermore, the bidirectional message forwarding includes:
[0018] The proxy service program is reachable to the intranet host, and the proxy service program receives a message sent by the external network host and forwards it to the corresponding intranet host;
[0019] The proxy service program is reachable to the external network host, and the proxy service program receives a message sent by the internal network host and then forwards it to the corresponding external network host.
[0020] Further, the proxy service program detects the reachability between the intranet host and the reachability between the extranet host and includes:
[0021] The proxy service program pings the corresponding intranet host or tcpings the corresponding intranet host port, and the proxy service program pings the corresponding extranet host or tcpings the corresponding extranet host port;
[0022] If the delay of the proxy service program pinging the corresponding intranet host or the delay of the port of the intranet host tcping is lower than the rated delay, the proxy service program and the intranet host are reachable, otherwise they are not reachable;
[0023] If the delay of the proxy service program pinging the corresponding external host or the delay of the port of the external host tcping corresponding to the external host is lower than the rated delay, the proxy service program and the external host are reachable, otherwise they are unreachable.
[0024] Preferably, the proxy service program runs in the gateway or in a bypass host.
[0025] Preferably, establishing a port mapping from the external network to the proxy service program in the gateway includes:
[0026] Establish a port mapping in the gateway from the external network address and port number to the internal network address and port number of the proxy service program, or establish a port mapping in the gateway from the external network port number to the internal network address and port number of the proxy service program;
[0027] The proxy service program receives a message sent by an external network host and then forwards it to a corresponding internal network host, including: the proxy service program receives a message sent by an external network host and then modifies the source and target IP addresses and port numbers of the message and then sends it to the corresponding internal network host;
[0028] The proxy service program receives a message sent by the intranet host and then forwards it to the corresponding extranet host, including: the proxy service program receives a message sent by the intranet host and then modifies the message source and target IP address and port number and then sends it to the corresponding extranet host.
[0029] On the other hand, the present invention also provides a proxy-based NAT conversion system, the system comprising at least one processor; and
[0030] a memory communicatively connected to the at least one processor; wherein,
[0031] The memory stores instructions that can be executed by the at least one processor. The instructions are executed by the at least one processor so that the at least one processor can perform the above-mentioned proxy-based NAT conversion method.
[0032] On the other hand, the present invention also provides a non-volatile computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by one or more processors, the one or more processors can execute the above-mentioned proxy-based NAT conversion method.
[0033] The beneficial effects of the present invention are as follows: port mapping from the external network to multiple proxy service programs is established in the gateway; messages sent by multiple external network hosts are sent to corresponding proxy service programs through port mapping via the gateway; the proxy service program detects the accessibility between the internal network host and the external network host; the accessibility includes: reachable and unreachable; if the proxy service program is unreachable between the internal network host and the external network host, an alarm is issued; if the proxy service program is reachable between the internal network host and the external network host, two-way message forwarding is performed; thereby, when the internal and external hosts do not set the gateway address, the external network host can actively initiate communication and reach the inside and outside, thereby improving the degree of intelligence and further improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1It is a flow chart of the implementation of the proxy-based NAT conversion method provided in the first embodiment of the present invention;
[0035] Figure 2 It is a structural diagram of a proxy-based NAT conversion system provided in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0037] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments:
[0038] Embodiment 1:
[0039] Figure 1 The implementation process of the proxy-based NAT conversion method provided in the first embodiment of the present invention is shown. For the convenience of explanation, only the part related to the embodiment of the present invention is shown, which is described in detail as follows:
[0040] In step S101, a port mapping from an external network to multiple proxy service programs is established in the gateway;
[0041] In an embodiment of the present invention, establishing a port mapping from an external network to a proxy service program in a gateway includes:
[0042] A port mapping is established in the gateway from the external network address and port number to the internal network address and port number of the proxy service program. When there is a fixed public network IP, a port mapping is established in the gateway from the external network port number to the internal network address and port number of the proxy service program. This is applicable to the case of a dynamic public network IP. Furthermore, the proxy service program can also perform dynamic domain name resolution to adapt to the case of a dynamic public network IP, so that the proxy service program can be accessed through the domain name, thereby improving the degree of intelligence and reducing costs.
[0043] The proxy service program receives the message sent by the external network host and then forwards it to the corresponding internal network host, including: the proxy service program receives the message sent by the external network host, modifies the source and target IP addresses and port numbers of the message, and then sends it to the corresponding internal network host;
[0044] The proxy service program receives the message sent by the internal network host and then forwards it to the corresponding external network host, including: the proxy service program receives the message sent by the internal network host, modifies the source and target IP addresses and port numbers of the message, and then sends it to the corresponding external network host.
[0045] Further preferably, the proxy service program runs in the gateway or in the bypass host.
[0046] In step S102, the messages sent by multiple external network hosts are sent to the corresponding proxy service programs through port mapping by the gateway;
[0047] In the embodiment of the present invention, different ports are used to forward messages through different proxy service programs;
[0048] In step S103, the proxy service program detects the reachability between the intranet host and the extranet host;
[0049] In the embodiment of the present invention, the reachability includes: reachable and unreachable; the proxy service program detects the reachability between the intranet host and the reachability between the extranet host and includes:
[0050] The proxy service program pings the corresponding intranet host or tcpings the corresponding intranet host port, and the proxy service program pings the corresponding extranet host or tcpings the corresponding extranet host port;
[0051] If the delay of the proxy service program pinging the corresponding intranet host or the delay of the port of the corresponding intranet host through tcping is lower than the rated delay, the proxy service program and the intranet host are reachable, otherwise they are unreachable;
[0052] If the delay of the proxy service program pinging the corresponding external host or the delay of the port of the external host using tcping is lower than the rated delay, the proxy service program and the external host are reachable, otherwise they are unreachable.
[0053] In step S104, if the proxy service program is unreachable with the intranet host and the extranet host, an alarm is issued;
[0054] In the embodiment of the present invention, for example, the proxy service program sends an unreachable alarm reminder to a specific server or intelligent terminal.
[0055] In step S105, if the proxy service program is reachable with both the intranet host and the extranet host, bidirectional message forwarding is performed.
[0056] In the embodiment of the present invention, before forwarding the bidirectional message, the process includes: performing identity authentication on the external network host, and if the identity authentication of the external network host passes, bidirectional message forwarding is performed, otherwise the message is discarded.
[0057] Before authenticating the external network host, the following steps are included: presetting the identity information of the external network host;
[0058] The identity information of the external host includes: one or more of an IP address, a MAC address, and an identification key.
[0059] Presetting the identity information of the external network host includes: establishing a port mapping from the external network to the management port of the proxy service program in the gateway, and adding identity information to the management port of the proxy service program when logging in to the proxy service program via a web page. Among them, identity authentication is performed when logging in to the proxy service program via a web page;
[0060] Furthermore, the bidirectional message forwarding includes:
[0061] The proxy service program is reachable to the intranet host. The proxy service program receives the message sent by the external host and forwards it to the corresponding intranet host.
[0062] The proxy service program is reachable to the external network host. The proxy service program receives the message sent by the internal network host and forwards it to the corresponding external network host.
[0063] In an embodiment of the present invention, port mapping from the external network to multiple proxy service programs is established in the gateway; messages sent by multiple external network hosts are sent to corresponding proxy service programs through port mapping through the gateway; the proxy service program detects the reachability between the internal network host and the external network host; the reachability includes: reachable and unreachable; if the proxy service program is unreachable between the internal network host and the external network host, an alarm is issued; if the proxy service program is reachable between the internal network host and the external network host, two-way message forwarding is performed; thereby, when the internal and external hosts do not set the gateway address, the external network host can actively initiate communication and reach the inside and outside, thereby improving the degree of intelligence and further improving the user experience.
[0064] Embodiment 2:
[0065] Figure 2 A NAT conversion system based on a proxy provided by the second embodiment of the present invention is shown. Figure 2 As shown, the device 10 comprises:
[0066] One or more processors 110 and memory 120, Figure 2 A processor 110 is used as an example for description. The processor 110 and the memory 120 may be connected via a bus or other means. Figure 2 The example of connecting through bus is taken in the following.
[0067] The processor 110 is used to complete various control logics of the device 10, and it can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn RISCMachine) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or any combination of these components. In addition, the processor 110 can also be any traditional processor, microprocessor or state machine. The processor 110 can also be implemented as a combination of computing devices, for example, a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration.
[0068] The memory 120, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions corresponding to the proxy-based NAT conversion method in the embodiment of the present invention. The processor 110 executes various functional applications and data processing of the device 10 by running the non-volatile software programs, instructions and units stored in the memory 120, that is, implementing the proxy-based NAT conversion method in the above method embodiment.
[0069] The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store applications required for operating the device and at least one function; the data storage area may store data created according to the use of the device 10, etc. In addition, the memory 120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 120 may optionally include a memory remotely arranged relative to the processor 110, and these remote memories may be connected to the device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0070] One or more units are stored in the memory 120, and when executed by one or more processors 110, the proxy-based NAT conversion method in any of the above method embodiments is executed, for example, the above described NAT conversion method is executed. Figure 1 The method comprises steps S101 to S105.
[0071] Embodiment three:
[0072] Embodiment 3 of the present invention provides a non-volatile computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors, for example, to execute the above-described Figure 1 The method comprises steps S101 to S105.
[0073] As an example, the non-volatile storage medium can include a read-only memory (ROM), a programmable ROM (PROM), an electrically programmable ROM (EPROM), an electrically erasable ROM (EEPROM), or a flash memory. Volatile memory can include a random access memory (RAM) as an external cache memory. By way of illustration and not limitation, RAM can be obtained in many forms such as synchronous RAM (SRAM), dynamic RAM, (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and direct Rambus RAM (DRRAM). The disclosed memory components or memories of the operating environment described herein are intended to include one or more of these and / or any other suitable types of memory.
[0074] What has been described herein in this specification and the accompanying drawings includes examples that can provide a proxy-based NAT conversion method and system. Of course, it is not possible to describe every conceivable combination of elements and / or methods for the purpose of describing the various features of the present disclosure, but it can be recognized that many other combinations and permutations of the disclosed features are possible. Therefore, it is obvious that various modifications can be made to the present disclosure without departing from the scope or spirit of the present disclosure. In addition, or in an alternative, other embodiments of the present disclosure may be apparent from consideration of this specification and the accompanying drawings and from the practice of the present disclosure as presented herein. It is intended that the examples proposed in this specification and the accompanying drawings are considered to be illustrative and not restrictive in all respects. Although specific terms are employed in this article, they are used in a general and descriptive sense and are not used for limiting purposes.
Claims
1. A NAT conversion method based on proxy, It is characterized in that The method comprises the following steps: Establish port mapping from external network to multiple proxy service programs in the gateway; The messages sent by multiple external network hosts are sent to the corresponding proxy service programs through port mapping by the gateway; The proxy service program detects the reachability between the intranet host and the extranet host; The reachability includes: reachable and unreachable; If the proxy service program is unreachable with the intranet host or the extranet host, an alarm is issued; If the proxy service program is reachable with both the intranet host and the extranet host, bidirectional message forwarding is performed.
2. The method according to claim 1, It is characterized in that Before the two-way message forwarding is performed, the method includes: The external network host is authenticated, and if the external network host passes the identity authentication, bidirectional message forwarding is performed, otherwise the message is discarded.
3. The method according to claim 2, It is characterized in that Before the identity authentication of the external network host, the steps include: presetting the identity information of the external network host; The identity information of the external network host includes: one or more of an IP address, a MAC address, and an identification key.
4. The method according to claim 3, It is characterized in that The preset identity information of the external network host includes: A port mapping from the external network to the management port of the proxy service program is established in the gateway, and the identity information is added to the management port of the proxy service program by logging into the web page.
5. The method according to claim 1, It is characterized in that The bidirectional message forwarding includes: The proxy service program is reachable to the intranet host, and the proxy service program receives a message sent by the external network host and forwards it to the corresponding intranet host; The proxy service program is reachable to the external network host, and the proxy service program receives a message sent by the internal network host and then forwards it to the corresponding external network host.
6. The method according to claim 1, It is characterized in that The proxy service program detects the reachability between the intranet host and the reachability between the extranet host and the intranet host, including: The proxy service program pings the corresponding intranet host or tcpings the corresponding port of the intranet host, and the proxy service program pings the corresponding extranet host or tcpings the corresponding port of the extranet host; If the delay of the proxy service program pinging the corresponding intranet host or the delay of the port of the intranet host corresponding to tcping is lower than the rated delay, the proxy service program and the intranet host are reachable, otherwise they are not reachable; If the delay of the proxy service program pinging the corresponding external host or the delay of the port of the external host tcping corresponding to the proxy service program is lower than the rated delay, the proxy service program and the external host are reachable, otherwise they are unreachable.
7. The method according to claim 1, It is characterized in that The proxy service program runs in the gateway or in a bypass host.
8. The method according to claim 1, It is characterized in that The port mapping from the external network to the proxy service program is established in the gateway including: Establish a port mapping in the gateway from the external network address and port number to the internal network address and port number of the proxy service program, or establish a port mapping in the gateway from the external network port number to the internal network address and port number of the proxy service program; The proxy service program receives a message sent by an external network host and then forwards it to a corresponding internal network host, including: the proxy service program receives a message sent by an external network host and then modifies the source and target IP addresses and port numbers of the message and then sends it to the corresponding internal network host; The proxy service program receives a message sent by the intranet host and then forwards it to the corresponding extranet host, including: the proxy service program receives a message sent by the intranet host and then modifies the message source and target IP address and port number and then sends it to the corresponding extranet host.
9. A NAT conversion system based on proxy, It is characterized in that The system includes at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the proxy-based NAT conversion method according to any one of claims 1 to 7.
10. A non-volatile computer-readable storage medium, It is characterized in that The non-volatile computer-readable storage medium stores computer-executable instructions, which, when executed by one or more processors, enable the one or more processors to execute the proxy-based NAT conversion method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for guaranteeing network address translation and reachability of internal local address
CN101127720A
Data communication method, device and system based on internal and external networks
CN107257345A
Intranet and extranet communication method, device and system, proxy server and storage medium
CN110266713A
User Access system using proxies for accessing a network
US20020078371A1
Cited By
Intranet service management system and method
CN119484471A
