Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a [game] server (CentOS) that has about 10 used ports. For one game in particular, I have 2 servers: a private one and a public one. The IP for them is the same, so to differentuate between them the user must use mydomain.com:[portnumber]. Is there a way that I can configure CentOS to automatically take something like subdomain.mydomain.com and transform it to mydomain.com:[portnumber] or simple localhost:[portnumber]? Is this what a DNS is for?

Thanks

share|improve this question

migrated from stackoverflow.com Sep 10 '11 at 12:10

This question came from our site for professional and enthusiast programmers.

3  
I don't get why this was downvoted. It's a legitimate question. –  Chris Thorpe Sep 11 '11 at 0:43
add comment

4 Answers 4

up vote 4 down vote accepted

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.)

share|improve this answer
add comment

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.

share|improve this answer
1  
This method is specific to web hosting and won't work for this scenario (guessing UDP video game traffic) –  Chris Thorpe Sep 11 '11 at 0:44
    
This only works for apache. Im talking about non-specific applications, mainly such as FTP, VoIP, and game servers –  alecwhardy Nov 9 '11 at 3:02
add comment

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.

share|improve this answer
add comment

You have these solutions the are easy to implement:

  • DNAT rule in a firewall to change the destination port for the local traffic to the port dedicated for the local traffic
  • Listen on external_IP:same_port for external app and listen on internal_IP:same_port for internal application. In this way you have both applications running, and using the same port, but different IPs.
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.