In this tutorial, I’m using a dedicated server running Ubuntu to host a Left 4 Dead 2 server. These instructions will also work for the first Left 4 Dead.
Install the necessary packages.
sudo apt-get update
sudo apt-get install lib32gcc1 screen wget
Create a directory for the L4D2 server.
mkdir ~/l4d2 ; cd ~/l4d2
Retrieve and extract SteamCMD.
tar -xvzf steamcmd_linux.tar.gz
The program will update itself and you’ll be brought to a Steam prompt.
You’ll have to login with a Steam account that has purchased L4D2 in order to proceed. It seems that you can now login anonymously.
login <username> <password>
It should then prompt you for a Steam guard code, so enter that. Next, set the installation directory and let SteamCMD start downloading all of the necessary files. (Make sure you specify an absolute path)
app_update 222860 validate
That part will take a while. After it’s complete, you’re ready to run your server. To install L4D instead, use 222840.
But there are a few things you should do first.
1. Create a server.cfg file
I only bother configuring a few settings, and leave all other cvars at their default values.
hostname "sample hostname"
Some resources to check out for more in-depth server.cfg editing:
2. Decide what kind of variables you want to pass to srcds_run.
~/l4d2/game/srcds_run +ip 192.168.1.150 -port 27015 +map c1m4_atrium -secure
More information here:
I just put that code above into a script and then execute it inside of a screen session, disconnect from the screen, and start playing.
screen -S l4d2 ~/start-server.sh
Ctrl + A, D to disconnect from screen.
Connecting to your server
You can open the developer console and connect to your server via IP address with this command:
Alternatively, you can create a lobby and configure your game to only try connecting to your server when you click “Start game.”
Only problem is, every time you boot up L4D2 and want to connect to your server, you’ll need to remember that command and your IP address. To avoid that, put the command in a .cfg file and store it here:
C:\Program Files (x86)\Steam\SteamApps\common\left 4 dead 2\left4dead2\cfg\myserver.cfg
When in game, just execute your cfg file and you’re good to go.
Remember to forward port 27015 on your router.