Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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[portnumber]. Is there a way that I can configure CentOS to automatically take something like and transform it to[portnumber] or simple localhost:[portnumber]? Is this what a DNS is for?


share|improve this question

migrated from Sep 10 '11 at 12:10

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

I don't get why this was downvoted. It's a legitimate question. – Chris Thorpe Sep 11 '11 at 0:43
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 SRV record in order to give the user a way to use 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

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>
    Redirect permanent /

<VirtualHost ip.add.of.server>
    Redirect permanent /
</VirtualHost> can be same server, You must add new A record on DNS.

share|improve this answer
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

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

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

Your Answer


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.