With Valve announcing that Steam will finally be coming to Linux and the fact that “Left 4 Dead 2″ the popular multiplayer zombie shooter will be first to get the Linux treatment, I thought it would be a good idea to run through how to set up a dedicated Left 4 Dead 2 Linux server. In general, this article will focus on CentOS/Fedora based systems, but there is very little different between those distributions and Ubuntu/Debian-based systems aside from the firewall configuration.

First you’ll need to set up a user for the server as this is good security practice. Enter the following commands as root (putting “sudo” in front if you’re using Ubuntu):-


adduser l4d2
passwd l4d2

Drop down from root to the new “l4d2″ user: -

su - l4d2

Now you need to download the Steam HLDS update tool using “wget”. If you don’t have wget installed use your package manager to download and install it: -

wget http://www.steampowered.com/download/hldsupdatetool.bin

Make this binary executable with: -

chmod +x hldsupdatetool.bin

Now run the executable, scroll past all the legal guff and type “yes” when prompted.

./hldsupdatetool.bin

Under Fedora at least, now is the time you might come across an error such as: -

sh: command uncompress not found

This is because you need to install the “ncompress” package which contains the “uncompress” command that the installer is missing. “Exit” back to the root user and install with the following under Fedora: -

yum install ncompress

Then “su – l4d2″ back to the l4d2 user and continue. If you do an “ls” on the directory, you’ll see several new files, one of which is called “steam”. Run this command with: -

./steam -command update -game left4dead2 -dir ~/hlds -verify_all

This will take a fairly long time as this is the ‘meat’ of the server download. So go and make a cup of tea or something for ten minutes. Also, when new DLC comes out for Left 4 Dead 2 or the server software gets updated by Valve, you may need to periodically rerun this command.

Once this is done, you should see something similar to: -


Checking bootstrapper version ...
Getting version 49 of Steam HLDS Update Tool
Downloading. . . . . . . . . . . .
Steam Linux Client updated, please retry the command

After you have all the game files you need a server configuration file, so open up a new file called “server.cfg” using “vi”: -

vi ~/hlds/left4dead2/left4dead2/cfg/server.cfg

Below is a simple example server config file, with a slightly more complex one that explains a few more of the options for you. If you find that your server config doesn’t meet your needs, check Google to find all available configuration options for this file.


hostname "Night of the Living Server" // Server Name
rcon_password "mypassword" //Set remote control password
sv_lan 0 // Disable LAN
mp_disable_autokick 1 // Disable Autokick
sv_cheats 0 // Disallow Cheats
sv_clearhinthistory 0 //Clear Server Side Hint History
sv_consistency 1 //Enforce file consistency
sv_pausable 0 //Server not pausable
sv_allow_lobby_connect_only 0 // Disable Lobby Connections
sv_voiceenable 1
sv_alltalk 1
sv_region 3 // set this to your region if required (3 = Europe)
//sv_steamgroup 999 // set this if required
z_difficulty hard
sv_search_key "blah"
sv_gametypes "coop"

…and here is a slightly more complex one showing more options…


hostname "" // Hostname for server.
rcon_password "
" // remote console password.
sv_password "" // Password protects server
sv_gametypes "versus,survival,coop,realism,teamversus,teamscavenge" // Allowable game types of the server

// Here is stuff that you only need to think about if you want to associate your server with a Steamgroup
// sv_steamgroup 0 // The ID of the steam group that this server belongs to. You can find your group's ID on the admin profile page in the steam community.
// sv_steamgroup_exclusive 1 // If set, only members of Steam group will be able to join the server when it's empty, public people will be able to join the server only if it has players. (I've heard that there's a third option (2) that if set it will be exclusively for steam group members)
sv_allow_lobby_connect_only 0 // If set, players may only join this server from matchmaking lobby, may not connect directly.

// Server Cvars
sv_alltalk 0 // Players can hear all other players' voice communication, no team restrictions
sv_cheats 0 // Allow cheats on server
sv_clearhinthistory 0 // Clear memory of server side hints displayed to the player.
sv_consistency 1 // Whether the server enforces file consistency for critical files
sv_contact "" // Contact email for server sysop
sv_pausable 0 //Is the server pausable.

// Lan or internet play, Server region cvars
sv_lan 0 // Server is a lan server ( no heartbeat, no authentication, no non-class C addresses )

// #REGION
// eastcoast - sv_region 0
// westcoast - sv_region 1
// south america - sv_region 2
// europe - sv_region 3
// asia - sv_region 4
// australia - sv_region 5
// middle east - sv_region 6
// africa - sv_region 7
// world - sv_region 255
sv_region 3

// Server Logging
sv_log_onefile 0 // Log server information to only one file.
sv_logbans 1 // Log server bans in the server logs.
sv_logecho 1 // Echo log information to the console.
sv_logfile 1 // Log server information in the log file.
sv_logflush 1 // Flush the log file to disk on each write (slow).
sv_logsdir "logs" // Folder in the game directory where server logs will be stored.

// bandwidth rates/settings
sv_minrate 20000 // Min bandwidth rate allowed on server, 0 == unlimited
sv_maxrate 30000 // Max bandwidth rate allowed on server, 0 == unlimited
sv_mincmdrate 10 // This sets the minimum value for cl_cmdrate. 0 == unlimited
sv_maxcmdrate 33 // (If sv_mincmdrate is > 0), this sets the maximum value for cl_cmdrate

//Difficulty Settings
z_difficulty Hard // Difficulty of the current game (Easy, Normal, Hard, Impossible)

// Voice Comm
sv_voiceenable "1"

// Ban stuff
writeid // Writes a list of permanently-banned user IDs to banned_user.cfg.
writeip // Save the ban list to banned_ip.cfg.
exec banned_user.cfg // Execute the banned_user list
exec banned_ip.cfg // Execute the banned_ip list

Now to check to see if everything is running properly…


cd ~/left4dead2
./srcds_run -game left4dead2 +maxplayers 4 +ip [YOUR_IP_ADDRESS_OR_HOSTNAME_HERE]

You can issue commands to the server here or use the Screen utility to to connect/disconnect from the server session. Obviously, if you want, you can use: -


cd ~/left4dead2
nohup ./srcds_run -game left4dead2 +maxplayers 4 +ip [YOUR_IP_ADDRESS_OR_HOSTNAME_HERE] >> l4d2.log &

…to run the server process in the background and write all events to a log file. Once the process is working fine, you need to configure your firewall to open up the ports that Steam uses. Either see my article on iptables firewall configuration if you want to make the changes permanent or run the following: -


iptables -A INPUT -p udp -m udp --dport 27000:27030 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 27014:27050 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 4380 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 3478 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 4379 -j ACCEPT
iptables -A INPUT -p udp -m udp --dport 4380 -j ACCEPT

If you’re using Ubuntu, UFW is used instead of iptables. See my article on how to configure the Ubuntu firewall here. The last thing you might want to do is set up some custom banners and Message of the Day (MOTD) pages. These are essentially just web pages that are displayed ingame in their boxes. You could in theory put whatever you want there as long as it’s a web page such as an image logo or whatever.

But for this we will go with the basics, a simple image for both Host and MOTD. For this to work you need to be able to host web pages using Apache or something similar. For the HOST Banner go and create a graphic that is 605×121 pixels and for the MOTD create a 1076×538 pixel image. Upload them to your Apache install (usually /var/www/html/images) and create two web pages. They can be named whatever you like but for simplicity’s sake we’ll use “host.jpg” and “motd.jpg” for the images and “host.html” and “motd.html” for the actual pages.

Both web pages have the same source code but with the path to different image (one for the MOTD and the other for the Host banner): -

<html>
<head><title>Left 4 Dead 411</title></head>
<body style="margin:0px;padding:1px;background:#000000;">
<img src="<path to my image/>" style="width:100%;height:100%;" />
</body>
</html>

Next we need to edit the host.txt and motd.txt files on the server. These files are located in “left4dead2/left4dead2″ directory not the “cfg” sub-directory where the “server.cfg” file is located. In each file you put the URL to the respective HTML file. After this is done you restart the server and the changes should take effect immediately.

Happy zombie shooting!

Leave a Reply

Search The Node
XBox LIVE Gamertag
The Node Downloads
Mini Tweets

Switch to our mobile site