This guide covers the setup of Half Life / Source based games on a Linux server using the Source Dedicated Server (SRCDS). This can be applied to games such as Counter Strike Source (CS:S), Day Of Defeat Source, GarrysMod, Team Fortress 2 (TF2) and many more.

Step 1: Tunnel Setup

Setup your tunnels if you have not already, you should ensure the tunnel is added to your init system to run at boot.

X4B Ports

Add a port for your server, forwarded to the GRE Tunnel. You can often identify this port using netstat:

# netstat -lnp | grep srcds_linux
tcp 0 0 10.17.22.2:27015 0.0.0.0:* LISTEN 6305/srcds_linux
udp 0 0 10.17.22.2:26901 0.0.0.0:* 6305/srcds_linux
udp 0 0 10.17.22.2:27005 0.0.0.0:* 6305/srcds_linux
udp 0 0 10.17.22.2:27015 0.0.0.0:* 6305/srcds_linux
udp 0 0 10.17.22.2:27020 0.0.0.0:* 6305/srcds_linux

In this case the UDP ports 26901, 27005, 27015 and 27020 are required. The TCP port 27015 is also required.

All these ports should be configured on for your service using the Tunnel type ports to forward to your configured GRE tunnel.

Step 2: 32bit libraries (for 64bit servers only)

If you are on a 64bit server you will first need to install 32bit libraries to run SteamCMD. On Debian based distributions this is done with:

dpkg --add-architecture i386
apt-get update
apt-get install ia32-libs

Step 3: Downloading SteamCMD

Follow the instructions for downloading SteamCMD on Linux: https://developer.valvesoftware.com/wiki/SteamCMD#Linux

Step 4: Install Game Server

Follow the instructions for downloading the Game Server on Linux: https://developer.valvesoftware.com/wiki/SteamCMD#Linux_2

A list of Steam AppID's can be found at: https://developer.valvesoftware.com/wiki/Dedicated_Servers_List

Common Games

To download Counter Strike Source:

app_update 232330 validate

To download Garry's Mod:

app_update 4020 validate

Step 5: Running the server

Change directory into the game installed directory, e.g

cd ~/Steam/steamapps/common/Counter-Strike Source Dedicated Server

Run the game server

Counter-strike Source:

./srcds_run -game cstrike +maxplayers 20 +map de_aztec -ip <INTERNALIP>

GarrysMod:

./srcds_run -game garrysmod +maxplayers 20 +map gm_flatgrass -ip <INTERNALIP>

Where is the internal IP of your servers GRE network, if you have only one GRE tunnel on this server this can be retrieved with:

ip addr | grep 10.17.

Step 6: Further Setup

Add the game server to your init system to run on boot. Ensure the game is started AFTER the tunnel setup script.