Skip to content

远程联机

警告

若您是直接来到本页面进行查看的,请先阅读引言部分
引言部分有十分重要的说明,请您务必先仔细阅读。

本方案目前只测试了双人联机,效果良好。
该方案实现逻辑为:

  1. 其中一台玩家电脑用作服务器 + 游戏端,其他玩家电脑为正常游戏端。
    在此教程中,担任服务器的电脑需要有高带宽的网络
  2. 使用 SakuraFRP 进行内网穿透,使服务器能够被游戏端的电脑连接。
  3. 使用 OpenVPN 部署远程虚拟局域网。

1. 确定服务主机与游戏主机

  1. 请确定哪台电脑担任服务器。担任服务器的电脑务必有高带宽的网络。
  2. 其余的电脑均为游戏主机。
  3. 为避免网络波动等影响,请均使用有线网络连接
  4. 不建议联机的电脑之间地域距离过远(比如,广州和北京的联机)

2. 安装 OpenVPN

您可以在这里进行下载:

  • 官网
    请下载最新的安装包,务必选择 Windows 64-bit MSI installer
  • kKsk's File Site
    不提供最新安装包,但提供与本教程相同的安装包。

安装教程:

提示

以下步骤为担任服务器电脑的安装步骤。
游戏端电脑在打开安装包后,直接点击 Install Now 即可。

  1. 打开安装包,点击 Customize

1

  1. 按照图片进行勾选:

    • 勾选:OpenVPN --> Entire feature will be installed on local hard drive
    • 勾选:OpenSSL Utilities --> Entire feature will be installed on local hard drive

2
3

  1. 不要更改安装路径,点击 Install Now,等待安装完毕即可

3. 安装并登录 SakuraFRP

警告

此步骤只需要担任服务器的电脑执行即可。
游戏端电脑无需执行此步骤。

需要澄清的是:
SakuraFRP与XRS服务器无任何关联。
您若在SakuraFRP上升级套餐所产生的资费,均与XRS服务器无关。

  1. 前往SakuraFRP官网
  2. 点击注册账号(如果您已经有账号,直接点击管理面板登录即可)
  3. 自行注册账号 / 登录账号
  4. 服务 --> 软件下载 中,下载最新的 Windows端安装程序

4
5

  1. 下载完毕后,安装 SakuraFRP
  2. 安装完毕后,打开 SakuraFRP,进入 设置 界面,可以看到 账户 处需要填写访问密钥进行登录。

6

  1. 前往网页,点击 用户 --> 用户信息

7

  1. 账号信息 处,找到 访问密钥 ,点击右侧 点击复制

8

  1. 回到软件,填写访问密钥,点击登录即可

9

4. 创建内网穿透隧道

  1. 前往网页,找到 服务 --> 隧道列表

10

  1. 点击 创建隧道

11

  1. 寻找并选择一个合适的节点。请不要选择海外节点。
  2. 仿照图片进行设置。

12

  1. 点击 创建,回到软件,点击上方刷新按钮,刷新即可看到你创建的隧道。

13

5. 配置虚拟局域网(服务端)

警告

此步骤为最难的步骤,请务必仔细阅读。

  1. 使用终端/CMD进入到文件夹:C:\Program Files\OpenVPN\easy-rsa
cmd
cd "C:\Program Files\OpenVPN\easy-rsa"

14

  1. 执行命令进入 Easy-RSA 3 Shell
cmd
.\EasyRSA-Start.bat

15

  1. 初始化公钥基础设施目录 pki
cmd
./easyrsa init-pki

16

  1. 构建证书颁发机构(CA)密钥,CA 根证书文件将在后续用于对其他证书和密钥进行签名。

该命令要求输入 Common Name,随便输入一个名字即可。

cmd
./easyrsa build-ca nopass

17

此指令将会创建两个文件:

  • ca.crtC:\Program Files\OpenVPN\easy-rsa\pki
  • ca.keyC:\Program Files\OpenVPN\easy-rsa\pki\private

请将其复制到 C:\Program Files\OpenVPN\config 下。

  1. 构建服务器证书和密钥。

期间会请求输入 yes 以继续,请输入 yes 并回车。

cmd
./easyrsa build-server-full server nopass

18
19

此指令将会创建两个文件:

  • server.crtC:\Program Files\OpenVPN\easy-rsa\pki\issued
  • server.keyC:\Program Files\OpenVPN\easy-rsa\pki\private

请将其复制到 C:\Program Files\OpenVPN\config 下。

  1. 构建客户端证书和密钥。

期间会请求输入 yes 以继续,请输入 yes 并回车。

cmd
./easyrsa build-client-full client nopass

20
21

此指令将会创建两个文件:

  • client.crtC:\Program Files\OpenVPN\easy-rsa\pki\issued
  • client.keyC:\Program Files\OpenVPN\easy-rsa\pki\private

请将其复制到 C:\Program Files\OpenVPN\config 下。

  1. 生成 Diffie-Hellman 参数
cmd
./easyrsa gen-dh

22

此指令将会创建一个文件:

  • dh.pemC:\Program Files\OpenVPN\easy-rsa\pki\dh.pem

请将其复制到 C:\Program Files\OpenVPN\config 下。

  1. 复制并编辑配置文件

C:\Program Files\OpenVPN\sample-config 文件夹中,复制 server.ovpnC:\Program Files\OpenVPN\config 文件夹下。

使用代码编辑器(如:VSCode / Notepad--等)打开 server.ovpn
将文件内的内容替换为以下内容:

配置文件内容
ovpn
#################################################
# Sample OpenVPN 2.6 config file for            #
# multi-client server.                          #
#                                               #
# This file is for the server side              #
# of a many-clients <-> one-server              #
# OpenVPN configuration.                        #
#                                               #
# OpenVPN also supports                         #
# single-machine <-> single-machine             #
# configurations (See the Examples page         #
# on the web site for more info).               #
#                                               #
# This config should work on Windows            #
# or Linux/BSD systems.  Remember on            #
# Windows to quote pathnames and use            #
# double backslashes, e.g.:                     #
# "C:\\Program Files\\OpenVPN\\config\\foo.key" #
#                                               #
# Comments are preceded with '#' or ';'         #
#################################################

# Which local IP address should OpenVPN
# listen on? (optional)
;local a.b.c.d

# Which TCP/UDP port should OpenVPN listen on?
# If you want to run multiple OpenVPN instances
# on the same machine, use a different port
# number for each one.  You will need to
# open up this port on your firewall.
port 1194

# TCP or UDP server?
;proto tcp
proto udp

# "dev tun" will create a routed IP tunnel,
# "dev tap" will create an ethernet tunnel.
# Use "dev tap0" if you are ethernet bridging
# and have precreated a tap0 virtual interface
# and bridged it with your ethernet interface.
# If you want to control access policies
# over the VPN, you must create firewall
# rules for the TUN/TAP interface.
# On non-Windows systems, you can give
# an explicit unit number, such as tun0.
# On Windows, use "dev-node" for this.
# On most systems, the VPN will not function
# unless you partially or fully disable/open
# the firewall for the TUN/TAP interface.
dev tap
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel if you
# have more than one.
# You may need to selectively disable the
# Windows firewall for the TAP adapter.
# Non-Windows systems usually don't need this.
;dev-node MyTap

# SSL/TLS root certificate (ca), certificate
# (cert), and private key (key).  Each client
# and the server must have their own cert and
# key file.  The server and all clients will
# use the same ca file.
#
# See the "easy-rsa" project at
# https://github.com/OpenVPN/easy-rsa
# for generating RSA certificates
# and private keys.  Remember to use
# a unique Common Name for the server
# and each of the client certificates.
#
# Any X509 key management system can be used.
# OpenVPN can also use a PKCS #12 formatted key file
# (see "pkcs12" directive in man page).
#
# If you do not want to maintain a CA
# and have a small number of clients
# you can also use self-signed certificates
# and use the peer-fingerprint option.
# See openvpn-examples man page for a
# configuration example.
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret

# Diffie hellman parameters.
# Generate your own with:
#   openssl dhparam -out dh2048.pem 2048
dh dh.pem

# Allow to connect to really old OpenVPN versions
# without AEAD support (OpenVPN 2.3.x or older)
# This adds AES-256-CBC as fallback cipher and
# keeps the modern ciphers as well.
;data-ciphers AES-256-GCM:AES-128-GCM:?CHACHA20-POLY1305:AES-256-CBC

# Network topology
# Should be subnet (addressing via IP)
# unless Windows clients v2.0.9 and lower have to
# be supported (then net30, i.e. a /30 per client)
# Defaults to net30 (not recommended)
topology subnet

# Configure server mode and supply a VPN subnet
# for OpenVPN to draw client addresses from.
# The server will take 10.8.0.1 for itself,
# the rest will be made available to clients.
# Each client will be able to reach the server
# on 10.8.0.1. Comment this line out if you are
# ethernet bridging. See the man page for more info.
server 192.168.50.0 255.255.255.0

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt

# Configure server mode for ethernet bridging.
# You must first use your OS's bridging capability
# to bridge the TAP interface with the ethernet
# NIC interface.  Then you must manually set the
# IP/netmask on the bridge interface, here we
# assume 10.8.0.4/255.255.255.0.  Finally we
# must set aside an IP range in this subnet
# (start=10.8.0.50 end=10.8.0.100) to allocate
# to connecting clients.  Leave this line commented
# out unless you are ethernet bridging.
;server-bridge 10.8.0.4 255.255.255.0 10.8.0.50 10.8.0.100

# Configure server mode for ethernet bridging
# using a DHCP-proxy, where clients talk
# to the OpenVPN server-side DHCP server
# to receive their IP address allocation
# and DNS server addresses.  You must first use
# your OS's bridging capability to bridge the TAP
# interface with the ethernet NIC interface.
# Note: this mode only works on clients (such as
# Windows), where the client-side TAP adapter is
# bound to a DHCP client.
;server-bridge

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"
push "route 192.168.50.0 255.255.255.0 vpn_gateway"

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose the client
# having the certificate common name "Thelonious"
# also has a small subnet behind his connecting
# machine, such as 192.168.40.128/255.255.255.248.
# First, uncomment out these lines:
;client-config-dir ccd
;route 192.168.40.128 255.255.255.248
# Then create a file ccd/Thelonious with this line:
#   iroute 192.168.40.128 255.255.255.248
# This will allow Thelonious' private subnet to
# access the VPN.  This example will only work
# if you are routing, not bridging, i.e. you are
# using "dev tun" and "server" directives.

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2

# Suppose that you want to enable different
# firewall access policies for different groups
# of clients.  There are two methods:
# (1) Run multiple OpenVPN daemons, one for each
#     group, and firewall the TUN/TAP interface
#     for each group/daemon appropriately.
# (2) (Advanced) Create a script to dynamically
#     modify the firewall in response to access
#     from different clients.  See man
#     page for more info on learn-address script.
;learn-address ./script

# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# or bridge the TUN/TAP interface to the internet
# in order for this to work properly).
;push "redirect-gateway def1 bypass-dhcp"

# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.  CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
# The addresses below refer to the public
# DNS servers provided by opendns.com.
;push "dhcp-option DNS 208.67.222.222"
;push "dhcp-option DNS 208.67.220.220"

# Uncomment this directive to allow different
# clients to be able to "see" each other.
# By default, clients will only see the server.
# To force clients to only see the server, you
# will also need to appropriately firewall the
# server's TUN/TAP interface.
client-to-client

# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.  This is recommended
# only for testing purposes.  For production use,
# each client should have its own certificate/key
# pair.
#
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE.
duplicate-cn

# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 60

# For extra security beyond that provided
# by SSL/TLS, create an "HMAC firewall"
# to help block DoS attacks and UDP port flooding.
#
# Generate with:
#   openvpn --genkey tls-auth ta.key
#
# The server and each client must have
# a copy of this key.
# The second parameter should be '0'
# on the server and '1' on the clients.
;tls-auth ta.key 0 # This file is secret

# The maximum number of concurrently connected
# clients we want to allow.
;max-clients 100

# It's a good idea to reduce the OpenVPN
# daemon's privileges after initialization.
#
# You can uncomment this on non-Windows
# systems after creating a dedicated user.
;user openvpn
;group openvpn

user nobody
group nogroup

# The persist options will try to avoid
# accessing certain resources on restart
# that may no longer be accessible because
# of the privilege downgrade.
persist-key
persist-tun

# Output a short status file showing
# current connections, truncated
# and rewritten every minute.
status openvpn-status.log

# By default, log messages will go to the syslog (or
# on Windows, if running as a service, they will go to
# the "\Program Files\OpenVPN\log" directory).
# Use log or log-append to override this default.
# "log" will truncate the log file on OpenVPN startup,
# while "log-append" will append to it.  Use one
# or the other (but not both).
;log         openvpn.log
;log-append  openvpn.log

# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# Silence repeating messages.  At most 20
# sequential messages of the same message
# category will be output to the log.
;mute 20

# Notify the client that when the server restarts so it
# can automatically reconnect.
explicit-exit-notify 1

comp-lzo no
push "comp-lzo no"

保存即可

提示

上述提供的配置文件内容中,
设置的UDP端口号为 1194 ,与上述 SakuraFRP 配置中的UDP端口号相同。
设置的IP分配规则为 192.168.50.X,后续连接后,分配的IP为 192.168.50.X
并且使用了TAP的配置,因此只会代理局域网流程,不会影响正常软件的使用。

6. 配置虚拟局域网(客户端)

  1. C:\Program Files\OpenVPN\sample-config 下找到 client.ovpn
  2. 复制到 C:\Program Files\OpenVPN\config 文件夹下
  3. 编辑配置文件

使用代码编辑器(如:VSCode / Notepad--等)打开 client.ovpn
将文件内的内容替换为以下内容:

配置文件内容
ovpn
##############################################
# Sample client-side OpenVPN 2.6 config file #
# for connecting to multi-client server.     #
#                                            #
# This configuration can be used by multiple #
# clients, however each client should have   #
# its own cert and key files.                #
#                                            #
# On Windows, you might want to rename this  #
# file so it has a .ovpn extension           #
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
dev tap
;dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one.  On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote 127.0.0.1 1194
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server.  Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user openvpn
;group openvpn
user nobody
group nogroup

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here.  See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets.  Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description.  It's best to use
# a separate .crt/.key file pair
# for each client.  A single ca
# file can be used for all clients.
ca ca.crt
cert client.crt
key client.key

# Verify server certificate by checking that the
# certificate has the correct key usage set.
# This is an important precaution to protect against
# a potential attack discussed here:
#  http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the keyUsage set to
#   digitalSignature, keyEncipherment
# and the extendedKeyUsage to
#   serverAuth
# EasyRSA can do this for you.
remote-cert-tls server

# Allow to connect to really old OpenVPN versions
# without AEAD support (OpenVPN 2.3.x or older)
# This adds AES-256-CBC as fallback cipher and
# keeps the modern ciphers as well.
;data-ciphers AES-256-GCM:AES-128-GCM:?CHACHA20-POLY1305:AES-256-CBC

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20

替换完成后,我们需要进行一些修改:
在配置文件的约 42 行处:

ovpn
# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote 127.0.0.1 1194
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

这个时候我们需要前往SakuraFRP软件,启动创建好的隧道:

23

然后点击左侧 日志
找到所分配的连接地址(别抄图,这个每个人都不一样):

24

可以看到,上述示例的图片中,分配给我们的是 120.233.26.237:35518

然后我们修改连接的地址:

ovpn
# Are we connecting to a TCP or
# UDP server?  Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote 127.0.0.1 1194 // 这里删掉
remote 120.233.26.237 35518 // 这里添加
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing.  Otherwise
# try hosts in the order specified.
;remote-random

然后保存,这样我们的客户端配置文件就配置好了。

7. 分发客户端配置文件

我们需要创建一个文件夹存放客户端配置文件以及其需要的证书等文件。

文件夹内包含4个文件:

  • ca.crt: 前面已经复制到了 C:\Program Files\OpenVPN\config 下了
  • client.crt:位于 C:\Program Files\OpenVPN\easy-rsa\pki\issued
  • client.key:位于 C:\Program Files\OpenVPN\easy-rsa\pki\private
  • client.ovpn:第6步中所编辑的配置文件

请放置到一个文件夹内,然后将该文件夹打包压缩包并发送给游戏端的玩家。

25
26

游戏端的玩家接收到了压缩包后,请打开压缩包:

27

然后,打开 C:\Users\你的电脑用户名\OpenVPN\config 文件夹

28

创建 client 文件夹,然后将上述打包的4个文件全部放置进去

29

8. 关闭防火墙与调整跃点

所有玩家(包括服务端玩家与游戏端玩家)都应关闭防火墙
并且最好退出杀毒软件。

然后我们需要调整一下跃点使局域网的网卡的优先级高于互联网网卡,以便于连接成功。

  1. 打开控制面板

30

  1. 点击网络和Internet下方的 查看网络状态和任务

31

  1. 点击 更改适配器设置

32

  1. OpenVPN 的网卡的跃点调整为 10

33

  1. 将互联网的网卡的跃点调整为 20

34

9. 连接测试

  1. 担任服务端的玩家,首先先打开 SakuraFRP 的隧道开关:

35

  1. 在桌面找到 OpenVPN GUI 图标,双击打开,然后在任务栏里面找到图标

36

  1. 右键,点击连接,会弹出窗口,等待一段时间将会连接上服务器
  2. 您可以右键点击显示状态,查看到当前服务器的IP地址:

37

  1. 上述服务器IP地址被成功分配后,代表服务器已经启动。服务器成功启动后,再进行下一步操作。
  2. 游戏端的玩家启动 OpenVPN GUI,同样在任务栏找到图标,找到 client,点击连接:

38

  1. 等待一段时间,连接成功后,也会分配IP地址:

39

  1. 若显示如上述图类似,则代表测试成功。

10. 启动游戏

所有玩家应将TP模拟器中,游戏设置的 General - NetworkAdapterIP 设置为服务端玩家的IP地址,然后启动游戏。
然后需要保证基板ID不能冲突:

调整基板ID

请前往 机修菜单 ==> ゲ一ム設定 ==> 基板ID
所有电脑的基板ID不可冲突,您可以设置基板ID为1/2/3/4,总之所有电脑的基板ID不能冲突。

如图所示进入:

4
4

然后就可以开始游玩了。

提示

游玩完毕后,请记得断开OpenVPN的连接与SakuraFRP的连接。

11. 后续再次进行联机

后续若重新进行联机,玩家只需按照连接测试与启动游戏的步骤执行即可,无需重新配置。

12. 其他事宜

SakuraFRP有流量限制,但一般来说够用。
每日可以签到领流量进行使用。
若不足够可以自行购买流量包等。