Networking
兩個客戶端可以連接到 OpenVPN 伺服器,但另一個不能
我有一個執行 Ubuntu 20.04 和 3 個客戶端的外部 OpenVPN 伺服器:
- 客戶端 1 (Android 11)
- Client2(Windows 10 和 Virtualbo 主機)
- Client3(Ubuntu 20.04 Virtualbox 來賓)
所有 3 個客戶端都能夠通過 SSH 連接到伺服器,但只有客戶端 1 和 2 可以連接到伺服器 OpenVPN。這讓我發瘋:客戶端 3 可以通過 SSH 連接到伺服器,但不能通過 OpenVPN。
我專注於 client3,因為 1 和 2 都可以。這是我的連接嘗試:
$ openvpn --config leaf9.ovpn Mon Feb 8 18:56:56 2021 Unrecognized option or missing or extra parameter(s) in leaf9.ovpn:14: block-outside-dns (2.4.7) Mon Feb 8 18:56:56 2021 OpenVPN 2.4.7 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Sep 5 2019 Mon Feb 8 18:56:56 2021 library versions: OpenSSL 1.1.1g 21 Apr 2020, LZO 2.10 Mon Feb 8 18:56:56 2021 Outgoing Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication Mon Feb 8 18:56:56 2021 Incoming Control Channel Authentication: Using 512 bit message hash 'SHA512' for HMAC authentication Mon Feb 8 18:56:56 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]123.123.123.0:1194 Mon Feb 8 18:56:56 2021 Socket Buffers: R=[131072->131072] S=[16384->16384] Mon Feb 8 18:56:56 2021 Attempting to establish TCP connection with [AF_INET]123.123.123.0:1194 [nonblock] Mon Feb 8 18:57:00 2021 TCP: connect to [AF_INET]123.123.123.0:1194 failed: Connection refused Mon Feb 8 18:57:00 2021 SIGUSR1[connection failed(soft),init_instance] received, process restarting Mon Feb 8 18:57:00 2021 Restart pause, 5 second(s) ^CMon Feb 8 18:57:00 2021 SIGINT[hard,init_instance] received, process exiting
在伺服器 OpenVPN 日誌上沒有任何反應(客戶端 1 和 2 我可以看到連接成功) 似乎 client3 OpenVPN 數據包沒有到達伺服器,但它的 SSH 數據包可以。
通過 OpenVPN 連接的 tcpdump
18:58:22.229266 IP leaf9.51870 > 123.123.123.0.1194: Flags [S], seq 1069973754, win 64240, options [mss 1460,sackOK,TS val 4103806626 ecr 0,nop,wscale 7], length 0 18:58:22.233116 IP leaf9.56081 > fritz.box.domain: 56163+ PTR? 15.2.0.10.in-addr.arpa. (40) 18:58:22.298298 IP fritz.box.domain > leaf9.56081: 56163 NXDomain 0/0/0 (40) 18:58:22.301063 IP leaf9.51370 > fritz.box.domain: 3433+ PTR? 1.1.168.192.in-addr.arpa. (42) 18:58:22.302352 IP fritz.box.domain > leaf9.51370: 3433* 10/1/1 PTR fritz.box., PTR www.fritz.box., PTR myfritz.box., PTR www.myfritz.box., PTR fritz.nas., PTR www.fritz.nas., PTR fritz-nas.fritz.box., PTR fritz-nas.box., PTR wpad.box., PTR wpad.fritz.box. (336) 18:58:23.247988 IP leaf9.51870 > 123.123.123.0.1194: Flags [S], seq 1069973754, win 64240, options [mss 1460,sackOK,TS val 4103807645 ecr 0,nop,wscale 7], length 0 18:58:24.460201 IP 123.123.123.0.1194 > leaf9.51870: Flags [R.], seq 0, ack 1069973755, win 0, length 0
通過 SSH 連接的 tcpdump
18:57:53.793395 IP leaf9.43942 > 123.123.123.0.22: Flags [S], seq 4052391502, win 64240, options [mss 1460,sackOK,TS val 4103778190 ecr 0,nop,wscale 7], length 0 18:57:53.798315 IP leaf9.34189 > fritz.box.domain: 26719+ PTR? 15.2.0.10.in-addr.arpa. (40) 18:57:53.848711 IP fritz.box.domain > leaf9.34189: 26719 NXDomain 0/0/0 (40) 18:57:53.851454 IP leaf9.60906 > fritz.box.domain: 64354+ PTR? 1.1.168.192.in-addr.arpa. (42) 18:57:53.852491 IP fritz.box.domain > leaf9.60906: 64354* 10/1/1 PTR fritz.box., PTR www.fritz.box., PTR myfritz.box., PTR www.myfritz.box., PTR fritz.nas., PTR www.fritz.nas., PTR fritz-nas.fritz.box., PTR fritz-nas.box., PTR wpad.box., PTR wpad.fritz.box. (336) 18:57:53.864247 IP 123.123.123.0.22 > leaf9.43942: Flags [S.], seq 32768001, ack 4052391503, win 65535, options [mss 1460], length 0 18:57:53.864341 IP leaf9.43942 > 123.123.123.0.22: Flags [.], ack 1, win 64240, length 0 18:57:53.955395 IP 123.123.123.0.22 > leaf9.43942: Flags [P.], seq 1:42, ack 1, win 65535, length 41 18:57:53.955439 IP leaf9.43942 > 123.123.123.0.22: Flags [.], ack 42, win 64199, length 0
請問有什麼想法嗎?
問題解決了在客戶端 .ovpn 文件中將協議更改為 udp。
.ovpn 文件中設置的協議是 tcp,因為我使用了網上找到的腳本來安裝 openvpn 並生成這些 .ovpn 文件。
奇怪的是,即使協議設置為 tcp,客戶端 1 和 2 也能正常工作。也許他們有某種備份力量。