s********k 发帖数: 6180 | 1 【 以下文字转载自 CS 讨论区 】
发信人: silverhawk (silverhawk), 信区: CS
标 题: 问一个NAT地址转换的问题?
发信站: BBS 未名空间站 (Thu Nov 27 21:36:38 2008)
NAT地址转换的机理是对内网(private network)的不同机子进行不同的port
forwarding吗?那假如在NAT里面有两台机子都对外面发送http(80)的邀请,在外面机
子看来,都看到NATrouter的ip(比如1.1.1.4),返回的包怎么被router正确发送到这
两个机子上的呢? | n********5 发帖数: 323 | 2 我的理解是 router 里面有个 table 完成转换的... 包含IP和port number.. 类似于
socket唯一确定某个application一样。。。 | z*****n 发帖数: 7639 | 3 Actually, there are so-called NATs and PATs:
For a NAT, it has a set of public addresses,
and each internal host will be mapped one. So
it is called NAT (Address Translator).
For a PAT, it usually has one public address,
and each connection is mapped by
(publicIP:port<-->internalIP:port) couple. So
it is called PAT (port translator).
But many ppl don't distinguish these two things
and call them all NATs simply.
For your question: if two internal hosts both
send HTTP requests to an WWW server, th
【在 s********k 的大作中提到】 : 【 以下文字转载自 CS 讨论区 】 : 发信人: silverhawk (silverhawk), 信区: CS : 标 题: 问一个NAT地址转换的问题? : 发信站: BBS 未名空间站 (Thu Nov 27 21:36:38 2008) : NAT地址转换的机理是对内网(private network)的不同机子进行不同的port : forwarding吗?那假如在NAT里面有两台机子都对外面发送http(80)的邀请,在外面机 : 子看来,都看到NATrouter的ip(比如1.1.1.4),返回的包怎么被router正确发送到这 : 两个机子上的呢?
| s********k 发帖数: 6180 | 4 谢谢,还是有点不是很明白的是。比如内网的机子发送http包的时候,port不是80?到
了NAT那里才被转换成80的?还有在例子中,如果
internalhost1IP:xxxx 和 internalhost2IP:xxxx 两个机子对同一个网站www.aaa.
com发送http(80) request, 那www.aaa.com返回的数据http response应该是指向
NAT的IP(1.1.1.4)80端口,NAT怎么区分倒是是给internalhost1IP还是
internalhost2IP呢? | z*****n 发帖数: 7639 | 5 No, the port number 80 is only for HTTP server.
The client, as I showed in previous example,
will always choose an ephemeral port (>2048)
to initiate the TCP connection.
Take this into consideration, the two internal
host will use port xxxx and yyyy respectively,
(xxxx and yyyy in most cases are different, of
course they can be equal, but this doesn't
do anything wrong), and send HTTP GET to
www.aaa.com's port 80.
At the NAT, the internal:external connections
are distinguished by both IPand PORT
【在 s********k 的大作中提到】 : 谢谢,还是有点不是很明白的是。比如内网的机子发送http包的时候,port不是80?到 : 了NAT那里才被转换成80的?还有在例子中,如果 : internalhost1IP:xxxx 和 internalhost2IP:xxxx 两个机子对同一个网站www.aaa. : com发送http(80) request, 那www.aaa.com返回的数据http response应该是指向 : NAT的IP(1.1.1.4)80端口,NAT怎么区分倒是是给internalhost1IP还是 : internalhost2IP呢?
| s********k 发帖数: 6180 | 6 谢谢zhaoyun,解释得非常清楚了。受教
【在 z*****n 的大作中提到】 : No, the port number 80 is only for HTTP server. : The client, as I showed in previous example, : will always choose an ephemeral port (>2048) : to initiate the TCP connection. : Take this into consideration, the two internal : host will use port xxxx and yyyy respectively, : (xxxx and yyyy in most cases are different, of : course they can be equal, but this doesn't : do anything wrong), and send HTTP GET to : www.aaa.com's port 80.
|
|