从 NAT 后面到相同 IP 和端口的多个开放 TCP/IP 连接
我正在尝试确定如果所有计算机都使用相同的端口,NAT 后面的多台计算机如何/是否可以与同一远程 IP 地址建立唯一的 TCP/IP 连接。在这种情况下,我的理解是,用于标识每个 TCP 连接的 5 元组实际上在单个远程计算机上看起来是相同的 - 因为它由以下部分组成:
- 协议
- 远程 IP
- 远程端口
- 本地 IP
- 本地端口
所以在这种情况下,如果单个远程计算机都使用端口 80,则如何区分来自 NAT 计算机 A 和 NAT 计算机 B 的连接?我假设这是可能的,因为 NAT 后面的计算机能够同时在相同端口上执行相同的操作,而不会出现问题...我只是没有看到远程计算机如何正确处理此问题。
谢谢!
I'm trying to determine how/if it is possible for multiple machines behind NAT to establish unique TCP/IP connections to the same remote IP address if all machines are using the same port. In this case, my understanding is that the 5-tuple used to identify each TCP connection would in effect look the same on the single remote machine - since it's made up of:
- protocol
- remote IP
- remote port
- local IP
- local port
So in this case, how does the single remote machine differentiate between the connection coming from NAT'd computer A vs. NAT'd computer B if they are both using port 80? I'm assuming this is possible since computers behind NAT are able to simultaneously perform the same action on the same ports without issue... I'm just not seeing how the remote machine properly handles this.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果机器使用不同的源端口 - 问题就解决了。远程 TCP 使用它来识别它们。如果多台计算机使用相同的源端口,NAT 会处理并更改它。
If the machines use different source ports - problem solved. The remote TCP uses that to identify them. If multiple machines use the same source port, the NAT takes care of it and changes it.
您还应该记住,NAT 路由器可以调整 IP/端口对以避免冲突。这就是端口转发等事情的完成方式。即使这些流来自同一源端口,路由器也会将其识别为唯一,因为源本地 IP 会不同。
You should also keep in mind that NAT routers can adjust the IP/Port pairs to avoid conflicts. It's how things are done such as port forwarding. The router will recognize the streams as unique even if they manage to come from the same source port because the source Local IP will be different.