Team Fortress 2

Team Fortress 2

Not enough ratings
How to host a tf2 server in 2021
By Bad Cat
Basic guide for a basic tf2 server
   
Award
Favorite
Favorited
Unfavorite
Intro
So, you decided to create your own server.

To get started, you need a hosting.

Hosting
Any linux computer can be a hosting for a tf2 server.
It could be a virtual private server (VPS), dedicated server, cloud service, virtual machine, docker container, your old PC, or your college's hacked server.

The server must meet the following requirements:
  • x86 or x86_64 (amd64) CPU architecture
  • 1 Ghz CPU frequency
  • 1 GB of RAM
  • 15 GB of disk space
  • Public static IP address
  • Thick internet connection
  • Any Linux distribution on the board. This tutorial assumes the use of Debian Buster (Debian 10, Debian Stable)

Many hosting services provide such servers. Comparing them is beyond the scope of this guide. Also I do not want to advertise them. On internet, you can find tons of guides for choosing a hosting service/hosting provider.

In terms of cost, my server costs around $26 per month.

Let's skip the step of choosing a hosting service and assume that you already have access to your server terminal.
Server
  1. Add support for i386 (x86) architecture:
    sudo dpkg --add-architecture i386
  2. Update software packages database:
    sudo apt-get update
  3. Update software packages:
    sudo apt-get dist-upgrade
  4. Install required software packages:
    sudo apt-get install screen wget mc htop lib32z1 libncurses5:i386 libbz2-1.0:i386 lib32gcc1 lib32stdc++6 libtinfo5:i386 libcurl3-gnutls:i386
  5. Run new screen session.
    screen -S s1
    This utility make it easier to start the server as a background process and reconnect to it at any time.
  6. Create a folder for your server staff:
    mkdir hlserver
  7. Go inside of it:
    cd hlserver
  8. Download steam console client archive:
  9. Upack it in the current folder:
    tar zxf steamcmd_linux.tar.gz
  10. Download tf2 server:
    ./steamcmd.sh +login anonymous +force_install_dir ./hlserver +app_update 232250 +quit
    If it failed with out of memory error, don't worry just retry this command again and again until it downloads tf2 server successfully
  11. Go to the downloaded server's folder:
    cd hlserver
  12. Now you should get your Valve Dedicated Game Server Account (token). It looks like a string of random letters and numbers. Something like
    F1337B16B00B5
    To get one go to https://steamcommunity.com/dev/managegameservers and create new account for TF2 (Game id is 440).
  13. Run your server:
    ./srcds_run -console -game tf +sv_pure 1 +randommap +maxplayers 24 +sv_setsteamaccount <INSERT YOUR TOKEN HERE>
    Replace
    <INSERT YOUR TOKEN HERE>
    with your token from previous step.
  14. You can now disconnect from your screen session while tf2 server will be running inside of it untouched.
    To do it press Ctrl+A and then press D.
    If you want to connect to it again enter:
    screen -r s1
  15. To stop the server simply press Ctrl+C
Network
To be able to connect to your server you need to open network port
UDP 27015
Different hosting providers have different user interfaces for opening ports.
You need to search on internet how to open port for your hosting provider, your home router or your virtual machine software depending of what you are using as hosting.
Google compute engine have the following UI for example:
Additional configuration
You may want to make basic configuration of your server.

  • Go to config folder:
    ~/hlserver/hlserver/tf/cfg
  • Create and edit server.cfg file:
    mcedit server.cfg
  • Edit it and save it with F2 key
  • Restart your server

Example of server.cfg:



Testing
Now launch the game and connect to your server by it's IP address.

Open console (press ~ key) and write:
connect <INSERT SERVER IP HERE>
Replace <INSERT SERVER IP HERE> with IP address of your server.

WHOA IT WORKS!!!
Acknowledgments
I apologize for my bad english and thank to translate.google.com.

Thanks for reading, and have fun!

I am planning to update this guide in the future to include more advanced configuration, security measures, administration tools and create docker image with preinstalled and preconfigured vanilla tf2 server.

Feel free to ask something and request guide improvement because i don't know which part of making server process is hard for average tf2 player.
8 Comments
⛥ xira ⎆ Mar 5, 2024 @ 10:21am 
Is TCP needed if I don't use SourceTV? I have `udp dport 27015 accept` in /etc/nftables.conf (also it's 2024, iptables is the past :3) and clients can connect just fine through the server browser.

Also- I like using this: https://github.com/CM2Walki/TF2
It's a Docker image with steamcmd that automatically downloads srcds and TF2 files, I put it in a systemd service to execute on startup, convenient.

You can set several envvars for it including a directory for the game's files that gets mounted to the Docker container, makes sourcemod/cfg/map management easier.
Not a Human Feb 27, 2024 @ 4:47pm 
Also quick trick to open your port in server without logging in into web panel. By default game is served under port 27015. So this is how look it is for example:

1) Using iptables:

sudo iptables -A INPUT -p tcp --dport 27015 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 27015 -j ACCEPT

2) Or much easier if you have UFW package installed:

sudo ufw allow 27015

and that's it :demoticon:
Not a Human Feb 27, 2024 @ 4:41pm 
I would like to add a note here: It’s much easier when you have a server with KVM. Then, you can install the server and addons with a graphical user interface (GUI) using Team Viewer or some other VNC software. Installing via SSH is still possible but can cause some issues if you’re seeing Linux for the first time. Afterwards, it’s much harder to install SourceMod extensions via SSH - it’s really painful.

A second note: Don’t buy a cheap server - you will be throttled if your server network has less than 250 Mbps or if it has a very bad CPU, like an Intel Atom or some other worthless piece.


Have a great games in TF2 all :spycon: :spycon: :spycon:
Not a Human Feb 27, 2024 @ 4:34pm 
Works great dude, thanks for this guide :)
Lego Kenobi Oct 18, 2022 @ 10:23am 
Hello! I'm trying to follow this guide and I've run into an issue, I can't connect to the IP my server provided me, neither by the "connect (IP)" command or the "connect (ip); password (pw)" command, how can I be sure I did everything correctly?
Orange Oct 3, 2022 @ 4:49pm 
Did all the step in october 2022 and it works great! Thank you so much!
Ares Apr 16, 2021 @ 11:06am 
:steamthumbsup:
Ares Apr 16, 2021 @ 11:06am 
Dude, this is so cool.