NAT之stun确定nat类型

NAT之确定nat类型

下载安装twisted和zope
http://twistedmatrix.com/trac/wiki/Downloads
http://pypi.python.org/pypi/zope.interface/3.8.0#downloads

下载stunclient
http://code.google.com/p/stunclient/

这里面有个stun子目录,说是用于发现NAT类型
This code comes from Shtoom: http://divmod.org/projects/shtoom

执行里面的stun.py,就会log一个文件,在我电脑上如下(很费解啊)

01:23:30 [-] Log opened.
01:23:30 [-] <class '__main__.TestStunDiscoveryProtocol'> starting on 5061
01:23:30 [-] Starting protocol <__main__.TestStunDiscoveryProtocol object at 0x00EDB190>
01:23:30 [-] startDiscover--localAddress is 0.0.0.0
01:23:30 [-] localAddress is invalid!
01:23:30 [-] resolving A.ROOT-SERVERS.NET
01:23:30 [-] connecting UDP socket to 198.41.0.4
01:23:30 [-] twisted.internet.protocol.DatagramProtocol starting on 57131
01:23:30 [-] Starting protocol <twisted.internet.protocol.DatagramProtocol instance at 0x00EE3828>
01:23:30 [-] connected UDP socket says 192.168.1.100
01:23:30 [-] (Port 57131 Closed)
01:23:30 [-] Stopping protocol <twisted.internet.protocol.DatagramProtocol instance at 0x00EE3828>
01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
01:23:30 [-] sending request 'bbf2c488eedcba1863238b76fbbdb1a' with 1 avpairs to ('216.146.35.99', 3478) (in state 1)
01:23:30 [-] sending request 'bcffaf59142c3cf2575d2fb6f06424' with 1 avpairs to ('213.192.59.75', 3478) (in state 1)
01:23:30 [-] sending request '26e9d0804bc12a4037aa59ccbd75e49' with 1 avpairs to ('192.98.81.87', 3478) (in state 1)
01:23:30 [stun] got STUN response to None from ('213.192.59.75', 3478)
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] MAPPED-ADDRESS 116.48.48.225 14959
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] CHANGED-ADDRESS 213.192.59.93 3479
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] SOURCE-ADDRESS 213.192.59.75 3478
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
01:23:30 [stun] ignoring belated STUN response to 'bcffaf59142c3cf2575d2fb6f06424' from ('213.192.59.75', 3478)
01:23:30 [-] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
01:23:30 [stun] ignoring belated STUN response to 'bcffaf59142c3cf2575d2fb6f06424' from ('213.192.59.75', 3478)
01:23:30 [-] sending request '1fd789b6d02e4be456597e8be1df4a7a' with 1 avpairs to ('213.192.59.75', 3478) (in state 2b)
01:23:30 [stun] got STUN response to '1fd789b6d02e4be456597e8be1df4a7a' from ('213.192.59.93', 3479)
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] MAPPED-ADDRESS 116.48.48.225 14959
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] CHANGED-ADDRESS 213.192.59.93 3479
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] SOURCE-ADDRESS 213.192.59.93 3479
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] calling handleStunState2b
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] 2b {'externalAddress': ('116.48.48.225', 14959), '_altStunAddress': ('213.192.59.93', 3479)}
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] STUN finished, results:
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] You're behind a <NatType FullCone>
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] and external address is ('116.48.48.225', 14959)
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] (Port 5061 Closed)
01:23:30 [__main__.TestStunDiscoveryProtocol (UDP)] Stopping protocol <__main__.TestStunDiscoveryProtocol object at 0x00EDB190>
01:23:30 [-] Main loop terminated.

转载于:https://www.cnblogs.com/cutepig/archive/2011/09/23/2185702.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值