Tutorial: How to setup a Dedicated Left 4 Dead 2 (L4d2) server on Linux (CentOS 5.6)

Most of the tutorials out there are dated or missing fixes that required time and effort to search and resolve. I am throwing this together as I go through the installation in the hopes it saves someone else some time. As always feel free to comment for help. I’ve run valve based servers on/off for about 10 years (CS, TFC, CS:S, TF2, L4d and L4d2).

In the next tutorial I will outline how to leverage cloud servers for an On-Demand Left4dead2 Server. No need to pay monthly fee’s for a server you use a couple times a month with your buddies. You will be able to start/stop the server within minutes, and only pay for what you use – pennies on the hour for a faster machine than you’d get with a monthly game server provider.

Format a server with centos 5.6 and login as root install screen if its not installed already:

yum install screen

launch new screen session:

screen

change root password

passwd

create user to run l4d2 hlds service

adduser l4d2

Change the password for the new user

passwd l4d2

install 32bit c++ library (needed by HLDS)

yum install libstdc++.i386

Add symlink to gunzip to avoid error durring HLDS installation

ln -s /bin/gunzip /bin/uncompress

Lets open up a couple ports on the default IPTABLES firewall so L4d2 desktops can access our server

nano /etc/sysconfig/iptables

Paste the following rules directly above this line”-A RH-Firewall-1-INPUT -j REJECT –reject-with icmp-host-prohibited”

-A RH-Firewall-1-INPUT -m udp -p udp --dport 27015 -j ACCEPT
-A RH-Firewall-1-INPUT -m udp -p udp --dport 27005 -j ACCEPT
-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 27015 -j ACCEPT
-A RH-Firewall-1-INPUT -m tcp -p tcp --dport 27005 -j ACCEPT

Restart IPTABLES so this new configuration takes:

service iptables restart

Verify new configuration is in place:

iptables -L

Switch to l4d2 user

su - l4d2

Download HLDS Update tool:

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

Make the download executable and launch it

chmod +x hldsupdatetool.bin && ./hldsupdatetool.bin

Download L4d2 server

./steam -command update -game left4dead2 -dir “.”

You’ll need a STEAM GROUP ID to associate with your server. Create a new group if necessary:

  • On your desktop, right click steam taskbar icon > Community
  • Select "Groups" then "Create new group".
  • Fill out the details, attach an awesome avatar, hit ok, invite your buddies.
  • Click on group admin options on the groups profile page > select edit.
  • Note your Group ID, copy this number for use in the next step.

Create the ever important server.cfg file

nano ~/left4dead2/left4dead2/cfg/server.cfg

Paste this as a starting point:

//Server name
hostname "Your L4D2 Server Name" // Server Name

// RCON password to administer server from ingame, change maps etc.
rcon_password "YOUR_RCON_PASSWORD_HERE"

// Set a search key to help join your server from ingame
// This can be anything, but make it unique
sv_search_key "YOUR_SEARCH_KEY"

// Server Admin Contact
sv_contact "YOUR EMAIL ADDRESS HERE" 

// Disable LAN - Leave this as 0
sv_lan 0

// Host game server port (default 27015)
hostport 27015   

// Region - This sets the lobby in which your server will be part of
// You will want to set this to the closest location to your server
// 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 1 

// Set gametypes (whichever you plan to use the server for, likely only versus)
// options: versus, coop, survival
// to do versus and coop "mp_gametype "versus,coop"
sv_gametypes "versus"

// Allow connections without creating lobby
sv_allow_lobby_connect_only 0

// Steam group # to assign to server
sv_steamgroup "YOUR_STEAM_GROUP_ID_HERE"

// Disable Autokick
mp_disable_autokick 1 

// No Cheating!
sv_cheats 0 		 // Disallow Cheats

// Misc.
sv_clearhinthistory 0    //Clear Server Side Hint History
sv_consistency 1         //Enforce file consistency
sv_pausable 0            //Server not pausable
sv_voiceenable 1         // enable voice communication
sv_alltalk 0             // You can switch this in game using rcon, best to leave it off by default
z_difficulty hard

// LOGGING
log on              //Creates a logfile (on | off)
sv_logecho 0        //default 0; Echo log information to the console.
sv_logfile 1        //default 1; Log server information in the log file.
sv_log_onefile 0    //default 0; Log server information to only one file.
sv_logbans 1        //default 0;Log server bans in the server logs.
sv_logflush 0       //default 0; Flush the log files to disk on each write (slow).
sv_logsdir logs     //Folder in the game directory where server logs will be stored.

//Network Tweaks - Increase network performance
sv_minrate 15000    //default "5000"; Min bandwidth rate allowed on server, 0 = unlimited
sv_maxrate 30000    //default "0";  Max bandwidth rate allowed on server, 0 = unlimited
sv_mincmdrate 20    //default 0; This sets the minimum value for cl_cmdrate. 0 = unlimited [cevo=67]
sv_maxcmdrate 33    //default 40; (If sv_mincmdrate is > 0), [cevo=101]

Be sure to change the following variables in the above configuration: hostname, rcon_password, sv_region, sv_steamgroup, sv_search_key

Determine what IP is attached to the outside interface (eth0):

/sbin/ifconfig
Look for the "inter addr:" line next to eth0, this is your outside accessible IP

Start the Left4Dead server with the above noted IP:

~/left4dead2/./srcds_run -game left4dead2 +maxplayers 8 +ip YOUR_SERVER_IP +map c5m1_waterfront -console

To connect to your server from in game, you need to issue these commands in your desktop console. You need to do this before you start a lobby. This tells steam to use your server when it searching for a server from lobby:

mm_dedicated_force_servers YOUR.SERVER.IP.ADDRESS
sv_search_key "YOUR_SV_SEARCH_KEY_FROM_SERVERCFG"

Developer Console on your local desktop can be enabled from Keyboard options > Advanced

Thanks to James for his original L4d2 server guide which this article is based on, located here: http://jamespo.org.uk/wp/archives/862

Subscribe

Subscribe to our e-mail newsletter to receive updates.

3 Responses to “Tutorial: How to setup a Dedicated Left 4 Dead 2 (L4d2) server on Linux (CentOS 5.6)”

  1. mr_pyro January 13, 2012 at 12:47 am #

    just download http://gamecp.com/ it is there whit 100 games.
    read the wiki page install it, ask for a tral key off 30 days, download the l4d2 cfg, install the game (45 Sec) and readdy to play.
    And you have a game control panel that is verry easy to use

    • iainlbc January 13, 2012 at 11:22 am #

      Using control panels and taking the easy route will teach you nothing in terms of server administration or how (game) servers actually function.

      It's sort of the equivalent of installing a GUI interface on a server; A GUI just makes it easier to do things, at the cost of not knowing how to fix things when they break because you are so separated from what's actually happening underneath the GUI.

      That said, I appreciate the comment and some readers may find it useful :)

      Cheers

  2. Sachin Sud February 21, 2012 at 3:14 am #

    Well nice tutorial

    Thanks,

Leave a Reply