2
2
I was wondering if tcp/udp hole punching would still work when you are in the same network (behind a NAT), and what the packet's path would be.
What happens when using hole punching on the same network, is that it will send a packet out with the same destination and source address. Only the source and destination port would differ. I imagine a router with NAT loopback enabled will handle this as it should, but how about other routers? Would they drop the packet, or would a router (the first?) from the ISP bounce the packet back after which it gets handled okay?
I'm wondering because I was thinking about using this technique to circumvent a block between peers in a network (like a school network where clients can only access the internet, but any contact with each other is blocked). The only other option is to use a man in the middle as proxy (tunnel?). The disadvantage of this is that you have to have a server with significantly more bandwidth than one that would only do hole punching. Also the latency would increase significantly.
You can try it, but it's very unlikely to work. A NAT device typically will not rewrite both the source and destination IP addresses of a single packet unless specifically configured to do so. – David Schwartz – 2012-09-27T20:23:39.547
@DavidSchwartz It doesn't have to rewrite both fields. It seems (also seeing the answer that was just posted) my question is a bit unclear... – Luc – 2012-09-27T21:20:33.630
It does have to rewrite both fields. Say machine A is talking to machine B through router R. The packet from A is addressed
A->R
. The packet it must pass to B must be addressedR->B
. (It must rewrite the source so it can NAT the replies. And it must rewrite the destination to get the packet to B at all.) So it must rewrite both the source and destination IP addresses. – David Schwartz – 2013-01-28T14:29:58.770