METHOD FOR ALLOCATING AN EXTERNAL NETWORK IP ADDRESS IN NAT TRAVERSAL, AND DEVICE AND SYSTEM

Information

  • Patent Application
  • 20130227170
  • Publication Number
    20130227170
  • Date Filed
    April 09, 2013
    11 years ago
  • Date Published
    August 29, 2013
    11 years ago
Abstract
Embodiments of the present disclosure provide a method for allocating an external network IP address in NAT traversal, and a device and a system. The method includes: receiving a request message sent by a client and is for establishing a NAT mapping entry corresponding to a connection, where the request message includes a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application; and when the NAT mapping entry is established according to the received request message, allocating, according to the designated external network IP address in the request message, an IP address which is the same as the designated external network IP address and used as an external network IP address of the NAT mapping entry to be established.
Description
FIELD

The present disclosure relates to the field of communications, and in particular, to a method for allocating an external network Internet protocol (IP) address in NAT traversal, and a device and a system.


BACKGROUND

Currently, almost all of IPv4 addresses are allocated, and a problem of IP (Internet Protocol) address shortage is very serious. The industry generally thinks that IPv6 is a fundamental way to solve the problem. However, the progress of IPv6 deployment is not ideal; therefore, IPv6 cannot solve the problem of the address shortage in a short term. In a short term, deployment of NAT (network address translation) in a carrier network (CGN, carrier-grade NAT) is an effective way to temporarily alleviate the problem of the address shortage.


However, the deployment of the NAT in the carrier network will bring many problems, especially with respect to NAT traversal. A main problem in the NAT traversal is that, payloads of some communication protocol packets carries IP addresses; however, only an address in a packet header is modified in common NAT translation. As a result, a communication protocol cannot work normally. Impacted communication protocols are FTP (File Transfer Protocol) and SIP (Session Initiation Protocol).


A method for solving a problem of the NAT traversal is to use an application layer gateway (ALG), which, however, is not a mainstream manner. At present, the PCP (Pinhole Control Protocol) protocol is usually used to implement the NAT traversal. As shown in FIG. 1, in the PCP protocol, a client sends a PCP server side a request, requesting opening an external network port number (ex-port). If a PCP server checks and finds that the port is not used, the PCP server establishes a NAT mapping entry: an internal network IP (in-ip)+an internal network port number (in-port) and an external network IP (ex-ip)+an external network port number (ex-port), and at the same time the PCP server returns, to the client, information about the external network IP and the external network port number. When an application of the client needs to advertise its own IP and port number to a network, the application advertises its own external network IP (ex-ip) and external network port number (ex-port). Other network nodes may use the external network IP and the external network port number as a destination address and a destination port number, and actively initiate access to the client. A NAT device translates a packet according to a NAT mapping entry which is established during PCP negotiation, so as to translate the external network IP and the external network port number into an internal network IP and an internal network port number; and performs reverse translation when the client needs to send a packet to other nodes. Disadvantages in implementing the NAT traversal by the existing PCP protocol are: In NAT in a carrier network (CGN), usually one external network IP address pool is used, and the address pool includes multiple IP addresses. When an application needs to establish one connection, the NAT device selects one IP and one port to establish a NAT mapping entry. When the same application establishes multiple connections, the existing PCP protocol cannot ensure that external network IP addresses of the multiple connections are the same, thereby causing that the application cannot transmit data correctly or is vulnerable to a network attack.


SUMMARY

Implementation manners of the present disclosures provide a method for allocating an external network IP address in NAT traversal, and a device and a system, so as to keep external network IP addresses consistent after multiple connections of a same application pass through a NAT device, thereby improving an adaptive capability of a NAT traversal protocol to an existing application, and well solving a problem caused by inconsistency of external network IP addresses after multiple connections of a same application pass through the NAT device.


An embodiment of the present disclosure provides a method for allocating an external network IP address in NAT traversal, including: receiving a request message which is sent by a client and is for establishing a NAT mapping entry corresponding to a connection, where the request message includes a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application of the client; and when the NAT mapping entry is established according to the received request message, allocating, according to the designated external network IP address in the request message, an IP address which is the same as the designated external network IP address and used as an external network IP address in a NAT mapping entry to be established.


An embodiment of the present disclosure further provides a method for allocating an external network IP address in NAT traversal, including: designating an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application; where the designated external network IP address enables the NAT device to: when the NAT mapping entry is established according to the request message, allocate, according to the designated external network IP address, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the NAT device; and sending the NAT device the request message including the designated external network IP address.


An embodiment of the present disclosure further provides a NAT device, including: a receiving unit, configured to receive a request message which is sent by a client and is for establishing a NAT mapping entry corresponding to a connection, where the request message includes a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application of the client; an establishment unit, configured to establish the NAT mapping entry corresponding to the connection according to the request message received by the receiving unit; and an allocation unit, configured to, when the establishment unit establishes the NAT mapping entry according to the received request message, allocate, according to the designated external network IP address in the request message received by the receiving unit, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the establishment unit.


An embodiment of the present disclosure further provides a communication device, including: a setting unit, configured to designate an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application on the communication device; and a sending unit, configured to send the NAT device the request message including the external network IP address designated by the setting unit.


An embodiment of the present disclosure further provides a communication device, including: a setting unit, configured to designate an index value in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where an external network IP address in an IP address index table corresponding to the designated index value is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application on the communication device; and a sending unit, configured to send the NAT device the request message including the index value designated by the setting unit.


An embodiment of the present disclosure further provides a NAT system, including: a client device and a server side device, where the foregoing communication device is adopted as the client device, and the foregoing NAT device is adopted as the server side device.


From the solutions provided in the foregoing embodiments of the present disclosure, it can be seen that, in the embodiments of the present disclosure, when the NAT mapping entry is established, and according to the designated external network IP address in the received request message sent by the client, the IP address which is the same as the external network IP address is allocated and used as an external network IP address in the NAT mapping entry to be established. Furthermore, the designated external network IP address in the received request message sent by the client is the same as an external network IP address in a NAT mapping entry corresponding to a connection already established by the same application. In this way, a problem which occurs frequently in an existing NAT traversal solution and is that an application cannot work normally or is vulnerable to a network attack because external network IP addresses of multiple connections of a same application are different after NAT traversal is well solved. This method significantly improves the adaptive capability of the NAT traversal protocol to the existing application and enhances the performance of a NAT device.





BRIEF DESCRIPTION OF THE DRAWINGS

To illustrate solutions in embodiments of the present disclosure or in the prior art more clearly, accompanying drawings to be used for describing the embodiments or the prior art are introduced briefly in the following. Apparently, the accompanying drawings in the following description are only some embodiments of the present disclosure, and a person having ordinary skill in the art can derive other drawings from these accompanying drawings without making creative efforts.



FIG. 1 is a schematic diagram of implementing NAT traversal by the PCP protocol in the prior art;



FIG. 2 is a schematic diagram of implementing, by using the PCP protocol, NAT traversal in an FTP application in the prior art;



FIG. 3 is a flow chart of a method according to Embodiment 1 of the present disclosure;



FIG. 4 is a schematic diagram of applying the method to the PCP protocol according to Embodiment 1 of the present disclosure;



FIG. 5 is a schematic diagram of implementing, by using the PCP protocol, NAT traversal in an FTP application according to Embodiment 2 of the present disclosure;



FIG. 6 is a schematic diagram of implementing, by using the PCP protocol, the NAT traversal in the FTP application when IP address allocation fails according to Embodiment 2 of the present disclosure;



FIG. 7 is a flow chart of a method according to Embodiment 3 of the present disclosure;



FIG. 8 is a structural block diagram of a NAT device according to Embodiment 4 of the present disclosure;



FIG. 9 is a structural block diagram of an allocation unit of the NAT device according to Embodiment 4 of the present disclosure;



FIG. 10 is another structural block diagram of the allocation unit of the NAT device according to Embodiment 4 of the present disclosure;



FIG. 11 is a structural block diagram of a communication device according to Embodiment 5 of the present disclosure; and



FIG. 12 is a schematic diagram of a communication system according to Embodiment 7 of the present disclosure.





DETAILED DESCRIPTION OF THE EMBODIMENTS

Implementations of the present disclosure are illustrated below through embodiments with examples. It is obvious that the embodiments to be described below are part rather than all of the embodiments of the present disclosure. All other embodiments obtained by a person having ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the protection scope of the present disclosure.


In current NAT traversal, when a same application needs to establish multiple connections, it cannot be ensured that IP addresses of the multiple connections are the same. When IP addresses of multiple connections are not the same, some communication protocols cannot work normally, for example, an FTP application shown in FIG. 2. When a client (running an FTP client program and used as a PCP client) needs to perform FTP negotiation, the client opens, through the PCP protocol and on a NAT device, a port ex-port-1 corresponding to ex-ip-1. A packet received by an FTP server from the client carries ex-ip-1 and ex-port-1. When the client needs to transmit data, the client opens, on the NAT device, a second port ex-port-2 corresponding to an external network IP address ex-ip-2. The client notifies the FTP server of ex-ip-2 and ex-port-2, and the FTP server sends a data stream to the address (that is, ex-ip-2 and ex-port-2). However, the current PCP protocol cannot ensure that ex-ip-1 and ex-ip-2 are the same, that is, cannot ensure that external network IP addresses of two connections established by the same application are the same after the NAT traversal. If the external network IP addresses of two connections are not the same, such a case may become a means for a network attack, for example, after completing negotiation with a server, an attacker makes the server send a data stream to an attack target. Solutions in embodiments of the present disclosures can ensure that external network IP addresses of multiple connections established by the same application are the same after the NAT traversal.


Embodiment 1

This embodiment provides a method for allocating an external network IP address in NAT traversal, which is a method that may be applied to a NAT traversal control protocol (for example, a PCP protocol) to make external network addresses of multiple connections of a same application after the NAT traversal be the same. The method may be implemented by a NAT device. As shown in FIG. 3, the method includes:


Step 11: Receive a request message which is sent by a client and is for establishing a NAT mapping entry corresponding to a connection, where the request message includes a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application of the client.


A request message may include a designated external network IP address in multiple manners. The designated external network IP address may be directly carried in the request message, or a designated index value may be carried in the request message, so that a receiving side may find a corresponding external network IP address in an IP address index table according to the designated index value. An index value designated by the client may be obtained by adopting the following manner. When establishing the foregoing connection of the same application, the client obtains, in a returned response message, an external network IP address of an already established NAT mapping entry, and then searches the IP address index table to determine an index value corresponding to the external network IP address. In another method for obtaining an index value, the foregoing response message may include the index value directly, where the index value is an index value that corresponds, in the IP address index table, to an external network IP address of a NAT mapping entry, after the NAT mapping entry is established for a connection of the same application.


Step 12: When the NAT mapping entry is established according to the received request message, allocate, according to the designated external network IP address in the request message, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established. In this way, it is ensured that external network IP addresses of multiple connections of the same application are the same in the NAT traversal.


If the request message carries a designated index value, first an IP address index table is searched according to the designated index value to obtain a designated external network IP address; then, according to the designated external network IP address, an IP address which is the same as the designated external network IP address is allocated and used as the external network IP address of the NAT mapping entry to be established.


The foregoing method further includes: if the IP address which is the same as the external network IP address cannot be allocated and used as the external network IP address in the NAT mapping entry to be established, returning prompt information indicating a failure of allocation. In this way, according to the returned prompt information indicating the failure of the allocation, the application of the client may disconnect a previously established connection, reestablish each connection, and reestablish, through a NAT traversal control protocol (for example, the PCP protocol), a NAT mapping entry corresponding to each connection.


A case where the foregoing method is applied to the PCP protocol is further described below with reference to FIG. 4.


Through the foregoing method, the request message which is sent by a PCP client of the PCP protocol and is for establishing a NAT mapping entry for a connection includes the designated external network IP address, the designated external network IP address is the same as an external network IP address of a NAT mapping entry corresponding to any connection already established by the same application (an external network IP address of a NAT mapping entry corresponding to an already established connection may be obtained through the external network IP address included in a response message after a PCP server establishes the NAT mapping entry corresponding to the connection). In this way, a PCP server side may allocate, according to the designated external network IP address, the external network IP address of the NAT mapping entry to be established. A procedure in the PCP protocol is as follows:


Step S11: A PCP client sends a NAT mapping request to a PCP server run by a NAT device, where the NAT mapping request includes the following parameters: in-ip, ex-ip, in-port, and ex-port (an internal network IP address, an external network IP address, an internal network port number, and an external network port number), the external network port number may not be designated, for example, the external network port number is 0; ex-ip is a designated external network IP address, and the designated external network IP address ex-ip is the same as an external network IP address of a NAT mapping entry corresponding to any connection already established by a same application.


For some applications which do not need to designate an external network port number in a NAT mapping request, the ex-port (an external network port number) in the NAT mapping request may be set to a value, for example, 0, so that the server side does not use this parameter.


Step S12: The PCP server establishes a NAT mapping entry according to request message sent by the PCP client, where the NAT mapping entry is (in-ip, ex-ip)->(in-port, ex-port), ex-ip in the NAT mapping entry is an external network IP address designated by the PCP client, and ex-port is allocated by the PCP server itself. After the NAT mapping entry is established, a NAT mapping response with which the PCP server replies to the PCP client is (in-ip, ex-ip, in-port, ex-port).


After step S11 and step S12, it is ensured that when the same application that needs to establish multiple connections establishes a successive connection, an external network IP address in a NAT mapping entry corresponding to the connection to be established is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by the application. In this way, external network IP addresses of multiple connections of the FTP application are the same after the NAT traversal, which ensures that the FTP application can be connected to transmit data properly and avoids an attack due to the difference of external network IP addresses of multiple connections.


When the PCP server cannot allocate a same external network IP address according to the designated external network IP address, step S13 is further included, where prompt information indicating a failure of allocation that is in a NAT mapping response with which the NAT mapping response PCP server replies to the PCP client, is: cannot allocate a designated address (cannot assign mandatory address).


In actual implementation, when establishing a connection, the application may not designate an external network IP address in a PCP request message when requesting establishment of a first connection, and the PCP server is allowed to perform allocation arbitrarily. After a corresponding NAT mapping entry is established for the first connection, the application may, after obtaining the external network IP address and when establishing a successive connection, use the external network IP address as a designated external network IP address in a sent PCP request message, and request the PCP server to allocate an IP address which is the same as the designated external network IP address. In this way, an external network IP address in a NAT mapping entry corresponding to a successive connection is the same as an external network IP address in a NAT mapping entry corresponding to a previously established connection, which avoids a problem that the application cannot be connected normally because of inconsistency of external network addresses of multiple connections.


Embodiment 2

In this embodiment, a method for allocating an external network IP address in NAT traversal provided in the embodiment of the present disclosure is illustrated with reference to a processing process which makes external network IP addresses of multiple connections be the same after the NAT traversal in an FTP application. Referring to FIG. 5, a client communicates with and is connected to an FTP server through a NAT device, an FTP client program and a PCP client program are run on the client, and a PCP server runs on the NAT device. The method may include the following steps:


Step S21: The FTP client program first establishes a control connection, and the client sends a NAT mapping request to the PCP server, where the NAT mapping request includes parameters (in-ip, in-port, ex-port-1), in-ip is an internal network IP address, in-port is an internal network port number, and ex-port-1 is an external network port number.


Step S22: After receiving the NAT mapping request of the client, the PCP server obtains an external network IP address ex-ip-1 and the external network port number ex-port-1, and the PCP server establishes, according to the NAT mapping request and the obtained external network IP address (ex-ip-1) and external network port number (ex-port-1), a NAT mapping entry: (in-ip, in-port-1)->(ex-ip-1, ex-port-1).


Step S23: After establishing the NAT mapping entry for the control connection, the PCP server replies to the client with a NAT mapping response, where the NAT mapping response includes (in-ip, in-port, ex-ip-1, ex-port-1). In this case, the NAT mapping entry for the control connection of the FTP application is established.


Step S24: When the FTP client needs to provide the FTP server with a destination IP address and a destination port number for data transmission, the client needs to establish, through the PCP protocol and on the NAT device, a NAT mapping entry for a data connection of the FTP application; in this case, the FTP client negotiates, through the control connection (the control connection includes parameters: ex-ip-1, ex-port-1), with the FTP server about the port number (ex-port-2) of the data connection.


Step S25: After determining, through negotiation, the port number (ex-port-2), the client sends the PCP server a NAT mapping request for establishing the NAT mapping entry of the corresponding data connection, where the NAT mapping request includes (in-ip, ex-port-1, in-port-2, ex-port-2).


Step S26: After receiving the NAT mapping request of the client, the PCP server obtains the external network port number (ex-port-2) on the designated external network IP address (ex-ip-1) in the NAT mapping request; and after obtaining the port number (ex-port-2), establishes, according to the NAT mapping request, the NAT mapping entry: (in-ip, in-port-2)->(ex-ip-1, ex-port-2).


Step S27: After establishing the NAT mapping entry for the data connection, the PCP server replies to the client with a NAT mapping response, where the NAT mapping response includes (in-ip, ex-ip-1, in-port-2, ex-port-2). In this case, the NAT mapping entry for the data connection of the FTP application is established.


The FTP client notifies the FTP server of the external network IP address (ex-ip-1) and the port number (ex-port-2), which ensures that the external network IP address of the control connection and the external network IP address of the data connection are the same and the FTP server uses ex-ip-1 and ex-port-2 as a destination IP address and a destination port number for data transmission.


In the foregoing process for establishing the NAT traversal, due to some reasons, for example, no spare port is available to be allocated to the external network IP address that is designated to be allocated under the requirement of the PCP client, and in this case, a processing procedure is shown in FIG. 5.


The processing process of steps S31 to 35 is substantially the same as that of steps S21 to S25 above, and the differences are:


Step S36: After receiving a NAT mapping request of the client, the PCP server cannot obtain a port number (ex-port-2) on a designated external network IP address (ex-port-1) in the NAT mapping request, for example, There is no available port corresponding to the designated external network IP address (ex-port-1) in the NAT mapping request, which causes that the external network port number (ex-port-2) cannot be obtained, and therefore, the PCP server replies to the client with a NAT mapping response, where the NAT mapping response includes error prompt information: cannot allocate a designated address (cannot assign mandatory address).


Step S37: The FTP server removes an established control connection, and reestablishes each connection.


It can be seen from FIG. 6 that, the FTP client succeeds in requesting allocation of a first IP address (ex-ip-1) and the port (ex-port-1), but fails to request allocation of a second port (ex-port-2) of the IP (ex-ip-1), that is, there is no available port corresponding to the IP (ex-ip-1). In this case, the FTP client needs to terminate a current FTP connection and restart to attempt to establish a connection. To prevent the NAT device from reallocating a previous IP address (that is, an address being the same as ex-ip-1) to the FTP client, the FTP client may first apply, through the PCP protocol, for an IP (an external network IP address different from ex-ip-1), and then remove the current FTP connection and reestablish a new FTP connection.


In step S36, if there still is an available port corresponding to but ex-port-2 is occupied, in this case, optionally, it may return information that a designated port cannot be allocated. In this case, the FTP client may not need to remove the control connection, but renegotiate with the FTP server about a port number for a data connection, and the foregoing steps are repeated.


It can be known that, in the FTP application, an external network IP address is designated in a NAT mapping request, and a manner that an index value is designated in the NAT mapping request so that the server finds, through the index value, a corresponding external network IP address in an IP address index table may also be adopted. In this manner, it may also be implemented that the client designates an external network IP address, so that the server side allocates, according to the designated external network IP address, an external network IP address for establishing a NAT mapping entry, thereby ensuring that external network IP addresses of multiple connections in the FTP application are the same after the NAT traversal.


Embodiment 3

This embodiment provides a method for allocating an external network IP address in NAT traversal. As shown in FIG. 7, the method includes:


Step S41: Designate an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application;


The designated external network IP address enables the NAT device to: when a NAT mapping entry is established according to the request message, allocate, according to the designated external network IP address, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the NAT device.


Step S42: Send the NAT device the request message including the designated external network IP address.


Embodiment 4

This embodiment provides a NAT device, which is as shown in FIG. 8, and includes:


a receiving unit 1, configured to receive a request message which is sent by a client and is for establishing a NAT mapping entry corresponding to a connection, where the request message includes a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application;


an establishment unit 2, configured to establish the NAT mapping entry corresponding to the connection, according to the request message received by the receiving unit; and


an allocation unit 3, configured to, when the establishment unit establishes the NAT mapping entry according to the received request message, allocate, according to the designated external network IP address in the request message received by the receiving unit, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the establishment unit.


As shown in FIG. 9, the allocation unit in the foregoing NAT device includes:


an obtaining module 31, configured to obtain the designated external network IP address in the request message which is received by the receiving unit, is sent by the client, and is for establishing the NAT mapping entry corresponding to the connection; and


a processing module 32, configured to allocate the IP address which is the same as the external network IP address and used as the external network IP address in the NAT mapping entry which is to be established by the establishment unit according to the request message.


The NAT device may allocate, according to the designated external network IP address in the received request message sent by the client, the IP address which is the same as the external network IP address and used as the external network IP address in the NAT mapping entry to be established.


As shown in FIG. 10, another structural form of the allocation unit in the foregoing NAT device includes:


an obtaining module 311, configured to obtain a designated index value in the request message which is received by the receiving unit, is sent by the client, and is for establishing the NAT mapping entry corresponding to the connection;


a search module 313, configured to find, according to the designated index value, a corresponding external network IP address in an IP address index table; and


a processing module 312, configured to allocate the IP address which is the same as the external network IP address and used as the external network IP address of the NAT mapping entry which is to be established by the establishment unit according to the request message.


The NAT device may allocate, according to the designated external network IP address in the received request message sent by the client, the IP address which is the same as the external network IP address and used as the external network IP address in the NAT mapping entry to be established. A problem which occurs frequently in an existing NAT traversal solution and is that an application cannot work normally or is vulnerable to a network attack because external network IP addresses of multiple connections of a same application are different after NAT traversal is solved, and an adaptive capability of a NAT traversal protocol to an existing application is significantly improved.


Embodiment 5

As shown in FIG. 11, this embodiment provides a communication device, which may be used as a client device, and includes: a setting unit 21 and a sending unit 22.


The setting unit 21 is configured to designate an index value in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where an external network IP address in an IP address index table corresponding to the designated index value is the same as an external network IP address in a NAT mapping entry corresponding to a connection already established by a same application; so that when establishing the NAT mapping entry according to the request message, the NAT device can allocate, according to an external network IP address which is found according to the designated index value, an IP address which is the same as the external network IP address and used as an external network IP address of a NAT mapping entry to be established by the NAT device.


The sending unit 22 is configured to send the NAT device the request message including the index value designated by the setting unit.


The communication device may designate an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application, which makes it convenient for a server to allocate, according to the designated external network IP address in the request message, a same IP address, which is used as an external network IP address of the NAT mapping entry to be established, and ensures that external network IP addresses of multiple connections of the same application are the same after the NAT traversal.


Embodiment 6

This embodiment provides a communication device, which may also be used as a client device, has a structure similar to that of the communication device in Embodiment 4, and referring to FIG. 11, includes a setting unit and a sending unit.


The setting unit is configured to designate an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application; the designated external network IP address enables the NAT device to: when the NAT device establishes the NAT mapping entry according to the request message, allocate, according to the designated external network IP address, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the NAT device.


The sending unit is configured to send the NAT device the request message including the external network IP address designated by the setting unit.


The communication device may designate an index value in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where an external network IP address in an IP address index table corresponding to the designated index value is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application, which makes it convenient for the server to find, according to the designated index value in the request message, a corresponding external network IP address in the IP address index table, and allocate, according to the found external network IP address, a same IP address, which is used as an external network IP address of the NAT mapping entry to be established, and ensures that external network IP addresses of multiple connections of the same application are the same after the NAT traversal.


Embodiment 7

As shown in FIG. 12, this embodiment provides a NAT system, including:


a client device 41 and a server side device 42, where the communication device provided in any one of Embodiment 5 and Embodiment 6 is adopted as the client device, and the NAT device provided in foregoing Embodiment 4 is adopted as the server side device.


The client device 41 is connected to the server side device 42, and is configured to: designate an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, where the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application; and send the request message to the server side device 42.


The server side device 42 is connected to the client device 41, and is configured to receive the request message which is sent by a client and is for establishing the NAT mapping entry corresponding to the connection, where the request message includes the designated external network IP address, the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by the same application; and when establishing the NAT mapping entry according to the received request message, allocate, according to the designated external network IP address in the request message, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established.


It can be seen above that, in the method according to the present embodiment, by modifying the PCP protocol, it is ensured in the NAT traversal that external network IP addresses of multiple connections of the same application are the same after the NAT traversal, thereby avoiding a problem that the application cannot be connected normally or vulnerable to a network attack due to inconsistency of external network IP addresses of multiple connections.


Through the foregoing descriptions of the embodiments, those of ordinary skill in the art can clearly understand that, the present disclosure may be implemented by software plus a necessary hardware platform, and definitely may also be completely implemented by hardware. In most cases, the former may be a preferred implementation manner. Based on such understanding, all or part of the solutions of the present disclosure that make contributions to the prior art may be embodied in a form of a non-transitory storage medium configured to store instructions to execute the foregoing methods. The instructions may be stored in a storage medium, such as a ROM/RAM, a magnetic disk or an optical disk, and include several instructions to make a computer device (which may be a personal computer, a server, or a network device, and so on) perform the method described in each of the embodiments of the present disclosure or in some parts of the embodiments.


The foregoing descriptions are merely exemplary embodiments of the present disclosure, but not intended to limit the protection scope of the present disclosure. Any modification or replacement easily thought of by a person skilled in the art within the scope disclosed in the present disclosure shall fall within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure is subject to the appended claims.

Claims
  • 1. A method for allocating an external network Internet protocol (IP) address in NAT traversal, comprising: receiving a request message which is sent by a client and is for establishing a NAT mapping entry corresponding to a connection, wherein the request message comprises a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application of the client; andwhen the NAT mapping entry is established according to the received request message, allocating, according to the designated external network IP address in the request message, an IP address which is the same as the designated external network IP address and used as an external network IP address in the NAT mapping entry to be established.
  • 2. The method according to claim 1, wherein allocating, according to the designated external network IP address in the request message, the IP address which is the same as the designated external network IP address comprises: comprising a designated index value in the request message sent by the client; finding, according to the designated index value, a corresponding external network IP address in an IP address index table, and allocating an IP address which is the same as the external network IP address corresponding to the designated index value.
  • 3. A method for allocating an external network IP address in NAT traversal, comprising: designating an external network IP address in a request message which is sent to a NAT device and is for establishing a NAT mapping entry corresponding to a connection, wherein the designated external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application;wherein the designated external network IP address enables the NAT device to: when the NAT mapping entry is established according to the request message, allocate, according to the designated external network IP address, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the NAT device; andsending the NAT device the request message comprising the designated external network IP address.
  • 4. The method according to claim 3, wherein designating the external network IP address in the request message which is sent to the NAT device and is for establishing the NAT mapping entry corresponding to the connection comprises: comprising a designated index value in the request message sent to the NAT device, so that a server side can find, according to the designated index value, a corresponding external network IP address in an IP address index table.
  • 5. A NAT device, comprising: a receiving unit, configured to receive a request message which is sent by a client and is for establishing a NAT mapping entry corresponding to a connection, wherein the request message comprises a designated external network IP address, and the external network IP address is the same as an external network IP address in a NAT mapping entry corresponding to any connection already established by a same application of the client;an establishment unit, configured to establish the NAT mapping entry corresponding to the connection according to the request message received by the receiving unit; andan allocation unit, configured to, when the establishment unit establishes the NAT mapping entry according to the received request message, allocate, according to the designated external network IP address in the request message received by the receiving unit, an IP address which is the same as the designated external network IP address and used as an external network IP address of a NAT mapping entry to be established by the establishment unit.
  • 6. The NAT device according to claim 5, wherein the allocation unit comprises: an obtaining module, configured to obtain the designated external network IP address in the request message which is received by the receiving unit, is sent by the client, and is for establishing the NAT mapping entry corresponding to the connection; anda processing module, configured to allocate the IP address which is the same as the external network IP address and used as the external network IP address in the NAT mapping entry which is to be established by the establishment unit according to the request message.
  • 7. The NAT device according to claim 5, wherein the allocation unit comprises: an obtaining module, configured to obtain a designated index value in the request message which is received by the receiving unit, is sent by the client, and is for establishing the NAT mapping entry corresponding to the connection;a search module, configured to find, according to the designated index value, a corresponding external network IP address in an IP address index table; anda processing module, configured to allocate the IP address which is the same as the designated external network IP address and used as the external network IP address in the NAT mapping entry which is to be established by the establishment unit according to the request message.
Priority Claims (1)
Number Date Country Kind
201010508346.4 Oct 2010 CN national
CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Application No. PCT/CN2011/075185, filed on Jun. 2, 2011, which claims priority to Chinese Patent Application No. 201010508346.4, filed on Oct. 15, 2010, both of which are hereby incorporated by reference in their entireties.

Continuations (1)
Number Date Country
Parent PCT/CN2011/075185 Jun 2011 US
Child 13859392 US