Linking Domain Names to Port Numbers

If it is completely your application and you have control over your DNS, you can define a SRV record for your game. Your clients have to understand then that you have defined a _gamename._tcp.example.com SRV record in order to give the user a way to use example.com to access the server at the right port.

Sounds complicated and nearly unfeasible if you just use an existing game server and host it, but it is the only way to include a port number in DNS.

If this is not possile, just take the "normal" port for the public server (so that the user does not have to worry about), and the "other" port for the private server (where you have to specify the port, but the user base is limited so the "total sum of worries" is smaller.)


You can do this by editing apache httpd.conf file and add Virtual Hosts redirection. Of course if that is your server and you can edit DNS records also. For example:

NameVirtualHost ip.add.of.server

<VirtualHost ip.add.of.server>
    ServerName yourserver.domain.com
    Redirect permanent / http://yourserver.domain.com:PORT
</VirtualHost>

<VirtualHost ip.add.of.server>
    ServerName yourserver2.domain.com
    Redirect permanent / http://yourserver.domain.com:PORT
</VirtualHost>

yourserver2.domain.com can be same server, You must add new A record on DNS.


Unfortunately there is no way to accomplish this, unless it's catered for as a feature of the particular games you're running.

Your choices are to either bind a separate public IP to each different instance of the same game (which isn't an option if you only hold a single public IP), or specify the port number when you tell people about the server.

There's a workaround for this when dealing with HTTP traffic, but that only works because a connecting client talks to the server and provides information to the server about what it thinks it's trying to connect to (ie it tells the server it's connecting to what DNS name it's trying to reach, when it connects). This allows the server to make a choice about what content to serve to the client. However, it doesn't bump anything to a different port.