Search
K
Links

How to set up a private Team Fortress 2 server with Meshnet

Discover how to set up your own Team Fortress 2 server using Meshnet on Windows and Linux and enjoy private gaming sessions with your friends.

Introduction

Team Fortress 2 (TF2), an online multiplayer first-person shooter developed by Valve Corporation, remains a favorite among its active and loyal community members even after more than a decade. Creating your own dedicated TF2 server not only provides enhanced stability and control compared to external servers but also enriches your gaming experience with exclusive maps, game modes, and other features. Additionally, a dedicated server is an excellent opportunity to give new life to an old PC.
Nonetheless, managing a public server can lead to potential vulnerabilities in your home network. Meshnet offers an effective solution that removes the necessity of opening ports and revealing your IP address. With Meshnet, you can establish a secure virtual network that links devices from around the globe, simulating a local area network (LAN) connection between remote participants.
This guide will show how to host a private TF2 game from within the game itself as well as how to set up a TF2 dedicated server on Linux and Windows systems, with instructions to connect using Meshnet.

Launch a private TF2 game without a dedicated server

If you're looking for a quick and simple way to create a private game without setting up a dedicated server, you can do so directly from the game.

Before you begin

To ensure that your devices can communicate with each other, enable Meshnet on your host machine and any other devices that will connect to your game.

Configure a private TF2 game session

  1. 1.
    Launch the TF2 game on your computer.
  2. 2.
    From the main menu, select Find a game > Create server.
  3. 3.
    Start a server with any random map. Once the server loads, open Console by pressing the ~ (tilde) key.
  4. 4.
    Run the following commands, replacing <meshnet_ip_address> with your device's Meshnet IP address and <map_name> with the name of the map you want to use:
    sv_lan 0
    ip <meshnet_ip_address>
    heartbeat
    map <map_name>
    Example
    Entering commands in the console.
After the server reloads with the specified map, other players can connect to your private game using your device's Meshnet IP address. For further details, see the Connect to the TF2 server section below.
Note
If you can't access Console, make sure it is enabled in the game's settings:
  1. 1.
    In the main menu, click the gear button at the bottom of the screen to open Options.
  2. 2.
    Under Keyboard, select Advanced, and then select Enable developer console and click OK.

Create a TF2 dedicated server on Windows and Linux

The TF2 server software is compatible with Windows and Linux, allowing you to create a private server on either system. This article covers the steps for both platforms.

Before you begin

Ensure you have the following:
  1. 1.
    A computer with a stable internet connection running Linux or Windows.
  2. 2.
    At least 20GB of free storage space for the game files.
  3. 3.
    A minimum of 8GB of RAM or, preferably, 16GB for optimal performance.
  4. 4.
    Meshnet is enabled on both your server machine and any devices that will be connecting to it.

Create a basic TF2 dedicated server with SteamCMD

The steps below outline how to install and configure the server software, create a configuration file, and launch the server with customized settings.
Windows
Linux
Note
This user guide is based on installing the server on Windows 11.

Download and install SteamCMD

To download and install SteamCMD, which is a command-line tool used to manage dedicated server files, follow these steps:
  1. 1.
    Create a new folder on your computer where you want to install SteamCMD. For example: D:\tf2_server
  2. 2.
    Download the SteamCMD for Windows from the Valve Developer Community website. Look for the download link under the “Windows” section.
  3. 3.
    Extract the contents of the downloaded ZIP file to the folder you created.
  4. 4.
    Double-click the steamcmd.exe file to launch the application.
  5. 5.
    If the Windows security alert box appears, select both the private and public networks options and then click the Allow access button to allow incoming connections through the firewall.
The SteamCMD tool will automatically update and, upon completion, will be ready to accept commands.
Using the SteamCMD command line tool.

Download and install the TF2 server

Now that you have SteamCMD installed, it's time to download and install the TF2 server files.
  1. 1.
    You can log in anonymously to SteamCMD to download TF2 dedicated server files by entering the following command:
    login anonymous
    Example:
    Logging in to SteamCMD anonymously.
    To log in to SteamCMD with your Steam account, enter the following command and replace <username> and <password> with your Steam account credentials:
    login <username> <password>
  2. 2.
    Specify the installation directory for the TF2 server files by entering force_install_dir followed by the path to the installation folder of your choice. For example:
    force_install_dir D:\tf2_server\tf2\
  3. 3.
    Download and install the server files by entering this command:
    app_update 232250
    The download process may take several hours to complete because the dedicated server content is quite large. Once the "Success!" message appears, it means that the server files are fully downloaded and installed.
  4. 4.
    Exit SteamCMD by entering the following command:
    quit

Configure the server

After installing the server files, the next step is to configure the server settings.
  1. 1.
    Navigate to the tf\cfg\ directory within the folder where you installed the TF2 server.
  2. 2.
    Create a new text file named server.cfg and open it with a text editor, such as Notepad.
  3. 3.
    Add the following lines to the file, replacing the placeholders with your desired settings, where:
    • <your_server_name> is your server display name.
    • <time_in_minutes> is the maximum time in minutes a map can be played before switching to the next map.
      hostname "<your_server_name>"
      mp_timelimit "<time_in_minutes>"
      Example
      Example server configuration file.
  4. 4.
    Save and close the text editor.
The server.cfg file allows you to store custom settings for your server. To learn more about additional configuration parameters, visit the TF2 Wiki's dedicated server configuration page.

Launch the server

Now that your server is configured, you can start it by creating a batch file to simplify the process.
  1. 1.
    Create a new text file in the tf2server folder in the folder where you installed the server. You can name it start_tf2.bat or choose another name for the file.
  2. 2.
    Open the file with a text editor and add the following line:
    srcds.exe -console -game tf +sv_pure 1 +randommap +maxplayers 24
    These lines contain key server settings that can be modified according to your preferences:
    • To set a specific map, replace +randommap with +map followed by the name of your preferred map. For example: +map ctf_2fort.
    • To limit the number of players who can connect to the server, adjust the maxplayers value.
    • To control custom content from clients, set sv_pure to the desired value. 1 restricts most custom content to ensure a consistent gaming experience.
  3. 3.
    Save the file and exit the text editor.
  4. 4.
    To launch the server, double-click the start_tf2.bat file you’ve just created.
  5. 5.
    If the Windows security alert box appears, select both the private and public networks options and then click the Allow access button to allow incoming connections through the firewall.
    Activating the TF2 dedicated server.
Now, your TF2 server should start with the specified settings.
Tip To stop the server, type quit or exit in the console window and press Enter.
To ensure your server runs smoothly, regularly update the server files.
Note
Package names and directories may vary slightly depending on the Linux distribution, but the process of setting up and configuring a dedicated server is generally similar.
This user guide is based on installing the server on Ubuntu 22.04.1 LTS.

Get started with SteamCMD

SteamCMD is a command-line version of the Steam client. It is used to download and manage the dedicated server files for TF2 and other popular PC games that use Steam for their multiplayer architecture.
If you have a 64-bit machine, you'll need to add support for 32-bit architecture and install specific libraries required by SteamCMD, as follows:
  1. 1.
    Open a terminal window.
  2. 2.
    Enter this command to add 32-bit architecture support:
    sudo dpkg --add-architecture i386
  3. 3.
    Update your system's package information by entering:
    sudo apt update
  4. 4.
    Install the required 32-bit libraries:
    sudo apt install lib32z1 libncurses5:i386 libbz2-1.0:i386 lib32gcc-s1 lib32stdc++6 libtinfo5:i386 libcurl3-gnutls:i386 libsdl2-2.0-0:i386
  5. 5.
    Optionally, create a separate user account, such as tf2server, for installing and running game servers.
    sudo adduser tf2server
  6. 6.
    Set a password and provide the required user information when prompted.

Download and install SteamCMD

Now you can proceed with the installation of SteamCMD.
  1. 1.
    Create a new folder to store SteamCMD files. To do this, enter the mkdir command and specify the desired folder name. For example:
    mkdir steamcmd
  2. 2.
    Change the current directory to this new folder by typing:
    cd steamcmd
  3. 3.
    Download the SteamCMD archive by entering:
    wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
  4. 4.
    Use the tar command to extract the archive:
    tar zxf steamcmd_linux.tar.gz

Download and install the TF2 server

With SteamCMD installed, it's time to download the TF2 server files.
  1. 1.
    Run SteamCMD by entering:
    ./steamcmd.sh
  2. 2.
    You can log in anonymously to SteamCMD to download TF2 dedicated server files, as follows:
    login anonymous
    To log in to SteamCMD with your Steam account, enter the following command and replace <username> and <password> with your Steam account credentials:
    login <username> <password>
  3. 3.
    Specify the installation directory for the TF2 server files by entering force_install_dir followed by the path to the installation folder of your choice. For example:
    force_install_dir ./tf2
  4. 4.
    Download and install the server files by entering this command:
    app_update 232250 +quit
    The download process may take several hours to complete because the dedicated server content is quite large. Once the download is finished, the output should be similar to the following:
    Terminal output after downloading the server files.
Note
If you encounter the error message "Error! App '232250' state is 0x202 after update job," it may be due to insufficient disk space available on your computer.

Configure the server

After installing the server files, the next step is to configure the server settings.
  1. 1.
    Use the command below to change the current working directory to ~/steamcmd/tf2/tf/cfg.
    cd ~/steamcmd/tf2/tf/cfg
  2. 2.
    Create a configuration file named server.cfg, using a text editor like Nano, as shown:
    nano server.cfg
  3. 3.
    Add the following lines, replacing the placeholders with your desired settings, where:
    • <your_server_name> is your server display name.
    • <time_in_minutes> is the maximum time in minutes a map can be played before switching to the next map.
      hostname "<your_server_name>"
      mp_timelimit "<time_in_minutes>"
      Example
      Example server configuration file.
  4. 4.
    Press Ctrl + X, followed by Y, and then press Enter to save the changes and exit Nano.
The server.cfg file allows you to store custom settings for your server. To learn more about additional configuration parameters, visit the TF2 Wiki's dedicated server configuration page.
Tip
In the terminal, the tilde symbol (~) represents the current user's home directory.

Launch the server

Your server is now configured and ready to be launched.
For convenience, you can create a shell script to run the server. To do this:
  1. 1.
    Navigate to the tf2 server directory by entering:
    cd ~/steamcmd/tf2
  2. 2.
    Create a new shell script file called tf2.sh, using a text editor like Nano, as shown:
    nano tf2.sh
  3. 3.
    In the text editor, add the following lines with the server launch command.
    #!/bin/sh
    ./srcds_run -console -game tf +sv_pure 1 +randommap +maxplayers 24
    These lines contain key server settings that can be modified according to your preferences:
    • To set a specific map, replace +randommap with +map followed by the name of your preferred map.
    • To limit the number of players who can connect to the server, adjust the maxplayers value.
    • To control custom content from clients, set sv_pure to the desired value. 1 restricts most custom content to ensure a consistent gaming experience.
  4. 4.
    Press Ctrl + X, followed by Y, and then press Enter to save the changes and exit Nano.
  5. 5.
    Grant the tf2.sh file executable permissions by entering:
    chmod u+x tf2.sh
  6. 6.
    Launch the server using the shell script, as shown:
    ./tf2.sh
Now, your TF2 server should start with the specified settings.
Activating the TF2 dedicated server.
Tip
To stop the server, press Ctrl + C in the terminal window.
To ensure your server runs smoothly, regularly update the server files.

Connect to the TF2 server

To connect to the newly created server, follow these steps:
  1. 1.
    Copy the Meshnet IP address of the server computer from the NordVPN app by clicking it.
  2. 2.
    Launch the TF2 game on your computer.
  3. 3.
    Open Console by pressing the ~ (tilde) key and then typing the following command, replacing <server_ip> with the copied Meshnet IP address:
    connect <server_ip>
    Example
    Connecting to the TF2 server using Console.
  4. 4.
    Click Submit.
Once connected to your server, you and your Meshnet peers can enjoy playing Team Fortress 2 together.
Playing TF2.
© 2023 Nord Security. All Rights Reserved.