How to install Counter-Strike: GO server on Ubuntu 16

Try it in our public cloud & Get $50 Credit
CLAIM NOW

Counter-Strike: Global Offensive is a popular, multi-player FPS title. While there are many available providers for running your own server, it is fairly easy to install it yourself on a cloud or virtual server. It is also less expensive, as your Linux server can host multiple distinct games. This guide will get you up and running quickly on a custom server running the Counter-Strike: GO server.

Getting Started

Confirm that you have the following before you follow this guide:
• 1 Node (Cloud Server or Dedicated Server) running Ubuntu 16.
• Root access to the node.
• All system updates applied
• Tar, nano, and wget, which should be included in the base Ubuntu installation already
• lib32gcc1

Tutorial

We’ll start by running the following commands, to get the latest updates:

apt-get update && apt-get upgrade -y
apt-get install nano wget tar lib32gcc1 -y

You’ll need a Steam user created to install the server and validate the license. Let’s make your account now.

adduser --disabled-login --disabled-password steam

You can leave the informational fields blank if you wish, but you must enter “y” at the end of this process to validate account creation.

Now we install the game server itself.

cd /home/steam/
su - steam
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar xvf steamcmd_linux.tar.gz
rm steamcmd_linux.tar.gz
./steamcmd.sh

You are in Steam’s command shell. Enter the following commands to continue with the installation.

login anonymous
force_install_dir ./csgo
app_update 740 validate

When you see this output, your server’s installation is complete.

Update state (0x61) downloading, progress: 100.00 (15789214502 / 15789238956)
Success! App '740' fully installed.

Exit the steamcmd shell by typing “quit”.

If you’d like to allow more than LAN connections, which is essential if you’re running the game server remotely, you’ll need to obtain a server token. Server tokens require that you own CS:GO and also have a Steam account. To learn more, please see this Wiki page.

When you’ve got your token, visit this link, logging in with the Steam account that owns CS:GO.

Registering Game Server Login Token

CS:GO game servers and GOTV relays not logged in to a persistent game server account with a Game Server Login Token (GSLT) will only allow clients to connect from the same LAN RFC1918 addresses (10.0.0.0-10.255.255.255,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255). If your server has a public routable IP address and clients need to connect from outside the server LAN then you need to get registered for GSLT.

To create your GSLTs, visit the GSLT creation utility and follow the instructions here: http://steamcommunity.com/dev/managegameservers

Each GSLT is restricted for use on one dedicated server instance only, and should be passed on command line with +sv_setsteamaccount THISGSLTHERE. You can also use command line setting -net_port_try 1 to avoid instances from reusing the same GSLT by accident.

Every game server operating with your GSLT must comply with game server operation guidelines outlined here: http://blog.counter-strike.net/index.php/server_guidelines/

Use 730 as the app ID for token registration. Note that the app ID for this field is 730, not 740.

Enter whatever you like into the memo field. It is optional, and only for your own records.

After validating the form, you’ll receive the necessary token to set up your server.

Game Authentification token (GSLT) Last connection Memo
730 *********************************

Now we’ll need a server configuration file.

nano /home/steam/csgo/csgo/cfg/server.cfg

Add this content into the file you’ve just opened:

hostname "SERVER-HOSTNAME"
sv_password "SERVER-PASSWORD"
sv_timeout 60
rcon_password "RCON-PASSWORD"
mp_autoteambalance 1
mp_limitteams 1
writeid
writeip

hostname "SERVER-HOSTNAME" #The name of your server

sv_password "SERVER-PASSWORD" #Server password, leave blank for no password.

rcon_password "RCON-PASSWORD" #Rcon server password, to administrate your server remotely via Rcon.

As the root user, you’ll now need to create a startup script so your server launches at boot.

nano /lib/systemd/system/csgo.service

Use this content for the script, replacing [YOUR_GSLT] with the game server token obtained previously:

[Unit]
Description=CSGO Server
[Service]
Type=simple
User=steam
Group=steam
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
ExecStart=/home/steam/csgo/srcds_run srcdds -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_active +map de_dust2 +sv_setsteamaccount [YOUR_GSLT] -net_port_try 1
ExecStop=killall -TERM srcds_linux
[Install]
WantedBy=multi-user.target

Learn more about server startup options and game modes.

With the script in place, we must next tell Ubuntu to launch it automatically on server boot.

systemctl --system daemon-reload
systemctl start csgo.service
systemctl enable csgo.service

Check that your server is running with this command:

systemctl status csgo.service

If you’re using Ubuntu’s firewall, here are some iptables rules to ensure that your server is reachable on the WAN.

iptables -A INPUT -p udp -m udp --sport 27000:27030 --dport 1025:65355 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 4380 --dport 1025:65355 -j ACCEPT

Here are the relevant CS:GO ports:

27000 to 27015 inclusive : UDP Game client traffic

4380 : UDP Steamworks P2P Networking and Steam Voice Chat

If you’re maintaining your iptables rules with iptables-services, here is a configuration file that will set all of this up automatically:

-A INPUT -p udp -m udp --sport 27000:27030 --dport 1025:65355 -j ACCEPT
-A INPUT -p udp -m udp --sport 4380 --dport 1025:65355 -j ACCEPT

Conclusion

Get ready to play Counter-Strike: GO on your newly launched server. Be sure to invite your friends, and to share this article with them if they’re interested in setting up their own server