如何发现给定接口背后的NAT类型 [英] How to discover the type of the NAT a given interface is behind

查看:239
本文介绍了如何发现给定接口背后的NAT类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发现给定网络接口背后的NAT(FullCone,Restricted Cone,Port Restricted cone,Symmetric)的类型。

I would like to discover the type of the NAT (FullCone, Restricted Cone, Port Restricted cone, Symmetric) a given network interface is behind.

我测试了不同的工具( http:/ /freshmeat.net/projects/jstun/ http://code.google.com / p / boogu / )但它们报告了同一界面的不同结果。

I've tested different tools (http://freshmeat.net/projects/jstun/, http://code.google.com/p/boogu/) but they report different results for the same interface.

我正在寻找Python(或其他语言的第二选择,如果没有其他可用的第二选择)的确定答案。

I'm looking for a definitive answer in Python (or other languages, 2nd choice being Java, if nothing else is available).

推荐答案

我从@ S.Lott得到的答案是:我不可能使用STUN(或任何其他协议)100%确定地确定什么类型的NAT你落后了。

I second the answer from @S.Lott: It is not possible to use STUN (or any other protocol) to determine with 100% certainty what type of NAT you're behind.

问题是(正如我最近所见),NAT有时可能充当地址相关(对称),有时候是与端点无关的(完整,限制或端口限制锥形)。

The problem is (as I witnessed recently) that the NAT may sometimes act as Address-Dependent (Symmetric) and sometimes as Endpoint-Independent (Full, Restricted or Port Restricted cone).

当你考虑它时,是地址依赖的意思当您将数据包从NAT后面的客户端上的一个套接字发送到两个不同的服务器时,NAT将为每个服务器创建两个自定义公共地址:端口元组。在我的例子中,这些绑定似乎是完全随机的,但如果范围很小,有时候这些元组实际上是相等的!这使测试感到困惑。

When you think about it, being Address-Dependent means that when you send packets from one socket on a client behind the NAT to two distinct servers, then the NAT will create two custom public address:port tuples for each of the servers. In my case, these bindings seemed completely random, but if the range is small, it sometimes happened that these tuples were actually equal! Which confused the test.

我使用的是这个图书馆当时有时它告诉我NAT的行为是地址依赖的,有时候它是Endpoint-Independent(两者之间的切换似乎也是完全随机的,有时它发生在我重新启动设备后,有时在一段时间之后, ...)。

I was using this library at the time and sometimes it told me the NAT's behavior was Address-Dependent and other times it was Endpoint-Independent (the switch between the two also seemed completely random, sometimes it happened after I restarted the device, sometimes after a time period,...).

我在移动设备上遇到了斯洛伐克Telekom ,这家公司主要由 Deutsche Telekom 拥有,所以我认为问题将至少在整个欧洲范围内。

This happened to me on a mobile device with Slovak Telekom, a company mostly owned by Deutsche Telekom so I think the problem will be at least Europe-wide.

我会说这里的规则是这样的:如果STUN测试告诉你,你是一个对称NAT而不是那个是这样,但如果它告诉你,那么你就不能百分百肯定。

I would say that the rule here is this: If STUN test tells you that you're behind a Symmetric NAT than that is the case, but if it tells you otherwise, then you can not be 100% sure.

最后一点,一个简单的方法来检查你的NAT的行为wi对TCP的尊重是在google中键入我的IP地址是什么,然后先打开(比如说)五页。如果页面与您的IP地址一致,则NAT的行为是地址相关或地址和端口相关(对称)。但同样,如果他们确实对应,你就不能确定。

One last note, an easy way to check your NAT's behavior with respect to TCP is to type "what is my IP address" into google and then open first (say) five pages. If the pages are not consistent about your IP address, your NAT's behavior is Address-Dependent or Address-and-Port-Dependent (Symmetric). But again, if they do correspond, you just can't be sure.

这篇关于如何发现给定接口背后的NAT类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆