Jump to content



Photo

[HowTo] Team Fortress 2 Server


  • Please log in to reply
2 replies to this topic

#1 Arctic

Arctic

    Haphost Staff

  • Moderators
  • 341 posts
  • LocationGermany

Posted 22 October 2014 - 01:40 PM

Article notation

This article was written according to the documented Linux standard syntax.  This includes:
The Kommandopräfix # (hash) indicates that this command must be run as root.  Almost all distributions have a separate root account;  for other distributions such as Ubuntu, Linux Mint CrunchBang, etc., represents the Kommandopräfix the sudo function is equivalent, by which the following command is executed with root privileges.The Kommandopräfix $ (dollar sign) indicates that this command must be run as a normal user../ means "current working directory".

Requirements

There are a number of conditions for a Team Fortress 2 server to run under Linux, these are:

    Write access to the current working directory
    glibc >= 2.3.6
    Approximately 4:49 GB free space (for a standard server with no custom content such as additional maps, sounds, etc.)
    In the case of a 64-bit distribution, the package ia32-libs lib32gcc1 or required: 

On 64-bit CentOS:

# yum install libgcc.i686 glibc.i686

On 64-bit Debian / Ubuntu / Linux Mint:

$ sudo apt-get install lib32gcc1 ia32-libs

If the server is installed on CentOS, this command must be used before: yum install ncompress
If the server on FreeBSD (not Linux) is installed, the Linux compatibility must be turned on in the kernel, and can be installed via the ports collection a basic system.

Download and install the SteamCMD Tools

 

It is recommended that a separate user (eg "Game Server") is applied to install the server and operate.

First, the SteamCMD file is downloaded: steamcmd_linux.tar.gz or

wget http://media.steampowered.com/client/steamcmd_linux.tar.gz

Use tar to decompress the file in a folder, eg './hlserver':

tar zxf steamcmd_linux.tar.gz

Create a startup script SteamCMD

 

  • Create a file named tf2_ds.txt in the folder where SteamCMD is installed, eg './hlserver'
  • Edit the file with a text editor and paste the text below:
@ShutdownOnFailedCommand 1
@NoPromptForPassword 1
login anonymous
force_install_dir ./tf2
app_update 232250
quit

If you want to play the beta version of Team Fortress 2 on the server, add this line before the app_update:

beta prerelease

Create an update script

 

  • Create a file named update.sh in the folder where SteamCDM is installed, eg './hlserver'
  • Edit the file with a text editor and paste the text below:
 #! / Bin / sh
 ./steamcmd.sh + runscript tf2_ds.txt

Download

 

  • Do ./update.sh to start the download. This can take several minutes to hours, depending on the speed of the Internet connection, as the contents of the server is 4.4 GB.
  • If unexpectedly, the access is not granted, you must run this command:
chmod + x update.sh

You may need to run the file repeatedly until the message "Success! App '232250' fully installed." appears.

 

Create / customize server files

 

  • Create a file called server.cfg in the directory '~ / hlserver / tf2 / tf / cfg'
  • Edit the file with a text editor and paste the text below:
hostname "your_server_name"
 rcon_password "RCON_Passwort"
 sv_contact "name@yourwebsite"
 mp_timelimit "30" 

The files motd.txt, maplist.txt and mapcycle.txt all located in the directory '~ / hlserver / tf2 / tf'. modt.txt is the file whose contents are as MODT ("Message of the Day" message of the day) when entering the server is displayed. maplist.txt is a list of all maps, mapcycle.txt determines the Maprotation.

 

Create a shell script

 

  • Create a file named tf.sh in the directory './hlserver/'
  • Edit the file with a text editor and paste the text below:
 #! / Bin / sh
 tf2 / srcds_run -game tf + sv_pure 1 + maxplayers 16 + map ctf_2fort.bsp

The values ​​+ map + maxplayers and can be customized. + Map is the map name, with the start of the server, + maxplayers is the number of available slots.

  • Run the file from tf.sh to start the server.
Other commands

Here are some other frequently used commands for the Team Fortress Linux dedicated server:

  • +ip 1.2.3.4 - bind the server to a specific IP. He usually listens to all network interfaces.
  • -port 27015 - The server bind to a specific port, the Port-moderately 27015 is used.
  • -strictportbind - If the server is already running on a specific port, so that the server can be stopped.
  • +randommap - Use this command instead of + map to select a random map.
  • +serverconfigfile - Here you can change which configuration file to be executed within tf / cfg / for a map change, this is the st-moderately server.cfg file
  • +mapcyclefile - Here you can change, containing configuration file within tf / cfg / the Mapcycle,-moderately this is mapcycle.txt the file. Can also be used to within tf / select files.
  • -replay - Performs replay.cfg and adds a Adicional Bot Bot added as a replay, but it reduces the number of slots to the first
  • -autoupdate - Attempts to update the server automatically, an update should appear. You MUST -steam_dir and -steamcmd_script use it.
  • -steam_dir ~/hl1server/ - place of SteamCMD file. Used by -autoupdate needed.
  • -steamcmd_script ~/hl1server/tf2_ds.txt - The SteamCMD script to update the server. Used by -autoupdate needed.
  • +sv_shutdown_timeout_minutes 360 - If the server is automatically updated after how many minutes the server will be restarted. Standard Moderately there are 360 ​​minutes (6 hours).
Screen

Many administrators servers run their server with Screen, as these easily switch between the server console and the shell and can be hergewechselt. Furthermore, you will end the SSH session without stopping the server. Screen can be installed via the package manager of your distribution, eg on Debian:

apt-get install screen

After installing screen can be started with the following command the server:

screen-S -m tf2 ./srcds_run parameters

where the normal parameters srcds_run are parameters. You can use Ctrl + A + D to minimize the console and screen -r tf2 order to open the console again. Ctrl + D closes the session and stops the server, but should the first killserver use command to the server to end. With Ctrl + A + [You can scroll through console.

 

Automatic server start after server crash

 

After an unexpected crash the whole server, eg after a power failure, it may be useful to have the Team Fortress Linux Desizierten server start up automatically. The following Debian LSB init scripts may Vedas used to allow the server automatically. Here is Screen used. The script is called tf2 server and set /etc/init.d in the folder. After this is done, the following command should be executed:

update-rc.d tf2-server defaults

This should allow a smooth start of the server after every reboot. Next, the contents of the script:

#! / Bin / sh

 ### BEGIN INIT INFO
 # Provides: tf2server
 # Required-Start: $ remote_fs
 # Required-Stop: $ remote_fs
 # Default-Start: 2 3 4 5
 # Default-Stop: 0 1 6
 # Short-Description: Team Fortress 2 server
 # Description: Starts a Team Fortress 2 server
 ### END INIT INFO

 NAME = "Team Fortress 2"
 USER = "tf2server"
 SCREENREF = "tf2"
 BINARYPATH = "/ home / tf2server / hlserver / tf2"
 BINARY NAME = "srcds_run"
 PIDFILE = "tf2server.pid"

 OPTS = "- game tf + sv_pure 1 + maxplayers 32 + ip 0.0.0.0 + map mvm_decoy -autoupdate -steam_dir / home / tf2server / hlserver / -steamcmd_script /home/tf2server/hlserver/tf2_ds.txt + sv_shutdown_timeout_minutes 5"

 cd "$ BINARYPATH"

 running () {
     if [-n "` pgrep-f $ BINARYNAME` "];  then
         return 0
     else
         return 1
     fi
 }

 begin () {
     if!  running;  then
         echo-n "Starting the server $ NAME ..."
         start-stop-daemon --start --chuid $ USER $ USER --user --chdir $ BINARYPATH --exec "/ usr / bin / screen" - -DMS $ $ SCREENREF BINARYPATH / $ BINARY NAME $ OPTS
         pgrep-f $ BINARY NAME> $ PIDFILE
         if [$ -s PIDFILE];  then
             echo "Done"
         else
             echo "Failed"
             rm $ PIDFILE
         fi
     else
         echo "$ NAME The server is already started."
     fi
 }

 stop () {
     if running;  then
         echo-n "Stopping the server $ NAME ..."
         kill `cat $ PIDFILE`
         while running;  do
             sleep 1
         done
         rm $ PIDFILE
         echo "Done"
     else
         echo "$ NAME The server is already stopped."
     fi
 }

 case "$ 1" in
     begin)
         begin
    ;;
     stop)
         stop
    ;;
     restart)
	 stop
         begin
    ;;
     status)
         if running;  then
             echo "$ NAME The server is started."
         else
             echo "$ NAME The server is stopped."
         fi
    ;;
     *)
         echo "Usage: $ 0 (start | stop | restart | status)"
         exit 1
 esac
 exit 0

iptables rules

-A INPUT-i venet0 p tcp tcp dport 27015 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p tcp tcp dport 27005 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27015 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27005 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p tcp tcp dport 27016 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p tcp tcp dport 27017 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p tcp tcp dport 27018 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p tcp tcp dport 27019 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p tcp tcp dport 27020 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27016 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27017 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27018 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27019 -m -m state --state NEW, ESTABLISHED-j ACCEPT
 -A INPUT-i venet0 p udp udp dport 27020 -m -m state --state NEW, ESTABLISHED-j ACCEPT

Note: Can be reduced if the multi ports extension should be installed.

 

CentOS (Minimal Installation)

 

In CentOS , the standart regular iptables rule contains a Reject-line that rejects all traffic if the above rules are applied. To fix this, you should first find out which ports are used:

netstat -lnptu

After that should be something like this:

(Not all Processes Could be Identified, non-owned process info
  will not be shown, you would have to be root to see it all.)
 Active Internet connections (only servers)
 Proto Recv-Q Send-Q Local Address Foreign Address State PID / Program name   
 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -                   
 tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -                   
 tcp 0 0 0.0.0.0:27015 0.0.0.0:* LISTEN 1393 /./ srcds_linux  
 tcp 0 0 ::: 22 ::: * LISTEN -                   
 tcp 0 0 :: 1: 25 ::: * LISTEN -                   
 udp 0 0 0.0.0.0:27020 0.0.0.0:* 1393 /./ srcds_linux  
 udp 0 0 0.0.0.0:26901 0.0.0.0:* 1393 /./ srcds_linux  
 udp 0 0 0.0.0.0:68 0.0.0.0:* -                   
 udp 0 0 0.0.0.0:27005 0.0.0.0:* 1393 /./ srcds_linux  
 udp 0 0 0.0.0.0:27015 0.0.0.0:* 1393 /./ srcds_linux

The ports are listed ./srcds_linux with the description, are used by the Team Fortress 2 server. In this case, port 27015 uses TCP and the ports 26901, 27005, 27015 and 27020 using UDP. These ports must be added to the iptables rules, so that the firewall does not block these ports against incoming traffic. To add these ports to the rules, you should first find out what is actually in the iptables configuration file. The best idea is to add your account to the sudo group, so that they have time-limited access to the file. But you can also use su to log in as root user.

sudo iptables -nL --line-numbers

Then should something similar to the following appear:

Chain INPUT (policy ACCEPT)
 num target prot opt ​​source destination         
 1 ACCEPT all - 0.0.0.0/0 0.0.0.0/0 state RELATED, ESTABLISHED 
 2 ACCEPT icmp - 0.0.0.0/0 0.0.0.0/0           
 3 ACCEPT all - 0.0.0.0/0 0.0.0.0/0           
 4 ACCEPT tcp - tcp dpt NEW 0.0.0.0/0 0.0.0.0/0 state: 22 
 5 REJECT all - reject-with icmp 0.0.0.0/0 0.0.0.0/0-host-prohibited 

 Chain FORWARD (policy ACCEPT)
 num target prot opt ​​source destination         
 1 REJECT all - reject-with icmp 0.0.0.0/0 0.0.0.0/0-host-prohibited 

 Chain OUTPUT (policy ACCEPT)
 num target prot opt ​​source destination  

You will notice that in line 5 "REJECT all ..." is, ie that your server blocks off all communication. If you decide to add new rules to the iptables configuration files, it will still not work because the rules are executed in the order in which they are listed. To fix this, you need the following commands as root user or with sudo:

 sudo iptables-I INPUT 5 p tcp dport 27015 -m state --state NEW, ESTABLISHED-j ACCEPT
 sudo iptables-I INPUT 6 p udp dport 27015 -m state --state NEW, ESTABLISHED-j ACCEPT
 sudo iptables-I INPUT 7 p udp dport 27005 -m state --state NEW, ESTABLISHED-j ACCEPT
 sudo iptables-I INPUT 8 p udp dport 27020 -m state --state NEW, ESTABLISHED-j ACCEPT
 sudo iptables-I INPUT 9 p udp dport 26901 -m state --state NEW, ESTABLISHED-j ACCEPT
 sudo service iptables save
 sudo service iptables restart

This will add the new rules on the repellent rule. If you look at the commands, you will notice that there is a section in the "-I INPUT 5,6,7,8,9." stands. This determines which rule number is used for this entry. Each time you add a new rule, the negative control is set to one by untern, so you must increase the control number by one each time. If you only enter anyway "-I INPUT 5", this will also work, but the configuration file is confusing. At the end of the iptables configuration file should look like the following:

Chain INPUT (policy ACCEPT)
 num target prot opt ​​source destination         
 1 ACCEPT all - 0.0.0.0/0 0.0.0.0/0 state RELATED, ESTABLISHED 
 2 ACCEPT icmp - 0.0.0.0/0 0.0.0.0/0           
 3 ACCEPT all - 0.0.0.0/0 0.0.0.0/0           
 4 ACCEPT tcp - tcp dpt NEW 0.0.0.0/0 0.0.0.0/0 state: 22 
 5 ACCEPT tcp - tcp dpt 0.0.0.0/0 0.0.0.0/0: 27015 state NEW, ESTABLISHED 
 6 ACCEPT udp - udp dpt 0.0.0.0/0 0.0.0.0/0: 27015 state NEW, ESTABLISHED 
 7 ACCEPT udp - udp dpt 0.0.0.0/0 0.0.0.0/0: 27005 state NEW, ESTABLISHED 
 8 ACCEPT udp - udp dpt 0.0.0.0/0 0.0.0.0/0: 27020 state NEW, ESTABLISHED 
 9 ACCEPT udp - udp dpt 0.0.0.0/0 0.0.0.0/0: 26901 state NEW, ESTABLISHED 
 10 REJECT all - reject-with icmp 0.0.0.0/0 0.0.0.0/0-host-prohibited 

 Chain FORWARD (policy ACCEPT)
 num target prot opt ​​source destination         
 1 REJECT all - reject-with icmp 0.0.0.0/0 0.0.0.0/0-host-prohibited 

 Chain OUTPUT (policy ACCEPT)
 num target prot opt ​​source destination 

This should fix your firewall issues.

 

Debugging

 

My server does not appear in the LAN tab in server browser my clients.
I can not reach when I play on this server my equipment menu.
Are you still in a position to the server via connect ip-address in the developer console to enter ?
Is displayed during the startup of the server following in the server console?

 * Unable to load Steam support library. *
 * This server will operate in LAN mode only. *

If you connect to the server, as the following is displayed?

NULL ISteamGameServer in Connect client.  Steam authentication june fail.
 ...
 Can not verify load for invalid steam ID [...]

If this is the case, so you must make sure that a file named steam_app.txt that contains the number 440, in your orange box folder.

 

My server is not automatically updated on startup.

 

The following is displayed when the server is started?

ERROR: -autoupdate requires -steam_dir and -steamcmd_script.
 WARNING: Failed to locate steam binary.
 WARNING: Could not locate steam binary :, ignoring.

If this is the case, you must srcds_run by -steam_dir and -steamcmd_script tell where your lies SteamCMD folder and scripts.

 

My server stops at 0/0 during an update.

 

Following will be displayed during an update?

force_install_dir / home / you / server / directory
 app_update 232250 validate
 Initial app state (0x4) installed
 App state (0x4) installed, progress: 0.00 (0/0)
 Success!  App '232250' already up to date.

If this is the case, remove the "validate" parameter of the update command.

 

 

Greetz

 

Arctic

 

 

 

 


any support PM's be Ignored please use the Support section for it

 

Support


#2 jorge2108

jorge2108

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 23 October 2014 - 04:10 AM

Any pic or is another copy & paste ?



#3 Arctic

Arctic

    Haphost Staff

  • Moderators
  • 341 posts
  • LocationGermany

Posted 23 October 2014 - 12:02 PM

Any pic or is another copy & paste ?

Oo

what they need pictures this tutorial is simply done by using Putty

should not they know how to be leading by a Linux server not suitable for them


any support PM's be Ignored please use the Support section for it

 

Support





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users