Re: [hlds_linux] Which ports are SRCDS binding to?

For the gentleman inquiring about what ports SCRDS use, how to tell which ports 
it's using, etc., here is a little write-up that might help.  For everybody 
else on here, this is probably a little bit long-winded and stuff you already 
know. I had deleted the original thread, so I don't see a why to reply directly 
to that inquiry.   So my apologies in advance, I hope I am not breaking 
Etiquette this long post.

First of all since this is a Linux mailing list, you can use the "netstat" 
command to show which ports various software has open on your system, and which 
processes are associated with those ports.  You can try "netstat -lptu" and see 
if that works for you.  The output can be long so maybe "netstat -lptu | more" 
or pipe it to a file and open it in an editor.  Of course "netstat --help" for 
more information on that command.  It won't show you what game is running on 
which port if you are hosting multiple games, but it will show you either 
"hlds_i686" (for GoldSrc/HL1 games) or "srcds_linux" (for Source/OrangeBox 
games).

Unfortunately, just knowing which ports the games are using right now, isn't 
always helpful because some of it is dynamically assigned, and may change every 
time the game server is re-launched.  However, you can specify EXACTLY which 
ports you want your game server(s) to use.  In fact, if you are running 
multiple simultaneous game servers on the same computer, you need to do this to 
ensure they will coexist.  This is typically also helpful, so that you know 
exactly what firewall changes are needed to accommodate running the games.

Each game server instance uses TWO ports - that's right TWO.  TWO at least that 
need to be opened for in-bound traffic to your game server(s).  I have noticed 
lately game servers also opening additional UDP ports dynamically, but nothing 
that seems to require being allowed at my firewalls.

The first is for client-server communication, for players to actually join the 
game and all client-server communication happens on this port.  Most games are 
already familiar with that port, and it's default being the famous "27015".  If 
you don't specify what port for a game to use for that setting, it defaults to 
"27015".  So for each simultaneous game server you will be running, you need to 
manually override that to a different port (27016, or whatever you like - but 
what you use has to be opened on your firewall).

This port can be specified in your start-up command-line parameter's for the 
game using the "+port NUMBER" option - where NUMBER is whatever port number you 
want to use.  This parameter is the same on both "GoldSrc" games (HL1, CS, TFC, 
DOD, DMC, etc.). Instead of specifying this command in the startup, it may 
alternatively be placed into your "autoexec.cfg" file.

All games running on the older (HL1/GoldSrc) engine running on Steam, and the 
newer (HL2/Source/OrangeBox) engine running on Steam also use a SECOND port - 
to communicate with the Steam network.  Not sure exactly what goes on there, 
but appears to be Steam authentication and anti-cheat stuff. I noticed it a few 
years ago, I think it must have been about the time VAC was implemented.

Unlike the game port, this port seems to be dynamically chosen at start-up of 
the game, and consequently does not HAVE to be specified at the command-prompt 
or an "autoexec.cfg" file or anything like that.  However, since it's 
dynamically chosen at startup, this makes it difficult to make work through 
some firewalls reliably. So, I always set mine explicitly to known values, and 
then ensure I open that port on my firewalls appropriately.

The command-line parameter for what port the game will use for talking to the 
Steam network has a slightly different syntax for GoldSrc engine games compared 
to Source/OrangeBox games.  For GoldSrc game's it's "-sport NUMBER", whereas 
for Source/OrangeBox games, it's "-steamport NUMBER".

For all the games I am going to run (or for all the network-related stuff I 
going to have running on a server at all - game related or not), it's handly to 
keep a spreadsheet or at least a text file listing what's using what ports - 
and work-out what ports you will assign to what ports in advance.

I tend to run all my games on non-default ports (i.e. never 27015).  This is 
mostly force of habit for me, to avoid conflicting with anything a game client 
might be trying to use behind the same firewall.  So, I usually start at like 
28015 instead of 27015, and add one for for each game - to use for it's "+port" 
parameter. I also like to jump 1000 for Source/OrangeBox games verses GoldSrc 
games.  Then, for the "-sport" or "-steamport" parameter, I add 100 to each.  
This doesn't mean you need to follow that convention by any means.  You can use 
virtually any numbers you like (in the 1-65535 range), as long as it's not used 
already for something else (generally stay up in the 27000+ range and you're 
Ok).  This convention is just what I find easy to use.  This convention leaves 
me with something like this:

Game ports for each ...
28015 = Game port for HL1 server.
28016 = Game port for TFC server.
28017 = Game port for CS server.
29015 = Game port for HL2 server.
29016 = Game port for TF2 server.
29017 = Game port for CS:S server.
...etc.

Steam ports for each ...
28115 = Steam port for HL1 server.
28116 = Steam port for TFC server.
28117 = Steam port for CS server.
29115 = Steam port for HL2 server.
29116 = Steam port for TF2 server.
29177 = Steam port for CS:S server.

So, in summary ...
(note that the "+" and "-" characters are significant on the command-line 
parameters)

For: GoldSrc games (HL1, TFC, CS, etc.):
 +port {port number to run the game on}
-sport {port number for this game to talk to Steam network}

For example:
hlds_run -secure -game tfc +port 28016 -sport 28116

For: Source/OrangeBox games (HL2, TF2, CS:S:, etc.):
+port {port number to run the game on}
-steamport {port number for this game to talk to Steam network}

For example:
srcds_run -secure -game tf +port 29016 -steamport 29116


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux

Reply via email to