在 Linux 中使用 OpenVPN 設定 VPN 伺服器以透過 Internet 存取 LAN

在 Linux 中使用 OpenVPN 設定 VPN 伺服器以透過 Internet 存取 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

相關內容