Server setup

Don’t run Steam or the KF2 dedicated server as the root user. Giving arbitrary applications root access to the system is never a good idea.

Create a Steam user to run all the Steam operations as. Do not add this user to the list of sudoers.

root@instance-1:~$ useradd -m steam

Don’t change into the Steam user yet. SteamCMD still needs to be installed.

SteamCMD installation

SteamCMD may or may not be in the repos depending on the flavor of Linux your server is running.

Ubuntu/Debian: sudo apt install steamcmd Fedora: sudo dnf install steamcmd Arch: pacman -S steamcmd

If your distributions repos don’t have steamcmd, you can manually install it.

Installing KF2

The following commands create an install directory, give ownership over it to the steam user, and install Killing Floor 2.

# Create the install directory
root@instance-1:~/# mkdir /kf2

# Give ownership of the directory to steam
root@instance-1:~/# chown steam:steam /kf2

# Switch to the steam user and install KF2
root@instance-1:/home/steam# su - steam
steam@instance-1:~$ mkdir ~/Steam && cd ~/Steam
steam@instance-1:~/Steam$ steamcmd

Steam>login anonymous

Steam>force_install_dir /kf2

Steam>app_update 232130 validate

KF2 should be installing at this point. The force_install_dir section can be changed to whatever arbitrary location on the file system you want KF2 installed to. I installed to /kf2.

Initial configuration

Launch the server to get the config files generated:

steam@instance-1:~/$ cd /kf2
steam@instance-1:~/kf2$ ./Binaries/Win64/KFGameSteamServer.bin.x86_64 kf-bioticslab

Configuration variables can be found here.

Setting Up A Single Instance

Edit the LinuxServer-KFGame.ini, change whatever settings you want to change (ServerName, Difficulty, GameLength, etc) and fire up the server.

Set bEnabled to true in the KFWeb.ini if you’d like to administer the server from the web portal and be sure to open port 8080, but make sure that port 8080 is only accessible from YOUR IP.

Setting Up Multiple Instances/Separate Servers

Create individual folders for each instance inside of ./KFGame/Config and copy all the LinuxServer-*.ini files into each folder.

Example: I’ll be running one Suicidal server and one Weekly Outbreak. I create one folder called suicidal1 and one called weekly1. I’ll configure them each separately - then execute them as different instances with a command line switch, -configsubdir.

This switch already uses the implicit install path, so I’ll just pass -configsubdir=weekly1 to start the server running the weekly outbreak game mode. If I wanted to run the suicidal server I’d pass -configsubdir=suicidal1.

steam@instance-1:~/kf2$ ./Binaries/Win64/KFGameSteamServer.bin.x86_64 kf-bioticslab -configsubdir=weekly1

Launching the server this way will take over your terminal. In the next step we’ll make a systemd unit file to allow systemd to handle starting and running the server.

Systemd unit file

Creating a systemd unit allows the system to handle starting and running the server in the background. We’ll configure the unit to allow multiple KF2 servers using the configurations we set up in the previous steps.

Single instance

First, create the unit file: touch /etc/systemd/system/kf2.service

Open the file in your editor of choice and drop in something like the below example (adjust for your own file structure):

[Unit]
Description=KF2 Dedicated Server

[Service]
User=steam
Group=steam
StandardOutput=null
StandardError=null
Type=simple
ExecStart=/kf2/Binaries/Win64/KFGameSteamServer.bin.x86_64

That’s it! Start the server via systemctl start kf2. Try connecting to it by opening the console (` button) inside KF2 and typing open <serverip>:7777 where <serverip> is the IP address of your server.

Multiple instances/advanced configuration

Create the unit file: touch /etc/systemd/system/kf2@.service

Open the file in your editor of choice and drop in something like the below example (adjust for your own file structure):

[Unit]
Description=KF2 Dedicated Server - %i

[Service]
User=steam
Group=steam
StandardOutput=null
StandardError=null
Type=simple
EnvironmentFile=/kf2/KFGame/Config/%i/.env
ExecStart=/kf2/Binaries/Win64/KFGameSteamServer.bin.x86_64 $ARG0 configsubdir=%i $ARG1 $ARG2 $ARG3 $ARG4 $ARG5


[Install]
WantedBy=multi-user.target

Run sudo systemctl daemon-reload to get systemd to recognize the service. If you try to start the server by running systemctl start kf2@.servce at this point, it will fail.

Explaining the systemd unit
  • The %i variable is whatever you pass in after the @ when starting the service. If my folder structure for a weekly game was kf2/KFGame/Config/weekly1 I would start the server by typing systemctl start kf2@weekly1.

  • User and Group are set to steam. If those are not specified the server will run as root.

  • systemd processes will log to the journal and syslog by default. KF2 logs a LOT of information and will flood your logs with mostly useless information. Setting StandardOutput and StandardError to null keeps all of the KF2 cruft out of your system log. After you get everything running smoothly you can probably disable the logs.

Setting an EnvironmentFile allows you to pass multiple arguments to the server at startup. In this case, I’m using it to pass starting map, webadminport, query and game port to allow for multiple instances. See the contents of my EnvironmentFile below. Note that it’s located in whatever directory I specify with systemctl start kf@.

ARG0=kf-bioticslab
ARG1=-webadminport=8080
ARG2=-difficulty=2
ARG3=-GameLength=2
ARG4=-queryport=27015
ARG5=-port=7777

After you’ve got your server up and running, try connecting to it by opening the console (` button) inside KF2 and typing open <serverip>:7777 where <serverip> is the IP address of your server.

“Gotchas” and other stuff

Updating

KF2 periodically updates. This means the server instances will need to be updated as well. This is done through SteamCMD in a similar manner to the install. Unlike the install, do not pass the “validate” parameter with the app_update command or any custom server settings that have been set up will be destroyed.

steam@instance-1:~/Steam$ steamcmd

Steam>login anonymous
Steam>force_install_dir /kf2
Steam>app_update 232130

Workshop maps

Check out this link to learn how to set up custom maps and get them into the server rotation.

Takeover opt-out

KF2’s server takeover option is novel, but annoying. It allows players looking for a private game to “take over” a server that hasn’t opted out, changing its gametype, mode, and typically passwording the server. Sometimes, these options don’t reset when a player leaves, rendering the server instances useless as they are locked and no one can join.

Edit LinuxServer-KFEngine.ini and change the bUsedForTakeover line to FALSE to disable takeover (or change it from the web admin console).

[Engine.GameEngine]
bUsedForTakeover=FALSE