Use case · Game server

Left 4 Dead 2 dedicated server on bare metal: install, configure, open the ports

A Left 4 Dead 2 dedicated server on Linux is SteamCMD app 222860, downloaded with an anonymous login and started by srcds_run with -game left4dead2 on port 27015. This page takes it from a clean x86-64 Ubuntu install to a systemd service: the 32-bit libraries the Valve Developer Community lists, the server.cfg cvars that decide who can join, the firewall rules and how updates arrive. It runs on a whole game server machine with root.

See the machines

What srcds needs from the hardware

Very little by modern standards; the constraints are the CPU architecture and the network, not the size of the box. The Valve Developer Community (VDC) publishes no Left 4 Dead 2 sizing figures. Its generic Source Dedicated Server page is old and approximate, so read the table as a floor, not a plan.

ItemWhat the VDC saysWhat follows for the machine
ArchitectureSteamCMD is a 32-bit binary and needs 32-bit libraries on 64-bit LinuxOur reading: an x86-64 line, with the lib32 packages installed
Memory512 MB minimum, 1 GB for over 60 player slots, 4 GB or more advised on newer operating systems (generic SRCDS page)Memory is rarely the limit; it is room for several instances
Idle loadsv_hibernate_when_empty defaults to 1: very low CPU use with no clients connectedAn empty instance costs almost nothing
NetworkUpload bandwidth is what a server uses; 27015 TCP/UDP must accept unsolicited inbound connectionsA public address and an open port, no NAT in the way

A single machine can carry several servers. Give each its own install folder (a second force_install_dir, such as /home/steam/l4d2-b), its own server.cfg in that folder, its own systemd unit and its own -port: 27016 for the second. Open that port's UDP to players and its TCP only to your admin address, because RCON follows -port.

Choosing the machine

Pick an x86 line and a city near your players. The machines on our game server page are whole servers: every core and all the memory are yours, with root and no hypervisor between srcds and the hardware. Every dedicated server comes with an unmetered port and one IPv4 address: 1 Gbps on 10 of the 18 configurable lines and 500 Mbps on the other 8. Nothing counts the traffic.

  • Location: New York, Miami, San Francisco, Amsterdam or Bucharest, all on our own network, AS19624. Ping each city's test address from the locations page before you order.
  • Delivery: a machine already racked is live about 30 minutes after the order is approved; see what is on the shelf on instant servers. A build to order takes 4-24 hours.
  • Console: each rack server and each blade carries an out-of-band controller (HPE iLO, Dell iDRAC or a Supermicro BMC) with a browser console, published once you add a console login. Moonshot cartridges other than the m510 and m710x have power control only.
  • Operating system: Ubuntu is a one-click install; the widest lines go up to 26.04.

Skip the ARM lines for this game. This is our inference, not Valve's: VDC lists only 32-bit x86 libraries for x86-64 systems and says nothing about ARM, so on our reading arm64 is outside what it documents. Take an x86 machine. The X-Gene cartridge also takes only Ubuntu 16.04 or 18.04.

Installing with SteamCMD

The install runs as an unprivileged steam user, as VDC's SteamCMD page asks: it warns against running SteamCMD as root. The firewall goes up before anything listens. Replace 203.0.113.10 with the address you will run RCON from.

# root part: 32-bit libraries, service user, firewall
sudo apt-get update
sudo apt-get install -y lib32gcc-s1 lib32stdc++6 curl
sudo useradd -m -s /bin/bash steam
sudo sed -i 's/^IPV6=.*/IPV6=yes/' /etc/default/ufw
sudo ufw allow OpenSSH
sudo ufw --force enable
sudo ufw allow 27015/udp
sudo ufw allow from 203.0.113.10 to any port 27015 proto tcp

# steam user part: SteamCMD, then app 222860
sudo -u steam bash -c 'mkdir -p /home/steam/Steam && cd /home/steam/Steam && curl -sqL "https://client-update.steamstatic.com/installer/steamcmd_linux.tar.gz" | tar zxf -'
sudo -u steam bash -c 'cd /home/steam/Steam && ./steamcmd.sh +force_install_dir /home/steam/l4d2 +login anonymous +app_update 222860 validate +quit'
  1. lib32gcc-s1 is VDC's dependency for a manual SteamCMD install on 64-bit Debian or Ubuntu; lib32stdc++6 is its fix when the 32-bit libstdc++ is missing.
  2. force_install_dir comes before login, which is the order VDC recommends.
  3. validate checks every file against Steam's copy. Use it on the first install and when something looks broken, not on every update.
  4. 222860 is the Left 4 Dead 2 Dedicated Server on VDC's Dedicated Servers List, marked as available to anonymous login. 222840 is the first game's server: don't mix them up.

server.cfg: name, RCON and who can join

The game directory is left4dead2, so the file is /home/steam/l4d2/left4dead2/cfg/server.cfg. VDC's CFG page says server.cfg runs when a dedicated server starts and again on every map change. Create it as the service user with sudo -u steam nano /home/steam/l4d2/left4dead2/cfg/server.cfg, then lock it with sudo chmod 600 /home/steam/l4d2/left4dead2/cfg/server.cfg.

// /home/steam/l4d2/left4dead2/cfg/server.cfg
hostname "Dead Center coop"
rcon_password "use-a-long-random-string-here"
sv_lan 0
sv_allow_lobby_connect_only 0
// sv_steamgroup 1234567
// sv_steamgroup_exclusive 1
  • hostname: what players see listed in the server browser.
  • rcon_password: the remote console password. Keep it in this file only. A +rcon_password on the launch line is visible to any local user in ps and lands in shell history.
  • sv_lan 0: VDC describes a LAN server as one with no heartbeat, no authentication and no addresses outside the local class C. An internet server needs 0.
  • sv_allow_lobby_connect_only: defaults to 1, which means players may only arrive from a matchmaking lobby and cannot connect directly. Set 0 to allow connect address:27015.
  • sv_steamgroup: the ID of the Steam group the server belongs to, shown on the admin profile page of the group. With sv_steamgroup_exclusive 1, only members can join while the server is empty.

Running it as a service

VDC's generic Source launch runs srcds_run with -game, +map and +maxplayers, plus -autoupdate. The unit below keeps the parts that apply here and lets systemd own restarts and updates.

# /etc/systemd/system/l4d2.service
[Unit]
Description=Left 4 Dead 2 dedicated server
Wants=network-online.target
After=network-online.target

[Service]
User=steam
WorkingDirectory=/home/steam/l4d2
TimeoutStartSec=1800
ExecStartPre=-/home/steam/Steam/steamcmd.sh +force_install_dir /home/steam/l4d2 +login anonymous +app_update 222860 +quit
ExecStart=/home/steam/l4d2/srcds_run -game left4dead2 -console -norestart -port 27015 +map c1m1_hotel
Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target
  • -norestart stops srcds_run from restarting the server itself; with Restart=always, systemd starts it again whenever the process ends, crash or clean exit.
  • The - in front of ExecStartPre lets the server start on its current files when the update exits with an error. An update that hangs instead holds the start for up to 30 minutes: TimeoutStartSec=1800 sets that ceiling, and it is there because the default start timeout also covers ExecStartPre, so a long download would otherwise kill the start.
  • c1m1_hotel is The Hotel, the first map of Dead Center. mp_gamemode defaults to coop; VDC says the mode changes with the map command, for example map c1m1_hotel versus.
  • +maxplayers: VDC notes the ceiling is set by the game and gives no Left 4 Dead 2 figure, so the unit leaves it out. Add it only if you know what your mode needs.

Run sudo systemctl daemon-reload, then sudo systemctl enable --now l4d2, and follow the console with journalctl -u l4d2 -f. VDC notes a server won't answer queries until a map is loaded, so give the first start a moment.

Ports and what they carry

PortProtocolPurpose (per VDC)Firewall here
27015UDPGame traffic and pings; moved with -portOpen to everyone
27015TCPRCON; it follows -port tooOpen only to your own address
27020UDPSourceTV; moved with +tv_portClosed unless you use SourceTV
27005UDPClient port; -clientportNot opened inbound
26900UDPSteam port, outgoing; -sportOutbound, allowed by ufw's default

VDC lists 27015 as both TCP and UDP; its RCON protocol page explains that srcds listens for the remote console on TCP 27015. That is the reason to fence TCP to one address rather than the world.

Updates, add-ons and copies

A Steam update for the server lands at the next start, because ExecStartPre runs app_update 222860 each time: sudo systemctl restart l4d2 is the whole update procedure. If files look damaged, run the install line from the setup block again with validate. VDC warns that validation overwrites any changed file that belongs to the default install; files you added yourself are left alone.

Add-ons for this game are VPK files. VDC's L4D2 add-on notes cover how the game installs them into its addons folder, but they do not describe a Workshop workflow for a dedicated server, so this page doesn't either. Treat any VPK you place on the server as something to test on a second instance first.

Keep a copy of server.cfg and any add-ons somewhere other than this machine. You make that copy yourself. It holds the RCON password, so store it privately.

Where this goes wrong

  • Friends can't connect by address: sv_allow_lobby_connect_only is still at its default of 1.
  • The log complains that it cannot locate a running instance of Steam: VDC's fix is a symlink to steamclient.so. With this layout that is sudo -u steam bash -c 'mkdir -p /home/steam/.steam/sdk32 && ln -s /home/steam/Steam/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so'.
  • A missing 32-bit libstdc++: install lib32stdc++6 (VDC's fix). VDC documents these libraries only for x86-64, so on an ARM machine our advice is to move to an x86 line.
  • Never add -insecure to a public server: it starts srcds without Valve Anti-Cheat.

For other Source titles the same SteamCMD and srcds pattern applies; our Garry's Mod server guide walks through one. For the operating system itself, see our Linux servers.

Questions

Which SteamCMD app ID installs the L4D2 server?

222860. VDC's Dedicated Servers List gives it as the Left 4 Dead 2 Dedicated Server for Linux and marks it available to anonymous login. The first game's server is 222840, which is a different install.

Does the server need a Steam account that owns the game?

No. VDC lists app 222860 as downloadable with login anonymous, so no account and no password ever touch the machine. That also keeps credentials out of the systemd unit.

Why does everyone have to come through a lobby?

Because sv_allow_lobby_connect_only defaults to 1. VDC describes it as letting players join only from a matchmaking lobby. Set it to 0 in server.cfg and players can connect with the server's address and port.

How do I run versus or survival instead of coop?

VDC's description of mp_gamemode lists coop, realism, versus, survival, scavenge and holdout, and says the mode changes through the map command, such as map c1m1_hotel versus from the console or RCON. sv_gametypes sets which modes the server accepts.

Will it run on an ARM server?

Our reading is no. VDC documents its 32-bit libraries for x86-64 only and says nothing about ARM, and the X-Gene cartridge's choice of systems ends at Ubuntu 18.04. Choose an x86 line from the game server page.

Put the server on its own machine

Whole x86 servers with root, an unmetered port and a choice of five cities.

See the machines

Related on Server Room

Other use cases