2016-09-20 190 views
0

我從http://www.stunprotocol.org/下載了stun客戶端,並試圖通過命令stunclient --mode full stun.stunprotocol.org --verbosity 9找出NAT類型,並且我得到了下面的響應。關於nat類型分析

config.fBehaviorTest = true 
config.fFilteringTest = true 
config.timeoutSeconds = 0 
config.uMaxAttempts = 0 
config.addrServer = 52.86.10.164:3478 
socketconfig.addrLocal = 0.0.0.0:0 
Sending message to 52.86.10.164:3478 
Got response (68 bytes) from 52.86.10.164:3478 on inter 
Other address is 52.201.75.212:3479 

Sending message to 52.201.75.212:3478 
Got response (68 bytes) from 52.201.75.212:3478 on inte 
Sending message to 52.201.75.212:3479 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Sending message to 52.201.75.212:3479 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Sending message to 52.86.10.164:3478 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Sending message to 52.86.10.164:3478 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Sending message to 52.86.10.164:3478 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Sending message to 52.86.10.164:3478 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Continuing to wait for response... 
Binding test: success 
Local address: 10.64.60.58:58841 
Mapped address: 125.19.34.60:24604 
Behavior test: fail 
Filtering test: success 
Nat filtering: Address and Port Dependent Filtering 

我在一家公司工作,因此出於安全考慮,NAT類型「地址和端口相關濾波」似乎是可行的。

但是作爲一個普遍的現象,在我看來,對於對等連接,大部分時間,NAT類型將是「地址和端口相關的過濾」,因此任何媒體通信都需要轉向服務器。

但是,在谷歌搜索webrtc,它顯示90%的點對點通信通過眩暈服務器本身建立(通過打孔等)。這意味着在這種情況下NAT類型完全支持建立連接。

專家對NAT類型分析有任何意見要考慮對等通信?

回答

1

stunclient程序可以使用更多的日誌記錄來指示它在做什麼。由於我對代碼有一點了解,下面是我對它的解釋。

Stunclient執行兩組不同的測試。首先是「映射行爲」測試,這對於瞭解NAT /防火牆如何影響P2P連接最重要。另一組是「過濾測試」,它表明您的NAT在接收來自其他IP /端口組合的流量時如何「打開」。

您的行爲測試「失敗」。這可能意味着,根據您的日誌輸出是這樣的:

測試1:在這種情況下選擇一個隨機端口,58841。從這個本地端口,對stun.stunprotocol.org:3478進行基本的綁定測試。這是客戶端收到服務器指示映射地址(125.19.34.60:24604)的響應的位置,並且用於後續行爲和過濾測試的暈眩IP位於52.201.75.212。

測試2:相同的本地端口58851.發送綁定請求到備用IP和主端口(52.201.75.212:3478)。就你而言,看起來返回的響應可能是不同的IP或端口。而在這種情況下,「測試3」是必需的。

測試3:相同的本地端口58851.發送綁定請求到備用IP和備用端口(52.201.75.212:3479),以便區分「地址相關」和「地址和端口相關映射」。這是一個有趣的部分 - 你從來沒有得到迴應。儘管能夠與端口3478上的兩個IP地址進行通信,但這是測試恢復失敗的原因。

可能是兩件事情之一:

a)您的NAT /防火牆實際上是開放的端口3478,而不是3479.在命令行中執行此檢測

stunclient 52.201.75.212 3479 

如果這成功獲得映射地址,然後立即執行此操作:嘗試其他這兩種IP地址和端口的組合。嘗試使用這兩種IP地址和端口的其他組合。嘗試其他組合。由此產生的行爲可能意味着以下內容:

b)當NAT和防火牆在remove ip和port都發生變化時拒絕端口映射。這意味着您的網絡環境更具限制性,即「地址和端口依賴映射」NAT。通常稱爲對稱NAT。

至於過濾測試,忽略這個結果。過濾測試嘗試檢測是否可以發送到一個ip:端口,但是從不同的ip或端口接收。 99%的時間NAT不允許這樣做。所以結果幾乎總是導致「地址和端口相關濾波」。過濾測試結果並不能很好地說明您的NAT如何在P2P連接中取得成功。

僅僅因爲您的企業網絡非常有限,並不意味着您無法與其他網絡上的對等方進行通信。如果他的端點獨立映射具有更好的NAT性能,那麼P2P連接仍然有可能成功。

我沒有跟上最近yearas的NAT趨勢,但80%-90%的STUN單獨成功的連接聽起來是對的。其餘的將需要一箇中繼解決方案,如TURN。

+0

謝謝塞爾比。但是,如果「52.201.75.212」的偵察服務器能夠通過其端口「3479」響應,直到它聽到它爲止?如果其中一種網絡NAT類型是對稱網絡,而其他網絡NAT類型是端點獨立映射,那麼P2P連接仍然是可能的。這就是你的意思,「這並不意味着你不可能與另一個網絡上的對等設備進行通信,如果他具有更好的端點獨立映射NAT,那麼P2P連接仍然有可能成功」 .. –

+0

STUN服務器始終在兩個端口(3478和3479)以及兩個IP地址上偵聽。由於對稱NAT(例如您的企業網絡)沒有可預測的端口映射,因此從STUN獲得的地址/端口是否可以與嘗試連接的對端的IP地址一起工作尚不確定。 Peer的NAT不僅必須是Endpoint Ind,而且過濾可能必須是「Address Dependent」或更好。 – selbie

0

我想,你想在所有可能的場景(包括對稱NAT)之間進行p2p之間的通信。 我的建議:嘗試使用webRTC並使用stun並在冰服務器列表中打開服務器。這將爲您提供一系列ICE考生,並且webRTC將負責連接最佳候選人。 這應該可以讓你免受NAT類型的擔憂。