Network address translation (NAT) generally refers to mapping or translation of Internet Protocol (IP) addresses of one address realm to another to allow devices in one network to communicate with devices on a different network. For example, in a home local area network (LAN), NAT is used for mapping a number of private IP addresses to a single public IP address supplied by an Internet Service Provider (ISP). This allows computers on the LAN to share a single Internet connection, and helps slow down the exhaustion of public IP addresses. If an application layer of an incoming or outgoing packet contains address information, then application layer gateway (ALG) processing is also required to translate private network addresses in the application layer into public network addresses.
By way of non-limiting example(s), a method, network device and computer program product for communication between a private network and a public network will be described with reference to the following drawings, in which:
The public network 140 may be a wide area network (WAN) such as the Internet and the private network 120 a local area network (LAN) etc. The public network 140 has an address realm with unique network addresses assigned by an address registry, such as the Internet Assigned Numbers Authority (LANA) etc. The private network 120 has a private address realm that is independent of the address realm of the public network.
In the example in
The network device 110 may be any device with suitable processing capabilities, such as a router, switch or bridge etc. Although one uplink router 140 and one server 150 are shown in
Referring also to
Configuration of First Devices (See Block 210):
Transmission of Outgoing Packets (See Blocks 220 and 230):
Transmission of Incoming Packets (See Blocks 240, 250 and 260):
According to the example method in
According to the example method in
Non-limiting examples of the method performed by the network device 110 in
If the network device 110 has multiple local area network (LAN) interfaces (e.g. in
If the private network is a small private network 120, such as a home network, communication between hosts 122 is generally minimal, and the main traffic in the network 120 is to access Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) applications, such as web applications and Simple Mail Transfer Protocol (SMTP).
In one example, dynamic host configuration protocol (DHCP) is used by the first devices 122 for requesting configuration, and by the network device 110 for delivering configuration information to the first devices 122.
At block 320 in
In response to the DHCP request message, the network device 110 assigns a public network IP address and a port number range to the first device 122. To minimise public network IP address consumption, a common public network IP address is assigned to the first devices 122 in the private network 120. The port number range, however, uniquely identifies the first device 122 in the private network 120.
A port is generally associated with an IP address of the host as well as the type of protocol used for communication, such as TCP and UDP. A port is identified by a port number, which is generally a 16-bit number. The minimum size of the port number range is one (in which case a single port number is assigned).
Further, the network device 110 assigns the first device 122 an IP address of a DHCP server and an IP address of a gateway of the first device 122. The IP addresses should be different to the public network IP address assigned for communication with the public network 140.
In one example, the public network IP address of the uplink router 130 is used as the IP addresses of the DHCP server and gateway. In another example, a second public network IP address (which is different to the assigned public network IP address) is configured on the network device 110 and used as the IP addresses of the DHCP server and gateway.
At block 330 in
At block 340 in
In the example in
Referring also to
In response, the network device 110 assigns configuration information to host A, and returns a DHCP response message with the following parameters; see also 420:
(i) a public network address (e.g. 20.1.1.2, which is the IP address of network device 110);
(ii) a port number range (e.g. 1024-2047);
(iii) an IP addresses of a DHCP sever and a gateway (e.g. 20.1.1.1, which is the IP address of the uplink router 130).
The network device 110 then stores the configuration information; see also 430. In one example, the configuration information may be stored is the form of an entry in a DHCP lease table, as follows:
Configuration information of host B may be assigned in a similar manner. Referring now to
In response, the network device 110 assigns configuration information to host B, and returns a DHCP response message with the following parameters; see also 520:
(i) a public network address (e.g. 20.1.1.2, which is the IP address of network device 110);
(ii) a port number range (e.g. 2048-3071);
(iii) an IP addresses of a DHCP sever and a gateway (e.g. 20.1.1.1, which is the IP address of the uplink router 130).
The network device 110 then stores the configuration information of host B as follows; see also 530:
In the examples in
The network device 110 also serves as a proxy for address resolution protocol (ARP) to resolve network layer IP addresses of the DHCP server and the gateway into link layer MAC addresses.
At block 350 in
In one example, the IP address of the DHCP server is the same as the IP address of the gateway, in which case the first device 122 only needs to send one ARP request message to the network device 110. In this case, only one ARP request is required because the MAC address of the DHCP server is the same as that of the gateway. A virtual MAC address of a LAN interface 124 of the network device 110 may be used as the MAC address of the DHCP server and gateway of the first device 110.
For example in
When the first device 122 sends a DHCP message, the MAC address of the DHCP server will be used as a destination MAC address. When the first device 110 sends a packet (e.g. TCP or UDP) to the public network 140, the MAC address of the gateway will be used as a destination MAC address. This way, the network device 110 will receive any subsequent DHCP messages and packets sent by the first device 122.
Following configuration according to block 210 in
More specifically, at block 220 in
Other information carried by the packet includes:
Upon receiving the packet from the first device 122, the network device 110 can forward the packet to the server 142 via the uplink router 130; see 230. The packet is forwarded without having to modify the source IP address and source port number of the packet.
In the example in
Similarly, in the example in
Since the source IP address (20.1.1.2) of the packet is already a public network IP address and the port number (1047 or 2048) unique identifies the host (A or B), the network device 110 does not have to perform any address and port number translation.
At block 240, the network device 110 receives an incoming packet from the second device 142 in the public network 140 that is intended for a first device 122 in the private network 120.
The incoming packet carries a destination IP address (the public network IP address assigned by the network device 110 to the first device 122) and a destination port number.
Based on the destination port number, the network device 110 determines whether a first device 122 in the private network 120 is assigned with the destination port number; see block 250. If the determination is affirmative, the incoming packet is forwarded to the first device 122 without requiring any address and port translation; see block 260.
In particular, the network device 110 searches the configuration information to determine whether the destination port number is within a port number range assigned to a first device 122. If yes, the packet is forwarded to the first device based on its MAC address and LAN interface identifier in the configuration information.
In the example in
In this case, host A is identified as the intended recipient because the destination port number (1024) is within its assigned port number range (1024-2047). As such, the network device 110 forwards the packet to host A according to the LAN interface (LAN INTFC1) and MAC address (0-0-1) of host A; see 495.
Similarly, in the example in
In this case, host B is identified as the intended recipient because the destination port number (2048) is within its assigned port number range (2048-3071). Accordingly, the network device 110 forwards the packet to host B according to the LAN interface (LAN INTFC2) and MAC address (0-0-2) of host B; see 595.
The above examples can be implemented by hardware, software or firmware or a combination thereof. Referring to
The processor 610 implements functional units in the form of a receiving unit 612, a processing unit 614, and a transmission unit 616. Information may be transmitted and received via the network interface device 630, which may include one or more logical or physical ports that connect the device 600 to another network device.
In case of a device 600 capable of acting as a “network device” 110:
In case of a device capable of acting as a “first device” 122:
For example, the various methods, processes and functional units described herein may be implemented by the processor 610. The term ‘processor’ is to be interpreted broadly to include a CPU, processing unit, ASIC, logic unit, or programmable gate array etc. The processes, methods and functional units may all be performed by a single processor 610 or split between several processors (not shown in
Although one network interface device 630 is shown in
The processes, methods and functional units may be implemented as machine-readable instructions executable by one or more processors, hardware logic circuitry of the one or more processors or a combination thereof. In the example in
Further, the processes, methods and functional units described in this disclosure may be implemented in the form of a computer program product. The computer program product is stored in a computer-readable storage medium and comprises a plurality of computer-readable instructions for making a device 600 (which can be a personal computer, a server or a network device such as a router, switch, bridge, host, access point etc.) implement the methods recited in the examples of the present disclosure.
The figures are only illustrations of an example, wherein the units or procedure shown in the figures are not necessarily essential for implementing the present disclosure. Those skilled in the art will understand that the units in the device in the example can be arranged in the device in the examples as described, or can be alternatively located in one or more devices different from that in the examples. The units in the examples described can be combined into one module or further divided into a plurality of sub-units.
Although the flowcharts described show a specific order of execution, the order of execution may differ from that which is depicted. For example, the order of execution of two or more blocks may be changed relative to the order shown. Also, two or more blocks shown in succession may be executed concurrently or with partial concurrence. All such variations are within the scope of the present disclosure.
It will be appreciated that numerous variations and/or modifications may be made to the processes, methods and functional units as shown in the examples without departing from the scope of the disclosure as broadly described. The examples are, therefore, to be considered in all respects as illustrative and not restrictive.
Number | Date | Country | Kind |
---|---|---|---|
201110152879.8 | Jun 2011 | CN | national |