Part 1 : Setting up the environment and installing the server

Nothing is worse than high latency (lag) in online games,  especially in Left 4 Dead 2 when you’re trying to have a relaxing zombie shooting session with couple of friends.  The best way to combat this is playing on a Dedicated server.  Which is exactly what I set out to do,  getting L4D2 dedicated server to run on my linux box.

I didn’t find any good comprehensive guide on how to do this for linux that tackled this adequately so after lots and lots of googling and running into weird problems (mainly concerning running srcds_run using nohup) I finally have a running dedicated Left 4 Dead 2 server with easy way to run it in the background. So let’s get started shall we.


This is part 1 of a 4 part series on how to set up and config a Left 4 Dead 2 dedicated server on CentOS Linux.

Part 1 : Setting up the environment and installing the server

Part 2 : Firewall configuration

Part 3 : Monitoring the dedicated server.

Part 4 : Extras.  Host and MOTD banners, Exclusive servers and lobby.


I find it wise to create a seperate user account to run the server, creating a new user is as straightforward as

# useradd SteamServer

This should create the user SteamServer, create a home directory for it in /home/SteamServer and give it the default shell (i.e. /bin/bash).

Let’s go into our new user using “su SteamServer -“.  We should now be masquerading around as the new user,  I like to keep things in the Home directories tidy so let’s create a new folder to store all our game files,

$ mkdir hlds
$ cd hlds

Next we need the files,  this is the easy part.  First we get the HLDS update tool.

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

This is a self extracting binary file,  we need to make it executable and then execute it.

$ chmod +x hldsupdatetool.bin
$ ./hldsupdatetool.bin

This should extract the binary file and leave us with bunch of files,  amongst them should be a “steam” file. We use this Steam file, or client if you prefer, to download the game using the “-command update” switch.

$ ./steam -command update -game left4dead2 -dir /home/SteamServer/hlds

this can take a very very long time,  if your linux box is on the local network and you happen to have Left 4 Dead 2 installed on your gaming computer then you can speed up the progress by copying the “Left 4 Dead 2″ folder from C:\Program Files (x86)\Steam\steamapps\common”,  make sure you rename the folder to “Left4Dead2″ though (remove the spaces) otherwise it might not work.  After that you just need to run the update command with the -verify_all switch which will verify all files and download the missing linux server files which will take considerably less time than downloading everything fresh.

$ ./steam -command update -game left4dead2 -verify_all

After you have all the game files you need a server config,  open up “server.cfg” in the  “~/hlds/left4dead2/left4dead2/cfg” directory.  I’m no expert on the settings but this is similar to what I used to begin with. I think Google will be more help to you than me regarding server configuration to suit your needs.  Remember that you can get command help from the server console while it’s running by typing in “help <command>”.

hostname "<insert your server name here>" // Hostname for server.
rcon_password "<insert some password here>" // 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 "<your email here>" // 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 that we have the configuration file it’s time to test if everything is working.  To start the server we use the srcds_run executable in the ~/hlds/left4dead2/ directory.

UPDATE : There is no need to specify any configuration file if you are using the default server.cfg file.  It’s only if you want to use a config file other than server.cfg, for example if you are running multiple servers each with it’s own configuration file like server01.cfg, server02.cfg etc, that you need to specify the file, To specify a file other than server.cfg use the +servercfgfile parameter,  do not use +exec. This is important if you have any plugins on the server and have plugin specific commands in your server configuration file.  With +exec the file is executed before the plugin is loaded and thus the commands will fail.  However +servercfgfile is executed after all plugins have loaded.

$ ./srcds_run +hostport 27015 +servercfgfile CustomServerConfig.cfg +map c5m1_waterfront -game left4dead2  -ip 10.10.10.10

Just make sure you change the IP to whatever IP your server has. –  If everything works as intended alot of lines should scroll upp and at the end you should see something similar to this :

[snip]
---- Host_NewGame ----
Host_NewGame on map c5m1_waterfront
ConVarRef room_type doesn't point to an existing ConVar
Executing dedicated server config file
Initializing Director's script
Couldn't find any entities named spawn_fryingpan_demo, which point_template template_demo is specifying.
WARNING: orator at 777 677 -418 missing modelname
Attempting to precache model, but model name is NULL
jukebox_script executing script: jukebox_main
Commentary: Loading commentary data from maps/c5m1_waterfront_commentary.txt.
Initializing Director's script
baseuser.cpp (431) : Assertion Failed: couldn't find entrypoint 'GetBaseUserDir'
Setting breakpad minidump AppID = 550
Looking up breakpad interfaces from steamclient
Calling BreakpadMiniDumpSystemInit
Writing cfg/banned_user.cfg.
Writing cfg/banned_ip.cfg.
Connection to Steam servers successful.
   VAC secure mode is activated.

don’t be alarmed if there are alot of errors,  for example if I start with the default map I get a bunch of messages about missing entities, for example :

Couldn't find any entities named fire_ballroom_07-hurt, which point_template fire_ballroom_07-template is specifying.
 Couldn't find any entities named fire_ballroom_07-sound, which point_template fire_ballroom_07-template is specifying.

From what I can gather on google there are alot of people getting these messages and it’s considered to be “normal”,  If you’re unsure about some of the errors just google them and see if you can find someone else getting the same errors and what they did about them.

That’s it for now, make sure to check out part 2.

Tagged with:
 

5 Responses to Left 4 Dead 2 Dedicated Server on Linux : Part 1

  1. MAC says:

    I tried to follow these instructions but failed at the command

    ./steam -command update -game left4dead2 -verify_all

    which said “Failed to create directory”

    It worked once I added -dir . to tell it to look in the CWD

  2. Andy says:

    Great guide, I got my server up and running in no time!

  3. […] Part 1 : Setting up the environment and installing the server […]

  4. D1G1T4L3CH0 says:

    Sometimes users may experience a problem with a library from gcc.

    error while loading shared libraries: libgcc_s.so.1

    If they do receive this error, they only need to install the gcc-multilib package.

    Source: http://forums.steampowered.com/forums/showthread.php?t=2821860

  5. goarilla says:

    And now your dedicated server gets compromised, and the attacker can wipe the SteamUser’s home and the entire dedicated service. Install/Update the server as root but run it as the normal user. Just like an apache’s documentroot isn’t owned by the apache user. Additionally you can chown the server’s cfg files to a “left 4 dead 2 admin group”.