我有一个运行 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 也能正常工作。也许他们有某种后备力量。