1. 先决条件和地点选择
本节列出了搭建 Rust 服务器之前需要准备的基本事项。推荐操作系统 Ubuntu 20.04/22.04 LTS 或者 Debian 是新版的(需要内核版本 ≥ 4.9 才能启用 BBR)。.
根据玩家人数推荐的硬件资源:
- 10-30名玩家: 4 个虚拟 CPU(单核性能强劲),8–12 GB 内存,NVMe 固态硬盘,1 Gbps 带宽
- 30-80 名玩家: 6-12 个高频虚拟 CPU,16-32 GB 内存,NVMe 固态硬盘,1-10 Gbps 带宽
- 100名以上玩家或角色扮演/模组服务器: 高频单核CPU,32-64 GB内存,NVMe RAID,10 Gbps
在选择数据中心位置时,务必选择…… 靠近球员的行动 例如:欧洲的法兰克福/阿姆斯特丹,美国东部的新泽西州/弗吉尼亚州,美国西部的洛杉矶,亚洲的新加坡或东京。我们公司拥有超过 全球85个地点 您可以根据玩家数量进行选择。如果存在遭受DDoS攻击的可能性,请选择带有反DDoS功能的套餐。.
2. 安装 SteamCMD 并下载 Rust Dedicated 模组
安装 SteamCMD 并下载服务器的基本步骤(以 Ubuntu 为例)。首先安装必备组件:
sudo apt update && sudo apt install -y lib32gcc-s1 wget tar创建一个专用的非root用户来运行Steam:
sudo useradd -m -s /bin/bash steam在 Steam 用户文件夹中安装 SteamCMD:
sudo -u steam bash -c 'mkdir -p ~/steamcmd && cd ~/steamcmd && wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz && tar -xvzf steamcmd_linux.tar.gz'下载并安装 Rust Dedicated 版本(服务器文件位于 /home/steam/rust_server):
sudo -u steam bash -c '~/steamcmd/steamcmd.sh +login anonymous +force_install_dir ~/rust_server +app_update 258550 validate +quit'3. 基本服务器配置(参数和 cfg 文件)
以下是运行 RustDedicated 时常用的参数示例。您可以将这些参数添加到 systemd 或启动脚本中:
/home/steam/rust_server/RustDedicated -batchmode +server.identity "myserver" +server.hostname "My Rust Server" +server.description "Welcome to my server" +server.url "https://your-website.example" +server.headerimage "https://..." +server.maxplayers 50 +server.seed 123456 +server.worldsize 4000 +server.saveinterval 300 +server.port 28015 +rcon.port 28016 +rcon.password "StrongRconPassword"重要参数说明:
- +服务器身份: 存储文件夹 ID(对备份很重要)
- +服务器主机名: 游戏列表中的服务器名称
- +server.seed 和 +server.worldsize: 地图确定
- +server.saveinterval: 自动保存时间(秒)
- 端口: 游戏端口通常为 28015(UDP),RCON 通常为 28016
您可以在类似这样的文件中添加更多设置。 server.cfg 将其放置好并在启动时加载。.
4. 创建 systemd 服务并更新脚本
用于运行服务和自动启动的 systemd 文件示例:
[Unit]
Description=Rust Dedicated Server
After=network.target
[Service]
User=steam
WorkingDirectory=/home/steam/rust_server
ExecStart=/home/steam/rust_server/RustDedicated -batchmode +server.identity "myserver" +server.hostname "My Rust Server" +server.port 28015 +rcon.port 28016 +rcon.password "ReplaceWithStrongPass" +server.maxplayers 50 +server.seed 123456 +server.worldsize 4000 +server.saveinterval 300
Restart=always
RestartSec=10
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target服务激活和启动:
sudo systemctl daemon-reload
sudo systemctl enable --now rust.service
sudo journalctl -u rust.service -f简单的更新脚本(示例):
#!/bin/bash
cd /home/steam/steamcmd
./steamcmd.sh +login anonymous +force_install_dir /home/steam/rust_server +app_update 258550 validate +quit
systemctl restart rust.service你可以每天在 cron 任务中运行此脚本,以保持服务器始终处于最新状态。.
5. 端口、防火墙和网络(更好的 Ping 和 BBR 设置)
常用的 Rust 端口:
- 游戏移植: 28015(UDP)
- RCON: 28016(通常为 TCP)
- 查询/服务器列表: 通常与游戏端口或游戏端口+1有关
ufw 配置示例(用于打开端口):
sudo ufw allow 22/tcp
sudo ufw allow 28015/udp
sudo ufw allow 28016/tcp
sudo ufw enable降低网络延迟和提高网络稳定性的建议:
- 选择靠近目标用户的数据中心
- 1 Gbps 或更高网络接口
- 最小丢包率和低抖动
- BBR激活 如果内核支持:
sudo sysctl -w net.core.default_qdisc=fq
sudo sysctl -w net.ipv4.tcp_congestion_control=bbr要使其永久生效,请将这些代码粘贴到…… /etc/sysctl.conf 添加。.
6. 硬件优化和内核设置
高负载情况下推荐的内核和操作系统设置:
sudo sysctl -w fs.file-max=2097152
sudo sysctl -w net.core.somaxconn=1024
sudo sysctl -w net.core.netdev_max_backlog=5000
sudo sysctl -w net.ipv4.tcp_max_syn_backlog=4096
sudo sysctl -w net.ipv4.tcp_fin_timeout=15
sudo sysctl -w net.ipv4.tcp_tw_reuse=1增加 Steam 用户打开文件数的限制(例如,修改 /etc/security/limits.conf 文件):
steam soft nofile 100000
steam hard nofile 200000关闭交换 它可以减少延迟,但请确保您有足够的内存:
sudo swapoff -a7. 安装 uMod(Oxide)和一些实用插件
uMod(原名 Oxide)是一个流行的 Rust 模组框架。安装方法:
- 从此处下载最新版本的uMod uMod 下载。.
- 将 uMod 文件解压到 RustDedicated 所在的服务器主文件夹;例如这样的文件夹。 管理 和 插件 它被创建了。.
- 重启服务器并安装文件夹中的插件 氧化物/插件 放上去。.
实用插件:
- Rust:IO(在线地图)
- 氏族或朋友
- 工具包、生成保护、更好的聊天
- 来自官方渠道的可信反作弊插件
8. 安全、监控和备份
安全:
- 以非 root 用户身份运行服务器(例如, 蒸汽).
- 设置强 RCON 密码,并尽可能更改默认端口。.
- 在网络层面使用防火墙(ufw/iptables)和DDoS防护。.
- 安装 fail2ban 以防止未经授权的登录尝试。.
监测:
- 简单工具:htop、nload、iftop、iotop、glances
- 高级工具:Prometheus + Grafana 用于资源和响应时间监控
- 使用 journalctl 检查日志,并查看 identity/map 文件夹中的日志。
备份:
定期备份文件夹 /home/steam/rust_server/identity/myserver 这是必要的。请使用 rsync 或 scp 将文件传输到备份服务器或云存储。备份脚本示例:
#!/bin/bash
dst="/backups/rust/$(date +%F)"
mkdir -p "$dst"
tar -czf "$dst/rust_identity_$(date +%F).tar.gz" -C /home/steam/rust_server/identity myserver
# rclone copy "$dst" remote:rust-backups9. 服务器管理和选择主机方案的实用技巧
要点:
- 高频单核 CPU 非常重要;Rust 的部分处理工作依赖于单核 CPU。.
- NVMe SSD 大幅提升了 IO 速度;这对降低负载和加快地图加载速度至关重要。.
- 高带宽(1-10 Gbps)对于大型服务器至关重要。.
- 对于安装了模组或角色扮演软件的服务器,需要更大的内存和更好的 CPU;通常不需要 GPU。.
如果您面临 DDoS 攻击流量或风险,请使用反 DDoS 服务器。我们公司拥有超过 全球85个地点 它还提供专为游戏设计的 VPS 和专用服务器方案,并提供 24/7 全天候支持。.
结论
本指南涵盖了安装 SteamCMD、下载 RustDedicated、配置服务器参数、管理端口和安全、优化系统和网络以及安装 uMod 插件等内容。遵循这些提示,您可以为玩家提供稳定、安全且低延迟的服务器。.
选择合适的地点、硬件资源,以及使用防 DDoS 功能和高质量的网络,会对玩家体验产生直接影响。.
计划和支持选择指南
如需获得技术建议并根据您的人口和游戏模型(普通、模组或角色扮演)选择最佳配置,您可以查看游戏的具体托管计划或联系技术团队以获得专家指导。.









