Because I struggled with this myself, here’s the step-by-step process when using the Bootstrap sample included in the Netcode package. Netcode for GameObjects works fine over the Internet without Relay, ICE, UDP hole punching through NAT - but it does require certain steps to set it up AND it requires each host to configure port forwarding.
Using Netcode for GameObjects to host a game on the Internet without Relay:
Make sure you have the Bootstrap sample installed (in PackageManager select Netcode for GameObjects package):
Open the Bootstrap scene and select the BootstrapManager object, then edit the Connection Data, entering your computer’s local IP address and 0.0.0.0 for the Server Listen Address, for example:
This local IP address is also the one you need to use in port forwarding on the router (I’ll get to that further down).
Make a build.
Name it “host” or similar. This build can be a “server” or “host” but only on your local machine.
Get your public IP address.
Let’s assume it is “66.67.98.99” - be sure to use yours not this example IP. Enter it in the same Address field in Connection Data:
Note that the public IP typically changes for most users from day to day. So be sure to re-check in case it suddenly stops working days later. This is what dynamic DNS services are used for (more below).
Make a build.
Name it “client” or similar. Just DO NOT OVERWRITE the “host” build!
ZIP up the “client” build and distribute it to someone who can remotely test connections.
NOTE: This “client” build will be able to connect to an instance of the “host” build that runs on your local machine and nothing else! This “client” build will NOT be able to connect to your “host” instance when you run it on your local network, not even on your local machine! This “client” build will also not be able to host/serve games on any network other than yours. All of this is due to the host’s public IP being hardwired in the build.
Lastly, setup port forwarding on both the router that connects to the Internet AND on any software firewall running on your system (ie Windows Firewall or some “Internet Security” or “Antivirus” software that runs a firewall). Personally, but only while testing, I would recommend to simply TURN OFF any software firewall that runs on your operating system. Those software firewall GUIs are often #§%&! … terribly confusing and loaded with additional proprietary features and for non-english users, the translations are often flabbergastingly odd.
On my router, it simply looks like this - see the second entry:
Yes, I also host and play DOOM.
192.168.0.78 is my machine’s local IP address on the router’s local network (LAN).
Now run the “host” instance locally and choose to either “Host” or “Serve” and instruct your testers to run the “client” instance and to click on the “Client” button. Everyone should click the “Random Teleport” button at least once, otherwise each peer’s sphere will occupy the same position.
If there’s exactly one sphere per connected peer (including the host) after everyone randomized their positions, then everything worked fine!
It’s now up to you to implement this in a way that does not require making multiple builds, and allows users to enter IP addresses and hostnames (ie mynetcodegame.com).
A couple things you’ll definitely need:
Note: Dynamic DNS can often be conveniently configured on the router itself allowing for, with proper port forwarding, multiple machines hosting various games on the local network all using the same dynamic DNS hostname.