آموزش کامل راه اندازی سرور بازی آنلاین Garry's Mod
در این مقاله به آموزش قدم‌به‌قدم راه اندازی سرور بازی آنلاین Garry’s Mod برای مدیران سرور و گیمرها پرداخته می‌شود.

آموزش کامل راه اندازی سرور بازی آنلاین Garry’s Mod

در این مقاله به آموزش قدم‌به‌قدم راه اندازی سرور بازی آنلاین Garry’s Mod پرداخته می‌شود. نکاتی از جمله انتخاب لوکیشن مناسب، نصب و پیکربندی SRCDS، تنظیمات امنیتی و بهینه‌سازی پینگ و منابع سخت‌افزاری شامل می‌شود.
0 Shares
0
0
0
0

Are you ready to set up a stable, secure, and low-latency Garry's Mod server?

This step-by-step guide for server administrators, gamers, and DevOps teams explains the complete process of setting up a Garry's Mod server (SRCDS) using SteamCMD. This article covers choosing the right location, installing and configuring SRCDS, security settings such as RCON and firewall, ping and hardware optimization, Workshop management, update and backup automation, and practical tips for maintenance and monitoring.

Choosing the right location and plan

Location selection is very important for Garry's Mod because the player experience is dependent on ping. For players in a specific country, choose the closest data center: Europe (Frankfurt/London), North America (New York/Chicago), West America (Los Angeles), Asia (Singapore/Tokyo), Australia (Sydney), Brazil (São Paulo).

The purpose of the ping below 80ms For an acceptable experience and below 60ms Recommended for competitive experience.

Hardware recommendation based on number of players

  • Small (up to 12 players): 2 vCPUs, 4GB RAM, SSD, 100Mbps bandwidth.
  • Medium (12–32 players): 4 vCPU, 8-16GB RAM, NVMe SSD, 1Gbps.
  • Large (more than 32 players or heavy addons): 6+ vCPU, 32GB+ RAM, NVMe, 1–10Gbps and high I/O server.

Use dedicated gaming servers or anti-DDoS servers for minimal latency and protection from attacks. Use a CDN to distribute download files (maps, addons) to reduce bandwidth and make downloads faster.

Prerequisites and System Preparation

Recommended operating system: Ubuntu 20.04/22.04 Or Debian 11/12. Run the following commands as a user with sudo access to update the system and install the prerequisites.

sudo apt update && sudo apt upgrade -y
sudo apt install -y wget lib32gcc-s1 lib32stdc++6 ca-certificates screen tmux unzip

If the package steamcmd Available in tanks:

sudo apt install -y steamcmd

Otherwise, install SteamCMD manually:

sudo mkdir -p /opt/steamcmd
sudo chown $USER:$USER /opt/steamcmd
cd /opt/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz

Create a non-root user to run the server:

sudo useradd -m -s /bin/bash gmod
sudo passwd gmod
sudo mkdir -p /home/gmod/server
sudo chown -R gmod:gmod /home/gmod

Download and install SRCDS with SteamCMD

Log in to the gmod user and run SteamCMD to install the Garry's Mod server:

sudo su - gmod
/opt/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/gmod/server +app_update 4020 validate +quit

To download Workshop items (e.g. collection or map):

/opt/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/gmod/server +app_update 4020 validate +workshop_download_item 4020 <WORKSHOP_ID> +quit

To automatically load a collection when starting SRCDS, use the following parameters:

+host_workshop_collection <COLLECTION_ID> +host_workshop_authkey <STEAM_WEB_API_KEY>

Server configuration — server.cfg and execution parameters

Put the base config file in the path /home/gmod/server/garrysmod/cfg/server.cfg Create or edit. Example of basic settings:

hostname "My GMod Server"
rcon_password "PUT_A_STRONG_PASSWORD_HERE"
sv_password ""
sv_cheats 0
sv_lan 0
sv_allowdownload 1
sv_allowupload 1
sv_maxrate 30000
sv_minrate 5000
sv_timeout 120
sv_voiceenable 1
sv_pure 0
sv_region 3

Configuration tips:

  • sv_maxrate and sv_minrate Adjust based on bandwidth and number of players.
  • To manage mods and access files from workshop collection Use to have players automatically download files.

Example SRCDS execution parameter:

cd /home/gmod/server
./srcds_run -game garrysmod +maxplayers 32 +map gm_flatgrass -tickrate 66 -port 27015 +host_workshop_collection <COLLECTION_ID> -autoupdate

Running the server as a systemd service

Create a systemd service for easy management and automatic startup at boot. Example of creating a service file:

sudo tee /etc/systemd/system/gmod.service <<'EOF'
[Unit]
Description=Garry's Mod Server
After=network.target

[Service]
Type=simple
User=gmod
WorkingDirectory=/home/gmod/server
ExecStart=/home/gmod/server/srcds_run -game garrysmod +maxplayers 32 +map gm_flatgrass -tickrate 66 -port 27015
Restart=on-failure
RestartSec=10
LimitNOFILE=100000

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable gmod.service
sudo systemctl start gmod.service
sudo journalctl -u gmod.service -f

Firewall, ports, and network security

Common Garry's Mod / SRCDS ports:

  • UDP 27015 (game and query)
  • TCP/UDP 27015 (RCON may use TCP)
  • UDP 27005 (Steam client)

Example configuration with UFW:

sudo ufw allow 27015/tcp
sudo ufw allow 27015/udp
sudo ufw allow 27005/udp
sudo ufw enable

To protect against DDoS, use anti-DDoS server plans to filter network attacks before they reach the server.

Optimize performance and reduce ping

Key tips for improving server performance:

  • Choose a location close to players to lower RTT.
  • Use SSD/NVMe to reduce map load times and increase I/O.
  • Use a high-frequency CPU for physics calculations; GMod relies on single-core frequency in many cases.

Network kernel settings (example):

sudo sysctl -w net.core.rmem_max=26214400
sudo sysctl -w net.core.wmem_max=26214400

Also, balance sv_maxrate, tickrate, and maxplayers based on resources and number of players, and test heavy mods before releasing them to the server.

Mod management, Workshop and download automation

Use SteamCMD to add mods from the Workshop:

/opt/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/gmod/server +workshop_download_item 4020 <WORKSHOP_ID> +quit

Suggestion: Use collection and pass its ID in the parameter +host_workshop_collection Set Steam to download items when the server is running.

To manually install addons, simply copy the files to garrysmod/addons Put it in and restart the server.

Automatic updates and backups

A simple script to update SRCDS:

#!/bin/bash
systemctl stop gmod
/opt/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/gmod/server +app_update 4020 validate +quit
systemctl start gmod

Put in cron (example every day at 4am):

sudo crontab -e
0 4 * * * /home/gmod/update_gmod.sh >> /var/log/gmod_update.log 2>&1

Backup: from folders garrysmod/maps, garrysmod/addons and cfg backups regularly. Use rsync or cloud infrastructure snapshots and object storage (S3-compatible) for fast recovery.

Monitoring, logs, and maintenance

Logs in garrysmod/logs and systemd are visible. Use logrotate to rotate logs.

To monitor the status of the server, tools such as Prometheus + Grafana Or Zabbix It is recommended to monitor CPU, RAM, network, and packet loss.

Scheduled restarts (e.g. every 6–12 hours) can reduce memory leaks and problems caused by addons.

Practical tips for managers and DevOps

  • First, test updates on a staging server to identify mod issues.
  • Use a domain name or DNS for the server to make changing the IP easier; create an A record for server.example.com.
  • Use CDN for downloading files and Load Balancer and BGP/Anycast for high availability.

Best Practice: When increasing capacity or providing a public service, use file traffic splitting to CDNs and distributed design to reduce server load and improve availability.

Summary and general recommendations

By following this guide, you can set up a stable, secure, and optimized Garry's Mod server, from installing SRCDS with SteamCMD to configuring server.cfg, systemd service, firewall, and anti-DDoS protection. Pay attention to location, proper hardware, and use of CDN for best performance.

The closest data center to your target users (e.g. Europe: Frankfurt/London, Asia: Singapore/Tokyo) is the best option for the lowest ping.
You can install SRCDS by creating a non-root user, downloading SteamCMD, and running the +app_update 4020 command from SteamCMD.
Enable RCON only when needed, use strong passwords and IP access restrictions, and utilize a management tunnel or VPN if possible.
Use collection and set its ID to +host_workshop_collection to have Steam automatically download items; test heavy mods before publishing.
Regular backups of the maps, addons, and cfg folders with rsync or cloud snapshot and storing them in object storage (S3-compatible) are the best practice.

You May Also Like