I try to test a python hole punching packet based on this article: https://bford.info/pub/net/p2pnat/
The hole punching process worked in several network setups, only the final use case (3.5 Peers Behind Multiple Levels of NAT) gives me difficulties.
Let's assume the following network:
| | 188.8.131.52 ___[eth0]___ **NAT0** ___[eth1]___ | 192.168.0.1 | (switch) / \ / \ 192.168.0.2 / \ 192.168.0.3 __[eth0]__ __[eth0]__ **NATA** **NATB** __[eth1]__ __[eth1]__ 192.168.10.1| |192.168.11.1 | | 192.168.10.2| |192.168.11.2 __[eth0]__ __[eth0]__ **NodeA** **NodeB**
I want to implement a hairpin on NAT0 as I think this causes the issue. However I do not understand how to configure the
POSTROUTING as I do not know the public port from the PAT(=NAT). Thus I am not able to know which packet belongs to machine NATA or NATB only by checking the destination ip
-d 184.108.40.206 if I would now which public port belongs to NATA and NATB I would able to send the package to the right local machine.
The interesting thing is that I was able to get it working with only a single NAT layer (while not having configured a Hairpin at all).
Possibly Related Question
However in this case all the (local) traffic with the destination of the public ip gets routed to a single machine. In my case I want to route the package to different machine depending on their public port.