开发者

How to perform p2p behind 2 nats?

I'm trying to send 'hello' btw 2 clients, each behind a firewalled NAT, without success. UDP or TCP punching are just as fine, for now.

client A expecting to receive 'hello p':

set -- $( wget -qO- http://www.pschmidt.it/screenshooter/ss3.php | awk '{print $1, $2}'); echo $1 $2 $3 $4; `nc -l -v $2 ` & sudo hping3 -2 -c 30 -s $2 -p $4 $3

client B sending hello p:

set -- $( wget -qO- http://www.pschmidt.it/screenshooter/ss3.php | awk '{print $1, $2}'); echo $1 $2 $3 $4; sudo hping3 -2 -c 30 -s $2 -p $4 $3; echo "hello p" | nc -p $2 -u 开发者_如何学JAVA$3 $4

Unfortunately nothing is received.

Implementation inspired by http://www.brynosaurus.com/pub/net/p2pnat/


So, are both NATs restricted cone NATs? Do they deny port access when nothing went out on that / to the request source before?

You need to send a packet from one host to another, with the correct addresses and ports so the NATs then accept incoming requests even if they’re requests and not responses.

As an example:

PC1 - NAT1 - network - NAT2 - PC2

PC1 wants to access PC2 on port 10.

PC2 sends a request to PC1 with source port 10 (which is blocked by NAT1). PC1 sends a request to PC2 to port 10, which is then not blocked and will be responded.


You need to investigate which type of NATs you are dealing with. The 'symmetric' terminology is obsolete. You can read corresponding chapter from the Practical JXTA II book available online from scribd.

The technique you describe in your question will never work if neither of your peers have a public address. Solving this issue is more sophisticated and is not always possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜