在 Linux 中使用 OpenVPN 设置 VPN 服务器,通过互联网进行 LAN 访问

在 Linux 中使用 OpenVPN 设置 VPN 服务器,通过互联网进行 LAN 访问

我想设置一个 LAN 互联网 VPN 服务器,以便能够访问我的计算机、与朋友一起玩游戏等...我对网络知之甚少。但我找到了一个指南:

https://codentium.com/using-openvpn-to-play-old-games-with-your-friends.html

一切都很顺利,直到我启动服务后出现错误。错误如下:

“journalctl -xe”输出:

-- Unit openvpn.games.service has begun starting up.
Nov 03 16:54:56 vm9707380586.bitcommand.com openvpn.games[2418]:  * Starting virtual private network daemon
Nov 03 16:54:56 vm9707380586.bitcommand.com ovpn-games[2432]: Options error: Unrecognized option or missing or extra parameter(s) in /etc/openvpn/games.conf: push (2.4.4)

Nov 03 16:54:56 vm9707380586.bitcommand.com ovpn-games[2432]: Use --help for more information.
Nov 03 16:54:56 vm9707380586.bitcommand.com openvpn.games[2418]:    ...fail!
Nov 03 16:54:56 vm9707380586.bitcommand.com systemd[1]: openvpn.games.service: Control process exited, code=exited status=1
Nov 03 16:54:56 vm9707380586.bitcommand.com systemd[1]: openvpn.games.service: Failed with result 'exit-code'.
Nov 03 16:54:56 vm9707380586.bitcommand.com systemd[1]: Failed to start LSB: Openvpn VPN service.
-- Subject: Unit openvpn.games.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit openvpn.games.service has failed.

更改push 10.42.42.0 255.255.255.0为之后push "10.42.42.0 255.255.255.0",我仍然收到另一个错误。

-- Unit openvpn.games.service has begun starting up.
Nov 03 14:21:25 vm9707380586.bitcommand.com openvpn.games[1446]:  * Starting virtual private network daemon
Nov 03 14:21:25 vm9707380586.bitcommand.com ovpn-games[1461]: Options error: ifconfig parms 'pool-persist' and 'games-ips.txt' must be valid addresses
Nov 03 14:21:25 vm9707380586.bitcommand.com ovpn-games[1461]: Use --help for more information.
Nov 03 14:21:25 vm9707380586.bitcommand.com openvpn.games[1446]:    ...fail!
Nov 03 14:21:25 vm9707380586.bitcommand.com systemd[1]: openvpn.games.service: Control process exited, code=exited status=1
Nov 03 14:21:25 vm9707380586.bitcommand.com systemd[1]: openvpn.games.service: Failed with result 'exit-code'.
Nov 03 14:21:25 vm9707380586.bitcommand.com systemd[1]: Failed to start LSB: Openvpn VPN service.
-- Subject: Unit openvpn.games.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit openvpn.games.service has failed. 

我的VPS操作系统:Ubuntu 18.04.5 LTS。

我完全按照网站进行的配置。

我找不到解决方案。有什么解决办法吗?

编辑1:

这是我的配置文件(/etc/openvpn/games.conf):

ca certs/keys/ca.crt
cert certs/keys/games.crt
key certs/keys/games.key
dh certs/keys/dh2048.pem

port 1194
proto udp
proto udp6
dev tap

user nobody
group nobody

server 10.42.42.0 255.255.255.0
client-to-client
push "route 10.42.42.0 255.255.255.0"
push 10.42.42.0 255.255.255.0
push "route-metric 512"
push "route 0.0.0.0 0.0.0.0"
topology subnet

persist-key
ifconfig pool-persist games-ips.txt

keepalive 10 120
comp-lzo

status /var/log/openvpn/games-status.log
log /var/log/openvpn/games.log
verb 4

尝试此命令后出现此错误:

openvpn --config /etc/openvpn/games.conf

Options error: Unrecognized option or missing or extra parameter(s) in /etc/openvpn/games.conf:15: push (2.4.4)
Use --help for more information.

我怀疑是 push 命令后缺少双引号,所以我改为push 10.42.42.0 255.255.255.0push "10.42.42.0 255.255.255.0"但仍然收到另一个错误:

Options error: ifconfig parms 'pool-persist' and 'games-ips.txt' must be valid addresses
Use --help for more information.

答案1

您的配置文件中似乎存在语法错误。如果不实际查看配置文件,很难确切地说出问题是什么。

您可能会通过使用以下命令在前台运行 openvpn 进程来发现更多详细的错误。

openvpn --config /etc/openvpn/games.conf

编辑:

检查了输出后,openvpn --config /etc/openvpn/games.conf发现问题出在第 23 行。正确的语法是ifconfig-pool-persist games-ips.txt

相关内容