To use a custom domain name, resolve the game address to the server's public IP. You can keep the website address and game address in different subdomains.
Step by step
-
Get the IP address and port available to players from the server provider. Using the address of the administration panel or the local IP of the machine.
-
Add an A record named
playto the DNS zone and write the IPv4 address as a value. If IPv6 is actually being listened to, add the AAAA record, don't publish a non-working IPv6 address. -
If you're using Cloudflare, set the game subdomain to
DNS onlyin your regular DNS record. If Java uses a private port, share the port or create a separate SRV record. -
Query the domain name from a different network and compare the result with the numerical address. If the numerical address works but the domain name does not, examine the DNS side.
Keep in mind
DNS record handles name resolution. Port forwarding and server listening are also required.