comgunner - 2014-05-18

🎮 Counter-Strike 1.6 Dedicated Server (HLDS) - Unified Linux Documentation

This document provides a complete, unified installation and configuration guide for deploying a Counter-Strike 1.6 HLDS dedicated server on Linux systems, covering both Ubuntu/Debian-based and Arch Linux environments.

While the initial installation requirements differ between distributions, both environments converge into the same server structure and execution model.

This guide includes system setup, dependency installation, server configuration, background execution, systemd integration, and troubleshooting.

Default Server Path:

/home/csserver/27020

1. System User Setup (Required for All Distributions)

For security and isolation, the server must run under a dedicated system account (csserver).

  1. **Create the Service Account:**
    sudo useradd csserver
    sudo passwd csserver
  2. **Create Directory and Assign Ownership:**
    sudo mkdir /home/csserver
    sudo chown csserver:csserver /home/csserver
  3. **Log In as the Server User:**
    su - csserver
    Note: All subsequent installation steps must be executed while logged in as the csserver user.

2. Installation on Ubuntu / Debian-Based Systems

The HLDS engine is a 32-bit application and requires compatibility libraries on 64-bit systems.

  1. **Enable Multi-Arch Support:**
    sudo dpkg --add-architecture i386
    sudo apt-get update
  2. **Install Required Packages:**
    sudo apt-get install -y \
        gdb mailutils postfix tmux ca-certificates lib32gcc1 \
        gcc g++ clang \
        lib32z1 lib32ncurses5 lib32bz2-1.0 lib32z1-dev \
        libc6-dev-i386 libc6-i386 \
        gcc-multilib g++-multilib

    These dependencies ensure HLDS, Metamod, AMX Mod X, and DProto operate correctly.


3. Installation on Arch Linux

Arch Linux requires the multilib repository for 32-bit support.

  1. **Verify/Enable Multilib:**

    Ensure the [multilib] section is enabled in /etc/pacman.conf:

    [multilib]
    Include = /etc/pacman.d/mirrorlist
  2. **Update the System:**
    sudo pacman -Syu
  3. **Install Required Packages:**
    sudo pacman -S --needed \
        gcc-multilib gdb tmux ca-certificates \
        lib32-gcc-libs lib32-glibc

    These packages provide the necessary 32-bit runtime environment.


4. Download and Extract the Preconfigured Server (All Distros)

Ensure you are logged in as the csserver user.

4.1 Download Package

cd /home/csserver
wget "https://downloads.sourceforge.net/project/cs16serverpreconfiguredlinux/beta2014/linuxserver%2BdprotoDualnosteam.tar.gz"

4.2 Extract Contents

tar xvzf linuxserver+dprotoDualnosteam.tar.gz

The extraction creates the directory /home/csserver/27020. This package includes HLDS, Metamod, AMX Mod X, and DProto, preconfigured with the correct liblist.gam entries.


5. Server Configuration

5.1 Edit server.cfg

  1. **Navigate:**
    cd /home/csserver/27020/cstrike
  2. **Edit:**
    nano server.cfg
  3. **Modify essential variables (Example):**
    hostname "CS 1.6 Server"
    rcon_password "secureRcon123" ; Set a secure RCON password
    

5.2 Enable DProto (Dual Protocol)

DProto allows both Steam and non-Steam clients to join.

  1. **Create and Configure dproto.cfg:**
    touch /home/csserver/27020/dproto.cfg
    nano /home/csserver/27020/dproto.cfg

    Action: Paste the contents from the official configuration source: https://pastebin.com/raw/crb5bNk5

  2. **Add Client Rejection Message:**

    Add the following line to /home/csserver/27020/cstrike/server.cfg:

    dp_rejmsg_nosteam47 "Sorry, you're using an old client, download a newer version."

6. Server Execution

6.1 Manual Execution (Testing)

Run the server directly for testing. Replace XXX.XXX.XXX.XXX with your server's public IP address.

cd /home/csserver/27020
./hlds_run -game cstrike +ip XXX.XXX.XXX.XXX +port 27016 -pingboost 3 +maxplayers 22 +map de_dust -autoupdate

To stop the server, press:

Ctrl + C

6.2 Background Execution with screen

Use screen to run HLDS detached from the terminal.

screen -A -m -d -S csserver \
./hlds_run -game cstrike +ip XXX.XXX.XXX.XXX +port 27016 -pingboost 3 +maxplayers 22 +map de_dust -autoupdate &
  • **To attach (view console):** screen -r csserver
  • **To detach (leave running):** Ctrl + A then D

7. Creating a systemd Service

For reliable, persistent operation and automatic restarts.

7.1 Create Service File

This requires sudo privileges.

sudo nano /etc/systemd/system/hlds.service

Insert the following configuration:

[Unit]
Description=HLDS Counter-Strike 1.6 Server
Wants=network-online.target
After=network-online.target

[Service]
WorkingDirectory=/home/csserver/27020
ExecStart=/home/csserver/27020/hlds_run -game cstrike +ip XXX.XXX.XXX.XXX +port 27016 -pingboost 3 +maxplayers 22 +map de_dust -autoupdate
User=csserver
Restart=on-failure

[Install]
WantedBy=multi-user.target

7.2 Reload and Enable Service

This requires **sudo** privileges.

sudo systemctl daemon-reload
sudo systemctl enable hlds
sudo systemctl start hlds

8. Network and Firewall Requirements

The following UDP ports must be open on the host firewall and forwarded on your router.

Port (UDP) Function
27005 Server monitoring and status
27016 Primary game communication (if using this port)

Example Firewall Configuration (iptables):

sudo iptables -A INPUT -p udp --dport 27005 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 27016 -j ACCEPT

9. Optional Server Update via SteamCMD

Warning: Use with caution; not recommended for preconfigured mod distributions as it may overwrite necessary files.
  1. **Install SteamCMD (as csserver):**
    cd /home/csserver
    wget http://media.steampowered.com/client/steamcmd_linux.tar.gz
    tar xvfz steamcmd_linux.tar.gz
    chmod +x steamcmd.sh
    ./steamcmd.sh
  2. **Inside SteamCMD Console:**
    login anonymous
    force_install_dir /home/csserver/27020/
    app_update 90 update
    • *To validate the installation:* app_update 90 validate
    • *To install the beta branch:* app_update 90 -beta beta validate

10. Troubleshooting

Issue Resolution
**High latency (ping)** Ensure only one HLDS instance is running, verify -pingboost 3, confirm no port conflicts, and check CPU governors (set to "performance").
**Server not listed publicly** Ensure public IP is correctly set in +ip, verify router port forwarding, check for ISP's CGNAT usage.
**Missing 32-bit libraries (Ubuntu)** Re-run architecture and package installation: sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install libc6-i386 lib32gcc1
**Segmentation fault (Arch)** Reinstall 32-bit libs: sudo pacman -S lib32-glibc lib32-gcc-libs

11. Frequently Asked Questions (FAQ)

Question Answer
**Can I run multiple HLDS servers?** Yes, provided each uses a unique port (e.g., +port 27016 and +port 27017).
**Can the server run without DProto?** Yes. However, only official Steam clients will be able to join the server.
**How do I change the starting map?** Modify the startup parameter in hlds_run or hlds.service: change +map de_dust to +map de_dust2.
**Does this work on VPS servers?** Yes, provided UDP ports are not blocked by the hosting infrastructure.

12. References

 

Last edit: comgunner 2 hours ago