OpenRA 服务器搭建:开源重制经典红色警戒和命令与征服
OpenRA 服务器搭建:开源重制经典红色警戒和命令与征服
OpenRA 是一款完全免费的开源项目,致力于用现代引擎重制经典即时战略游戏——红色警戒(Red Alert)、命令与征服:泰伯利亚黎明(Tiberian Dawn)以及沙丘 2000(Dune 2000)。与原版游戏不同,OpenRA 原生支持 Linux,内置在线多人对战系统,玩家可以通过官方大厅列表发现和加入全球服务器,也可以搭建私有服务器供好友联机。
本教程将指导你在 Ubuntu 22.04 上搭建一台 OpenRA 专用服务器,包括安装 OpenRA、配置服务端参数、设置 systemd 守护进程和防火墙规则,并介绍如何同时托管红色警戒和命令与征服两个游戏的服务器实例。
服务器配置建议
OpenRA 服务端使用纯 C# 编写(基于 .NET/Mono),在空载时内存占用约 150–300 MB,满人对战(8 人)通常在 400 MB 以内。CPU 占用相对较低,主要消耗在地图计算和网络同步。
推荐选择2 核 2GB 机型,可以同时跑红色警戒和命令与征服两个服务器实例,满足日常小队联机需求。
推荐使用雨云服务器 rainyun-com,注册填码2026off领 5 折,价格实惠,带宽充足,适合长期托管经典 RTS 游戏服务器。
操作系统推荐Ubuntu 22.04 LTS。
安装依赖
OpenRA 依赖 .NET 运行时(现代版本已迁移到 .NET 6+),安装前先确保系统软件包是最新的。
# 更新系统sudoaptupdate&&sudoaptupgrade-y# 安装常用工具sudoaptinstall-ywgetcurlgitunzip下载并安装 OpenRA
OpenRA 提供 deb 包和 AppImage 两种安装方式。推荐使用 GitHub Releases 上的 deb 包,安装简单且便于 systemd 管理。
# 查看最新版本(访问 GitHub Releases 确认版本号)# https://github.com/OpenRA/OpenRA/releases# 以 release-20231010 为例OPENRA_VERSION="release-20231010"# 下载 deb 包wget-O/tmp/openra.deb\"https://github.com/OpenRA/OpenRA/releases/download/${OPENRA_VERSION}/openra_${OPENRA_VERSION}_amd64.deb"# 安装sudodpkg-i/tmp/openra.debsudoapt-getinstall-f-y# 修复可能的依赖问题# 验证安装openra-ra--versionopenra-cnc--version也可以通过 apt 安装(版本可能略旧):
sudoaptinstall-yopenra下载服务端
OpenRA 安装完成后,服务端二进制文件通常位于/usr/lib/openra/。你也可以单独下载服务端版本:
# 创建专用目录和用户sudomkdir-p/opt/openrasudouseradd-r-s/bin/false-d/opt/openra openrasudochownopenra:openra /opt/openra# 确认服务端可执行文件位置whichopenra-ra# 通常输出:/usr/bin/openra-ra配置文件
OpenRA 服务端通过命令行参数传入配置,无需配置文件。核心参数如下:
| 参数 | 说明 | 示例 |
|---|---|---|
Server.Name | 服务器显示名称 | "我的红警服务器" |
Server.ListenPort | 监听端口 | 1234 |
Server.MaxPlayers | 最大玩家数 | 8 |
Server.Password | 房间密码(留空为公开) | "" |
Server.AdvertiseOnline | 是否在官方列表中显示 | True |
Server.Map | 起始地图 Hash(可选) |
启动脚本
红色警戒服务器
sudotee/opt/openra/start-ra.sh>/dev/null<<'EOF' #!/bin/bash exec openra-ra \ Server.Name="雨云红色警戒服务器" \ Server.ListenPort=1234 \ Server.MaxPlayers=8 \ Server.Password="" \ Server.AdvertiseOnline=True \ Server.RequireAuthentication=False EOFsudochmod+x /opt/openra/start-ra.sh命令与征服:泰伯利亚黎明服务器
sudotee/opt/openra/start-cnc.sh>/dev/null<<'EOF' #!/bin/bash exec openra-cnc \ Server.Name="雨云泰伯利亚黎明服务器" \ Server.ListenPort=1235 \ Server.MaxPlayers=8 \ Server.Password="" \ Server.AdvertiseOnline=True \ Server.RequireAuthentication=False EOFsudochmod+x /opt/openra/start-cnc.sh沙丘 2000 服务器
sudotee/opt/openra/start-d2k.sh>/dev/null<<'EOF' #!/bin/bash exec openra-d2k \ Server.Name="雨云沙丘2000服务器" \ Server.ListenPort=1236 \ Server.MaxPlayers=6 \ Server.Password="" \ Server.AdvertiseOnline=True EOFsudochmod+x /opt/openra/start-d2k.sh手动测试(前台运行):
sudo-uopenra /opt/openra/start-ra.sh看到类似Server listening on port 1234的输出即表示启动成功,按Ctrl+C停止。
systemd 服务
为红色警戒和命令与征服分别创建 systemd 服务单元:
红色警戒服务
sudotee/etc/systemd/system/openra-ra.service>/dev/null<<'EOF' [Unit] Description=OpenRA Red Alert Dedicated Server After=network.target [Service] Type=simple User=openra WorkingDirectory=/opt/openra ExecStart=/opt/openra/start-ra.sh Restart=on-failure RestartSec=15 StandardOutput=journal StandardError=journal SyslogIdentifier=openra-ra [Install] WantedBy=multi-user.target EOF命令与征服服务
sudotee/etc/systemd/system/openra-cnc.service>/dev/null<<'EOF' [Unit] Description=OpenRA Tiberian Dawn Dedicated Server After=network.target [Service] Type=simple User=openra WorkingDirectory=/opt/openra ExecStart=/opt/openra/start-cnc.sh Restart=on-failure RestartSec=15 StandardOutput=journal StandardError=journal SyslogIdentifier=openra-cnc [Install] WantedBy=multi-user.target EOF启动并设置开机自启:
sudosystemctl daemon-reload# 启用并启动红色警戒服务sudosystemctlenable--nowopenra-ra# 启用并启动命令与征服服务sudosystemctlenable--nowopenra-cnc# 查看状态sudosystemctl status openra-rasudosystemctl status openra-cnc防火墙配置
OpenRA 服务端默认使用TCP 1234 端口,每个游戏实例使用不同端口。
# 红色警戒端口sudoufw allow1234/tcp# 命令与征服端口sudoufw allow1235/tcp# 沙丘 2000 端口(如果运行)sudoufw allow1236/tcp# 如果 UFW 未启用sudoufwenable# 查看规则sudoufw status verbose同时在雨云控制台的安全组中放行对应端口的 TCP 入站规则。
查询服务器状态
通过日志查看连接信息
# 实时查看红色警戒服务器日志sudojournalctl-uopenra-ra-f# 查看最近 100 行日志sudojournalctl-uopenra-ra-n100通过 OpenRA 客户端验证
- 启动 OpenRA 客户端(红色警戒)
- 点击「多人游戏」→「直接连接」
- 输入服务器 IP 和端口
1234 - 如果服务器配置了
AdvertiseOnline=True,它还会出现在全球服务器列表中
常用管理操作
# 重启红色警戒服务器sudosystemctl restart openra-ra# 停止服务器sudosystemctl stop openra-ra# 查看所有 openra 相关进程psaux|grepopenra# 查看端口监听状态ss-tlnp|grep-E'1234|1235|1236'结尾
通过本教程,你已成功在 Linux 上搭建了 OpenRA 专用服务器,可以同时为红色警戒、命令与征服等经典 RTS 游戏提供多人联机服务。OpenRA 完全免费,服务端轻量,非常适合长期托管。
