## Sunday, November 30, 2008

### Left 4 Dead - Private Dedicated Ubuntu Server 8.1

The purpose of this guide is to create a private server that a community can be built round as the current matchmaking system deployed by Valve otherwise makes this impossible (as the lobby system will connect you to any public and available server out there).

Note: a dedicated server will be installed on either on a dedicated physical machine or in a virtual machine with dedicated resources, and should be configured with a static ip address [either in the networking configuration or via a DHCP assignment in your router]. I have my server running in a virtual machine ...

If you are installing a Virtual Machine boot from the .iso, press F4 on the first screen and select "Install a minimal virtual machine" - this will install version 8.1 of Ubuntu JeOS. Otherwise install a vanilla installation of Ubuntu Server on your box. The first two pages of this guide will show you step by step how to install Ubuntu Server (we will assume that the account for the Ubuntu installation is "l4d" and not administrator).

Note: For my virtual machine I set aside 10Gb of disk space - you may be able to get away with less, but as you can see Ubuntu JeOS and Left 4 Dead occupy almost 3 Gb on /dev/sda1:

Now that we have the preliminaries taken care of let's update the installation:

sudo apt-get update

sudo apt-get upgrade

Install SSH for remote management:

sudo apt-get install openssh-server

sudo apt-get install wget

Create a directory for the Left 4 Dead installation and then cd into the new directory:

mkdir hldscd hlds

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

Make the hldsupdatetool executable:

chmod +x hldsupdatetool.bin

Run the hldsupdatetool:

./hlsupdatetool.bin

Type yes to the agreement and then click enter to continue.

Make Steam executable:

chmod +x steam

./steam -command update -game l4d_full -dir /home/l4d/hlds

Note: you will most likely be prompted to run the last command again as the first time it runs it will update steam and not install Left 4 Dead.

Left 4 Dead files will now install to /home/l4d/hlds/l4d\left4dead\ - this may take some time, so you may want to make a few cups of tea or something ...

Once the download is complete we need to create a server configuration file [server.cfg] and a script to run the server with particular parameters.

Create a file called server.cfg and copy it [using SSH if necessary] to /home/l4d/hlds/l4d/left4dead/cfg.

Your server.cfg should look something like this:

hostname "Left 4 Dead"rcon_password "myrconpassword"sv_allow_lobby_connect_only 0sv_password "mypassword"

Change the hostname to whatever you want. The rcon password is for remote administration of Left 4 Dead when the server is running. sv_allow_lobby_connect_only 0 allows for players to connect directly to your server without using the Left 4 Dead lobby system. sv_password sets a password for gamers to play on your server.

Now create a file called autoexec.cfg (in the same folder as server.cfg):

z_difficulty normal

z_difficulty normal sets the default difficulty of the server to normal - you can set this to easy, normal, hard, or impossible.

Next we will create a script to run the game server as follows:

#!/bin/bashcd /home/l4d/hlds/l4d./srcds_run l4d -autoupdate -console -maxplayers 8 + sv_lan 0 +hostip xx.xx.xx.xx +ip xx.xx.xx.xx +hostport 27015 +exec server.cfg +map l4d_hospital01_apartment

Save the script as "startl4dserver.sh" and upload it to the home directory of the server.

-console: This will display a console that you can type commands into.

-game left4dead: This specifies that the server will run Left 4 Dead.

-maxplayers 8: This will specify the maximum number of players the server will allow, setting it to 8 should allow you to use versus mode, otherwise set it to 4 for survivors only gameplay.

-autoupdate: This will make the server check and update to the latest version when you launch it but this needs a manual fix to work properly.

+ip: where xx.xx.xx.xx is the static LAN address configured earlier.

-port 27015: This will specify the port for the server to run on [27015 is the default port]. +sv_lan 0: This will force the server to run on the internet instead of just on a lan.

+map l4d_hospital01_apartment: This will specify the map that the server will start with [and must be configured]. You will find all the available map names on your server here: /home/l4d/hlds/l4d/left4dead/maps

At this point you can run the server as follows:

./startl4dserver.sh

To connect to the server from your (LAN) gaming machine you will need to enable the "Developer Console" in the game options as follows: At the main menu, select "Options", then choose the "Keyboard/Mouse" selection. Enable the "Allow Developers Console" option.

You can then use the ~ key to bring up the console and then type:

connect xx.xx.xx.xx

Where xx.xx.xx.xx is the LAN ip address of the server.

To allow internet users to connect you will need to open ports 27000 to 27050 in your router firewall. I also forwarded 27015 directly to the server LAN address just for good measure.

Friends connecting from the internet will then be able to connect to the WAN ip address of your server using the password that you provided them.

Note: if your router supports it you may be able to dispense with +ip and +hostip in your command line. If this is the case you will simply be able to connect to your server from a LAN PC by connecting to you WAN address.

BarkerJr said...

Please note that you should use autoexec.cfg for z_difficulty, not server.cfg. See: http://forums.steampowered.com/forums/showthread.php?t=759749

Also, -autoupdate does not work without this workaround: http://www.dbaranski.net/node/6

doa said...

Thank you very much for your input BarkerJr, I have updated the blog post accordingly!

Much appreciated, doa.

MJ said...
This comment has been removed by the author.
MJ said...

You might want to note that for x64 version of Ubuntu you have to install lib32gcc1 before you can do ./hldsupdatetool.bin

You will get the error...
bash: ./hldsupdatetool.bin: No such file or directory

MJ said...

Be sure that your directory exists when you run the steam command for the second time (after STEAM updates). You will get an InstallRecord.blob error if it doesn't.

So:
mkdir [yourDirectory]
./steam -command update -game l4d_full -dir [yourDirectory]

... this assumes you created a slightly different folder structure than listed above.

Mike said...

Thanks for the additional info for Ubuntu x64 MJ.

dougdashwitz said...

i are ooober newber, that being said, how do i go about creating the server.cfg and such files? As in, what command do i type to create the new file and then how do i go about editing it? Its probably something really simple, yet it escapes me.

Thanks and sorry to bore you with stupid questions

Mike said...

Just open a text editor and save the file as "server.cfg".