-
Notifications
You must be signed in to change notification settings - Fork 330
Description
In order to have a basic NAT support, we should begin somewhere.
Modification of full cone NAT (port restricted full cone NAT) is default on Linux iptables. Since linux installations comprises majority of router setups we probably should start here. IPtables itself can be configured in other NAT types too, but this one looks to be the main one.
Attaching high level concept of how such NAT traversal could work.
There might be many issues with such implementation (such as IP gets blacklisted by FW if it gets traffic from an unknown IP). This can be addressed later, delaying initial CONNECT. For now we solve simple case, that should be most common.
Adapting NAT traversal to our node is a bit more complex, since we do not implement our own transport protocol, but try to use existing plain security protocols (WG, OpenVPN). We cannot and do not want to use any intermitting transport proxies. For best performance we should have plain p2p connections.
Since there is specifics how services are being launched in our node NAT traversal implementation may vary a bit. We cannot have OpenVPN started before datagram tunnel is not set up in a NAT. According diagram above, flow should be like this:
- Send { Port: 1194, External IP } to node service
- Client initiates connection ( Dst Port 1194, Src Port: Local Port 1194)
- Node starts NAT pinger on Local Port 1194 and sends packet to peer { Port 1194, External IP }
- When NAT pinger receives CONNECT from peer it shutdowns itself.
- Node service is started on 1194, next CONNECT from peer should reach node service and connection should proceed as normal.