You can choose to just keep adding the commands all as "-I INPUT 5".
and everything will still work, but I like to keep my iptables nice and orderly. If you wanted, you could delete the REJECT LINE (sudo iptables -D INPUT 5) and re-add it later, but you have to get the syntax correct so it is easier to insert them above.

Check that page for additional details and suggestions.
Information in that page and this one may also be useful on other Unix-like platforms.
In the below example the server is installed into the user's home directory in a directory called 'hlserver'.
Basic installation and configuration for a Linux dedicated server is the same for all distributions, but small details, such as package names, directories, etc. It is recommended that you check your distribution's repositories for the required packages before continuing.
Use these instructions only if you are unable/unwilling to use systemd.
The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "
The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.So, take a stroll down memory lane to remember all of our past Word of the Year selections.This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.
||The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.
In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.
To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.
||The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.
In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage:The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "
The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.So, take a stroll down memory lane to remember all of our past Word of the Year selections.This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.
||The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.
In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.
To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.
||The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.
In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: [[The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.So, take a stroll down memory lane to remember all of our past Word of the Year selections.This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.
||The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.
In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.
To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.
||The following example Debian LSB init script can be used to automatically restart the server. /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" BINARYNAME="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_sv_shutdown_timeout_minutes 5" cd "$BINARYPATH" running() start() stop() case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) if running; then echo "The $NAME server is started." else echo "The $NAME server is stopped." fi ;; *) echo "Usage: $0 (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.
In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
]] (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.So, take a stroll down memory lane to remember all of our past Word of the Year selections.This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out. (start|stop|restart|status)" exit 1 esac exit 0 description "TF2 Server" author "TF2 Wiki" start on runlevel [2345] stop on starting rc RUNLEVEL=[016] pre-start script cd /home/tf2-server/hlserver su -c "screen -dm S tf2 ./srcds_run -game tf sv_pure 1 maxplayers 32 ip 0.0.0.0 map mvm_decoy -autoupdate -steam_dir /home/tf2-server/hlserver/ -steamcmd_script /home/tf2-server/hlserver/tf2_sv_shutdown_timeout_minutes 5" tf2server while [ -z "$(pidof srcds_linux)" ]; do sleep 1 done end script script while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script post-stop script fuser -k /home/tf2-server/hlserver/tf2/srcds_run while [ -n "$(pidof srcds_linux)" ]; do sleep 1 done end script iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27015 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27005 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p tcp -m tcp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27016 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27017 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27018 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27019 -m state --state NEW, ESTABLISHED -j ACCEPT && iptables -A INPUT -i venet0 -p udp -m udp --dport 27020 -m state --state NEW, ESTABLISHED -j ACCEPT on Cent OS 6.4 the default iptables rules has a reject line as the last entry.In this instance port 27015 is using TCP, and ports 26901, 27005, 27015, and 27020 are using UDP.
These ports need to be added to the iptables rules so that the firewall will not block access to incoming traffic.
So, take a stroll down memory lane to remember all of our past Word of the Year selections.
This is a setup guide that allows you to install a basic Team Fortress 2 Linux dedicated server.
To add them, first you should find out what is currently in your iptables config. The best practice is to add your account to the sudoers file so that you are somewhat restricted and access will time out.