Peer to peer connection without port forwarding

I wrote a long devlog/guide on how to establish peer to peer connection between players without them needed to port forward.

https://blog.crowsneststudio.org/posts/nat/

It is not directly related to godot, but it showcases some gdscript examples. In general it is more engine agnostic. That being said I thought it was a good idea to post it here as godot does not have guides dedicated to NAT traversal, so I figured it would be of help to people using godot.

4 Likes

I’m surprised this works, I thought you needed UPnP to hole punch, is this a feature of UDP? I wish I knew anything about ipv6 as my ipv4 knowledge is that local networks are often very locked down without UPnP and a standard firewall.

1 Like

UPnP does not hole punch - it straight up opens a port that ANYONE can join to. It is basically an automatic port forwarding. The trick is UPnP would also close the port afterwards. Hole punching opens a port to a specific IP:PORT depending on your NAT type - I explain the theory around it here: War on NAT, or how to let your players connect without port forwarding
And here is the explanation on how different NAT types behave: War on NAT, or how to let your players connect without port forwarding
You can also check the link in the footnotes on the STUN server documentation for more information on them.

As for ipv6 - it is not really much different in terms of the method - you just punch a hole in the ipv6 space rather than ipv4. Obviously both users have to have ipv6 access. Really the main difference is that ipv6 does not really suffer from NAT issues, except if the user makes this specifically with their router - but that would mean they know what they are doing and are doing it intentionally. For example it could be for security, but then they shouldn’t be expecting to play peer to peer games. The other difference with ipv6 is that really in there you are not actually punching a hole in the router most of the time - you are actually punching a hole in the firewall. Technically with ipv6 you could also achive a similar thing by just changing the firewall settings to allow the game.

1 Like