Logo
My Journal
Blog

Timeline

Blog

Guide how to install Counter strike Server Under Linux

Installing the server


Once logged in, do not start x-windows, rather stay in the command line interface (hereafter referred to as the CLI). If your Linux box automatically starts x-windows don’t worry… when it starts up, just click on the Terminal Emulation icon you may have it on your taskbar or you may need to look in the “Start Menu” to find it. When you do find it and click on it, a box should open up that has something similar to this:

[email protected] [/root] #

What you have may differ slightly depending upon who you logged in as and the name of your Linux box. In this case, user “root” is logged into the Linux server named “mod” which defaults to the directory “/root”.

Now at your CLI, you want to type:

cd /

Now type this:

mkdir /hlds

Now type:

cd /hlds

If all is well, you should see this at the CLI:

[[email protected] /hlds]

Again, it may differ slightly depending upon who you logged in as and the server name, but you need to make sure you have the “/hlds” part in there. If you don’t see it there, go back and start again from the beginning – you did something wrong.

Now a quick side note that you do not have to use this directory (“/hlds“), and in most cases it would be better to use a directory such as “/usr/local/games/hlds” to install your Counter-Strike dedicated server into. If you choose to use this directory instead (usually there is more disk space there) simply substitute

/usr/local/games/hlds

wherever you see

/hlds

And just start over at the top using this new directory. Just remember to substitute your directory (/usr/local/games/hlds) wherever you see (/hlds) for the rest of this tutorial if you chose to go that route!

Now you have a new directory at the top level called “hlds“. This is where we are going to install your Counter-Strike server. We need to download 2 files to get started. You should be in the “/hlds” directory on your server, so when we download the files, they will be saved in this directory. If you are not in the /hlds directory we created, or are not sure, simply type:

cd /hlds

You should now be in the correct directory.

Next, click here to download the latest full version of the Half-Life dedicated server for Linux. The most current full version is called “hlds_l_1120_full.bin”.

The package is no longer distributed as a tar/gz file. It is distributed as a .bin file that needs to be directly executed. So, after downloading the file, make it executable and then execute it. For example:

chmod a+x hlds_l_1120_full.bin
./hlds_l_1120_full.bin

You will be presented with a EULA, after which the usual tar/gz package will be extracted. From there you gunzip and untar as usual.
So let’s type:

tar zxvf hlds_l_3111.tar.gz

The computer will then proceed to unpack and install the dedicated server in the hlds directory we created earlier in a directory called “hlds_l“. When it finishes, type:

cd hlds_l

You should now be in the directory “/hlds/hlds_l“. Now you need to download the Counter-Strike mod. Click here to download the latest full version of it for Linux dedicated servers. The most current version is called “cs_15_full.tar.gz“.

Once the file has downloaded, type this in the CLI you are at:

tar zxvf cs_>15_full.tar.gz

This will unpack and install the Counter-Strike mod on your dedicated server.

» First start
You should now be able to run the basic Counter-Strike dedicated server. Let’s test it and see if it works. Make sure you are in the “/hlds/hlds_l” directory and type the following in the CLI:

./hlds_run -game cstrike +maxplayers 10 +map cs_assault

The computer should then proceed to start a dedicated 10 player server with the cs_assault map. At the end of starting the server you should see the following if all went ok:

[email protected] [/hlds] # ./hlds_run -game cstrike +maxplayers 10 +map cs_assault

Auto-restarting the server on crash
Console initialized.
Protocol version 46
Exe version 3.1.1.1
Exe build: 21:44:58 Jun 5 2003 (2415)
WON Auth Server
Server IP address 192.168.1.1:27015
Downloading Security Module from Speakeasy.net …
Completed downloading Security Module from Speakeasy.net
Server is in Secure Mode.
[…]
Adding Auth server 65.73.232.251:27040
Adding Auth server 65.73.232.253:27040
Adding master server 65.73.232.251:27010
Adding master server 65.73.232.253:27010
Adding master server 65.73.232.252:27010

. . .

If you see something similar – congratulations, first step is done. If not, don’t worry – we will have a closer look at the 2 possible ways to start the server.
Let’s have a closer look at the INTERNET-server.

» Internet-server
The easiest way to start a internet-server is as told above:

./hlds_run -game cstrike +maxplayers 10 +map cs_assault

This line is very important:
WON Auth Server

If you see it: great. If not – let’s check it step-by-step.
Maybe your server uses the wrong IP. As you see above, the server used for the example uses 192.168.1.1 – the LAN-IP (and interface) of the server. So we should change this.

quit

Now let’s try running it again with a new line, type:

./hlds_run -game cstrike +ip +maxplayers 10 +map cs_assault

For instance, if the IP address of my server were 213.128.127.2, I would type this:

./hlds_run -game cstrike +ip 213.128.127.2 +maxplayers 10 +map cs_assault

Now after you run that, let the game load and wait to see if it gives you “WON Auth Server” this time. If it does, you re set!

If you still do not get the “WON Auth Server” it could be that you are behind a firewall. If so, the only hope for you my friend is to speak to the network administrator and have him open the ports you need (27015 is the default). In any case, he will be able to help you get it opened up to the internet.

» LAN-server
The LAN-server has a different commandline. He doesn’t show up in the masterlist, he doesn’t load the anti-cheat-stuff and is only for LAN – so we should tell him this:
./hlds_run -game cstrike -insecure -nomaster +sv_lan 1 +maxplayers 18 +map de_dust

After typing the above you should see this:

Auto-restarting the server on crash
Console initialized.
Protocol version 46
Exe version 3.1.1.1
Exe build: 21:44:58 Jun 5 2003 (2415)
Auth Server
Server IP address 192.168.1.1:27015
Master server communication disabled.

Now the server should be visible in your game-browser – except for 2 cases:

1) either your server or/and your client has internet access at the same time
2) you’re trying to use the +ip – switch with a LAN-server

Don’t ask me why this happens – but it happens. In this case you have to connect via giving the IP (at the console, type connect XXX.XXX.XXX.XXX).

» Running the server as non-root-user
running the sever as root is a possible security-risc. So you should run the server with the permissions of a normal user. This user and his group must exist.
So when all the stuff is installed, you should change the ownership of the files so that the non-root-account is able to run the server:

chown -R USER:GROUP /hlds

That’s it …

Now that you have your server running, we need to optimize it. You can run the server just as it is now but your clients won’t get maximum performance from your server. You need to edit your server.cfg file in your cstrike directory (/hlds/cstrike/server.cfg). Look here for some cvars (command variables) that you can add to this text file (server.cfg) to customize and improve your server.

» Server behind router

If the server is behind a router there are a few things you have to check.
You must FORWARD the port your server runs on from your router to the server (unless you change it with “-port 270XX” it’s port 27015).
Also these ports needs to be open in the given direction:

TCP 7002 out
TCP 5273 out
UDP 27010 out
UDP 27012 in and out
UDP 27015 in (if your server runs on this port)

So let’s get it clear with an example. We have a little LAN, connected with a linux-router to the internet. The router is called mod, it’s LAN-IP is 192.168.1.1, the WAN-IP 195.158.153.161. The box which run’s the server is called 127.0.0.1, the IP is 192.168.1.4. And there is another client called cs, IP 192.168.1.3.
At the router NAT (masquerading and routing) is enabled and ipchains is configured this way:

/usr/sbin/ipmasqadm autofw -A -v -r udp 27015 27015 -h 192.168.1.4
/sbin/ipchains -A output -p udp -s $ANY 27012 -j ACCEPT
/sbin/ipchains -A output -p udp -s $ANY 27010 -j ACCEPT
/sbin/ipchains -A input -p udp -s $ANY 27015 -j ACCEPT
/sbin/ipchains -A output -p tcp -s $ANY 7002 -j ACCEPT
/sbin/ipchains -A output -p tcp -s $ANY 5273 -j ACCEPT

Now every internet-client can connect to this server by giving the WAN-IP. The in-game-serverbrowser doesn’t work – you must give the WAN-IP.
If the server is started like this:

[email protected] [/hlds] >./hlds_run -game cstrike +map de_dust +maxplayers 18

the other LAN-box called cs can connect to this server via play cs – lan-game

Remember, the above is only used as example – there can be any other router, any other IP-range and so on!
Just check that
the server port is FORWARDED
the other ports are opened in the right direction
and don’t forget: internet-clients have to connect via giving the WAN-IP

DOWNLOAD
Download Steam Dedicated Server v.1.1.2.0 [Linux]

cs_15_full.tar.gz

3 Comments
    • Guide how to install Counter strike Server Under Linux
      Apr 28, 2008 at 1:45 AM / Reply

      […] [Der Schockwellenreiter: Weblog] wrote an interesting post today onHere’s a quick excerpt Installing the server Once logged in, do not start x-windows, rather stay in the command line interface (hereafter referred to as the CLI). If your Linux box automatically starts x-windows don’t worry… when it starts up, just click on the Terminal Emulation icon you may have it on your taskbar or you may need to look in the “Start Menu” to find it. When you do find it and click on it, a box should open up that has something similar to this: [email protected] [/root] # What you have may differ […]

    • gloc
      Apr 28, 2008 at 3:45 PM / Reply

      Thanks for this great guide, im now running my own CS 1.6 server under my Linux Fedora thanks xmodx……..

    • rafael
      Nov 12, 2008 at 3:08 AM / Reply

      eu sempre queria um serve mais eu naum consigor ter entrer nesse site e me passa o q sabe…….

Leave A Comment