How to install Counter-Strike: GO server on CentOS 7
Counter-Strike: Global Offensive, also known as “GO” or “CS:GO” for short, is the fourth game in the popular Counter-Strike game series developed by Valve and distributed on its online platform, Steam. Able to run as a console game on Windows, MacOSX, and most recently, Linux, Counter-Strike:GO is a first-person shooter that features brand new maps, characters, and game modes alongside with classic Counter-Strike content. This game is notable for the fact that it allows players to host their own servers, resulting in a high degree of possible gameplay through the ability to introduce individual customization. The high flexibility in gameplay thanks to the personal servers makes Counter-Strike:GO a game that will entertain most people, and can provide a good break from a hard day’s work.
If you are interested in setting up your CentOS 7 server to run Counter-Strike: Global Offensive, this guide will show you the necessary steps.
Getting Started
The following prerequisite is necessary to complete this tutorial:
• 1 Node (Cloud Server or Dedicated Server) running CentOS 7.
• Root access to the node.
In this tutorial, a new user will also be created specifically for running the game. If you want to enable online play, you will additionally need the following (optional):
• Steam Account
• Counter-Strike: Global Offensive Game Ownership
Tutorial
Before we can progress to the actual installation and setup process of Counter-Strike:GO for your server, it is good practice to ensure that you have the latest information from the Linux package repository concerning available packages and package versions. Using the default package manager, yum, we can fetch this information first with the command update, before then upgrading the available packages. Make sure your system is up to date by executing these two commands as root to update the information and then upgrade required packages. If you are not the root user, but your current user has superuser privileges, precede both of the following commands (and all further root commands) with the additional command sudo to execute it as root. You may be prompted for the root password when using sudo.
yum update
yum upgrade
Counter-Strike:GO uses the digital distribution platform Steam, which is also developed by Valve. In order to be able to access Steam as well as complete the rest of the tutorial, you will need to install the following prerequisite libraries and packages using yum, this time with the install command:
yum install glibc.i686 libstdc++.i686 wget nano tar screen
With the prerequisites installed, now it is time to create a new user on our system to handle all Steam-related content. Ensure that you are logged in as root or can use sudo, then execute the following two simple commands. The first command will create the new user, while the second will then set the password. In our tutorial, we will name the user “csgo,” but you are free to replace the text below with whichever name you choose. This also applies to the password, which for the case of simplicity we have kept the same as the username.
adduser csgo
passwd csgo
Installing Steam and Counter-Strike:GO
At this point in the guide, we will switch to the Steam user we just created with the command su. Upon entering this command, you will be prompted for the Steam user’s password. Afterwards, we will navigate to that user’s home directory by using the ~ shortcut:
su csgo
cd ~
As the GO user, you will need to install the SteamCMD software in order to be able to install the Counter-Strike server. This software will allow you to interact with the Steam digital platform in order to download and manage games and applications such as Counter-Strike:Global Offensive. Download the SteamCMD package as an archive using the web utility wget:
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
The file downloaded above is a compressed TAR archive that containers the installer for SteamCMD. To be able to access its contents and run the installation script, you will need to unarchive the file using the command tar.
tar xf steamcmd_linux.tar.gz
Next, we will open the Steam command line interface, from which we will be able to install the Counter-Strike:GO server. First, ensure that you are in the correct directory that has the SteamCMD script. This directory should be located at the following location in the csgo home repository:
cd ~/Steam
Open the SteamCMD interface by running the steamcmd.sh bash script from the unarchived package:
./steamcmd.sh
By running steamcmd.sh, you will open the terminal shell for SteamCMD. In this command line interface, you must execute the following commands, which will login to Steam as an anonymous user in order to force install Counter-Strike:GO to the /csgo directory. Note that the 740 in the final line refers to the Counter-Strike:GO application and is its identification code for updates.
login anonymous
force_install_dir ./csgo
app_update 740 validate
The installation process will complete when all the contents are downloaded and the screen will say the following message:
Success! App '740' fully installed
When your installation has completed, you will need to return to the csgo user shell. To exit the SteamCMD interface, type the following and press the Enter key:
quit
Note that for updating your Counter-Strike:GO server, you will need to run the above commands in SteamCMD from open to exit each time you want to update.
As the SteamCMD installer has installed Counter-Strike:GO in the Steam user’s location, we will switch back to the csgo user in order to complete the remainder of the setup for Counter-Strike:GO. As a reminder, you can switch back to the root user at any time by opening a new root user shell or by exiting the current csgo user shell. To open a new root shell when you need it, type the following and give the root password when prompted:
su
Setting Up Remote Play
The current setup without any further configuration will limit players only to local connections, known as LAN. This means that other players on the same network as you will be able to access the server, but it will be inaccessible to other networks. In order to be able to connect to the Internet and play remotely with other users, you will need to obtain something called a “Game Server Login Token,” or GSLT. This token can only be obtained if you have a Steam account and own the Counter-Strike: Global Offensive game. For more information, you can see Valve’s wiki page, which covers what is needed to play online.
We will briefly cover how to register the game server login token, also known as the “GSLT,” if you do in fact have both a Steam account and own the original game. As per the wiki page instructions, you must access the following URL:
http://steamcommunity.com/dev/managegameservers
At the above URL, you will need to login with the Steam account that possesses Counter-Strike:GO. There, you will find a creation utility. Follow the on-screen instructions, using the App ID 730. Note that although the application itself is 740 (as in the case when updating with SteamCMD above), you will need to use the ID 730 for the token registration online. The creation utility will also prompt you to set an optional memo describing your new server. After validating the form, you will be provided with the GSLT and some information concerning the server, such as the last connection made. This page should look similar to the following:
Game
Authentication token (GSLT)
Last connection
Memo
730 *********************************
After you have copied the token, you will need to use the sv_setsteamaccount command in order to enable online play. Replace LOGIN_TOKEN in the line below with your own token value and execute:
sv_setsteamaccount LOGIN_TOKEN
It is important to provide the token information to Counter-Strike:GO before the configuration file for the server, as is detailed further on in this tutorial. The reason is that the server.cfg file used for server configuration is executed too late in the startup process for the GLST to be registered, resulting in your server failing during login.
Configuring the Counter-Strike:GO Server
The Counter-Strike:Global Offensive server configuration file will allow you to make the modifications you want to your server. Open and/or create this file for editing using the nano text editor in the same location as your CS:GO user’s home repository:
nano ~/csgo/csgo/cfg/server.cfg
Within this file, add the following lines, replacing the text ServerName and RconPassword with your desired values for the server. These will be used by individuals in order to access it:
hostname "ServerName"
rcon_password RconPassword
Beyond these two basic settings, you can find far more in the developer wiki for Counter-Strike: Global Offensive. Save and close the file for the changes to take into effect. You can start up your CS:GO server at any time by using the following command:
cd /home/csgo/csgo/
screen -dmS csgo ./srcds_run -game csgo -console -port 27015 +game_type 0 +game_mode 1 +mapgroup mg_bomb +map de_nuke -autoupdate
To make your life easier, you can also easily create a small script that will start up your server for you. Create the following file using the text editor nano:
nano ~/startcsgo.sh
Edit this file to have the following contents. You may need to ensure that the directories correspond correctly to your own file structure.
#!/bin/sh
cd /home/csgo/csgo
screen -S "Counter-Strike: Global Offensive Server" ./srcds_run -game csgo -usercon +game_type 0 +game_mode 1 +mapgroup mg_bomb +map de_dust2
Notice that the command above used the value 1 after game_mode and 0 after game_type. These two options are used to determine the gameplay on your server. You have the following possible combinations to modify the gameplay:
Mode game_mode game_type
Classic Casual 0 0
Classic Competitive 0 1
Arms Race 1 0
Demolition 1 1
When you have configured the file as you want, save and close. To be able to execute this file, you will need to edit its permissions using the command chmod to add the +x for “executable” to the script:
chmod +x ~/startcsgo.sh
Since we created this file, we can now also use it instead of the above command to start the server by running it as the CS:GO user:
cd ~/ && ./startcsgo.sh
On CentOS 7, systemd is responsible for starting up various programs to run on boot. You can use systemd to enable your Counter-Strike:GO server start up at boot. To do this, we will need to create a new service named for CS:GO. As the root user, use nano to open up the following file in the folder for systemd:
nano /lib/systemd/system/csgo.service
Input the following text into the file in order to create the daemon for systemd. Replace the text GSLT_CODE with the actual code of your token. Note again that the game mode and game type have been set. These you are free to modify as you wish according to the instructions following the initial, simple startup script.
[Unit]
Description=My 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 GSLT_CODE -net_port_try 1
ExecStop=killall -TERM srcds_linux
[Install]
WantedBy=multi-user.target
Having saved and closed the file, it is necessary to update your CentOS 7 system with the information about the new service we just added. Interact with systemd by using the command systemctl as root:
systemctl --system daemon-reload
systemctl start csgo.service
systemctl enable csgo.service
You can now easily check if the Counter-Strike:GO server is running with one simple call to systemctl to check its status:
systemctl status csgo.service
Configuring Your Firewall
If you have a firewall running on your server, which is likely as it runs by default for fresh server installations, you will also need to open up some ports so that the Counter-Strike:GO server will be able to be accessed. You have two options at this point: choose to remain with firewalld, or switch to iptables configurations. We recommend sticking with firewalld, as it is the default shipped with CentOS 7. However, those who have previously had experience with iptables may prefer it so we have also provided the instructions for how to configure the firewall.
Recommended Firewall Option: firewalld
The following lines of code will add the TCP and UDP ports 27015 to your firewall before reloading the firewall.
firewall-cmd --zone=public --add-port=27015/tcp --permanent
firewall-cmd --zone=public --add-port=27015/udp --permanent
firewall-cmd --reload
The ports we opened in the previous step are required for enabling play in the server. The ways the specific ports are used for Counter-Strike:GO are detailed below:
UDP 27000 to 27015: Game client traffic
UDP 27015 to 27030: Typically Matchmaking and HLTV
UDP 4380: Steamworks P2P Networking and Steam voice chat
Alternate Firewall Option: iptables
If you prefer to use iptables, the classic user application for managing Linux firewalls, instead for modifying the ports, you will have to make some modifications to your system first. This is because in CentOS 7, iptables was replaces by firewalld. If you still want to use iptables, you will have to disable the running firewall and use the package manager yum to install the necessary package and enable it to run on boot:
systemctl stop firewalld
systemctl mask firewalld
yum install iptables-services
systemctl enable iptables
Afterwards, you will be able to use stop,start, and restart to manage the service as shown in the below line:
systemctl [stop|start|restart] iptables
The modification of ports using iptables will take the following form, as seen in this example to open TCP on port 3030:
iptables -I INPUT -p tcp --dport 3030 -j ACCEPT
For each port listed in the instructions for firewalld, you will need to replicate those commands using the syntax shown in the above example for TCP port 3030:
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
You can easily find more information online about how to apply configurations for iptables if you want to learn more about its usage. To save your new iptables configurations when finished, use:
service iptables save
Regardless of whether you choose to remain with firewalld or use iptables, completing this steps will allow connections to be made to your server for remote gameplay.
Conclusion
Congratulations on finishing! Having installed and configured the Counter-Strike:GO server on your CentOS 7 slave, you are now free to enjoy the customizable gaming experience! See just what your server can handle and relax a little from a long work day. If this guide was helpful to you, please share it with others who might also be interested in setting up their own Counter-Strike servers.