Linux
為什麼 OpenVPN 客戶端無法在 Linux 上連接?
此 VPN 在 Windows 中執行良好,但嘗試在 CentOS 中啟動它會執行幾秒鐘,最終停止,錯誤日誌中沒有任何消息。此外,伺服器會立即停止響應 ping,同時連接到 Windows 機器繼續執行的位置。
client dev tun proto udp remote 151.80.xxx.xxx 1194 resolv-retry infinite nobind persist-key persist-tun remote-cert-tls server auth SHA512 cipher AES-256-CBC ignore-unknown-option block-outside-dns block-outside-dns verb 3
沒有啟動 VPN 的 ip r
default via 51.195.234.254 dev eth0 51.195.234.254 dev eth0 scope link
有了它活躍
0.0.0.0/1 via 10.8.0.1 dev tun0 default via 51.195.234.254 dev eth0 10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.2 51.195.234.254 dev eth0 scope link 128.0.0.0/1 via 10.8.0.1 dev tun0 151.80.xxx.xx via 51.195.234.254 dev eth0
日誌
Fri May 21 19:42:19 2021 OpenVPN 2.4.11 x86_64-redhat-linux-gnu [Fedora EPEL patched] [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Apr 21 2021 Fri May 21 19:42:19 2021 library versions: OpenSSL 1.0.2k-fips 26 Jan 2017, LZO 2.06 Fri May 21 19:42:19 2021 Outgoing Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key Fri May 21 19:42:19 2021 Outgoing Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication Fri May 21 19:42:19 2021 Incoming Control Channel Encryption: Cipher 'AES-256-CTR' initialized with 256 bit key Fri May 21 19:42:19 2021 Incoming Control Channel Encryption: Using 256 bit message hash 'SHA256' for HMAC authentication Fri May 21 19:42:19 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]151.80.xxx.xxx:1194 Fri May 21 19:42:19 2021 Socket Buffers: R=[212992->212992] S=[212992->212992] Fri May 21 19:42:19 2021 UDP link local: (not bound) Fri May 21 19:42:19 2021 UDP link remote: [AF_INET]151.80.xxx.xxx:1194 Fri May 21 19:42:19 2021 TLS: Initial packet from [AF_INET]151.80.xxx.xxx:1194, sid=3b917597 2f279e15 Fri May 21 19:42:19 2021 VERIFY OK: depth=1, CN=ChangeMe Fri May 21 19:42:19 2021 VERIFY KU OK Fri May 21 19:42:19 2021 Validating certificate extended key usage Fri May 21 19:42:19 2021 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication Fri May 21 19:42:19 2021 VERIFY EKU OK Fri May 21 19:42:19 2021 VERIFY OK: depth=0, CN=server Fri May 21 19:42:19 2021 Control Channel: TLSv1.2, cipher TLSv1/SSLv3 ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA Fri May 21 19:42:19 2021 [server] Peer Connection Initiated with [AF_INET]151.80.xxx.xxx:1194 Fri May 21 19:42:20 2021 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1) Fri May 21 19:42:20 2021 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 213.186.33.99,dhcp-option DNS 213.186.33.199,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig 10.8.0.2 255.255.255.0,peer-id 0,cipher AES-256-GCM' Fri May 21 19:42:20 2021 OPTIONS IMPORT: timers and/or timeouts modified Fri May 21 19:42:20 2021 OPTIONS IMPORT: --ifconfig/up options modified Fri May 21 19:42:20 2021 OPTIONS IMPORT: route options modified Fri May 21 19:42:20 2021 OPTIONS IMPORT: route-related options modified Fri May 21 19:42:20 2021 OPTIONS IMPORT: --ip-win32 and/or --dhcp-option options modified Fri May 21 19:42:20 2021 OPTIONS IMPORT: peer-id set Fri May 21 19:42:20 2021 OPTIONS IMPORT: adjusting link_mtu to 1624 Fri May 21 19:42:20 2021 OPTIONS IMPORT: data channel crypto options modified Fri May 21 19:42:20 2021 Data Channel: using negotiated cipher 'AES-256-GCM' Fri May 21 19:42:20 2021 Outgoing Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key Fri May 21 19:42:20 2021 Incoming Data Channel: Cipher 'AES-256-GCM' initialized with 256 bit key Fri May 21 19:42:20 2021 ROUTE_GATEWAY 51.195.234.254 Fri May 21 19:42:20 2021 TUN/TAP device tun0 opened Fri May 21 19:42:20 2021 TUN/TAP TX queue length set to 100 Fri May 21 19:42:20 2021 /sbin/ip link set dev tun0 up mtu 1500 Fri May 21 19:42:20 2021 /sbin/ip addr add dev tun0 10.8.0.2/24 broadcast 10.8.0.255 Fri May 21 19:42:20 2021 /sbin/ip route add 151.80.xxx.xxx/32 via 51.195.234.254 Fri May 21 19:42:20 2021 /sbin/ip route add 0.0.0.0/1 via 10.8.0.1 Fri May 21 19:42:20 2021 /sbin/ip route add 128.0.0.0/1 via 10.8.0.1 Fri May 21 19:42:20 2021 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this Fri May 21 19:42:20 2021 Initialization Sequence Completed
Windows ipconfig /全部
Unknown adapter OpenVPN TAP-Windows6: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : TAP-Windows Adapter V9 Physical Address. . . . . . . . . : 00-FF-18-08-1B-04 DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::5185:de54:7498:6c08%4(Preferred) IPv4 Address. . . . . . . . . . . : 10.8.0.2(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Lease Obtained. . . . . . . . . . : Friday, May 21, 2021 8:55:25 PM Lease Expires . . . . . . . . . . : Saturday, May 21, 2022 8:55:25 PM Default Gateway . . . . . . . . . : DHCP Server . . . . . . . . . . . : 10.8.0.254 DHCPv6 IAID . . . . . . . . . . . : 184614680 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-28-38-63-9A-02-00-00-F8-D9-D4 DNS Servers . . . . . . . . . . . : 213.186.33.99 213.186.33.199 NetBIOS over Tcpip. . . . . . . . : Enabled
Debian 10:
0.0.0.0/1 via 10.8.0.1 dev tun0 default via 51.195.234.254 dev eth0 onlink 10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.2 128.0.0.0/1 via 10.8.0.1 dev tun0
連接時的 Windows ping:
C:\使用者\管理員>ping 10.8.0.1
Pinging 10.8.0.1 with 32 bytes of data: Reply from 10.8.0.1: bytes=32 time=4ms TTL=64 Reply from 10.8.0.1: bytes=32 time=4ms TTL=64 Reply from 10.8.0.1: bytes=32 time=4ms TTL=64 Reply from 10.8.0.1: bytes=32 time=4ms TTL=64 Ping statistics for 10.8.0.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 4ms, Maximum = 4ms, Average = 4ms
Linux Ping:
ping 10.8.0.1 PING 10.8.0.1 (10.8.0.1) 56(84) bytes of data. --- 10.8.0.1 ping statistics --- 5 packets transmitted, 0 received, 100% packet loss, time 3999ms
您已指定
client
,這意味著pull
。動詞從伺服器提取路由,pull
伺服器提供覆蓋路由,通過 VPN 發送所有客戶端流量。(有關man openvpn
各種配置選項的詳細資訊,請參閱。)一旦所有流量都配置為通過 VPN,對您的任何回復
ping
也將通過 VPN,然後失去。這正是您的配置狀態,因此日誌中不會出現錯誤。我想要麼您的 Windows 配置略有不同,並且有一個選項可以防止所有流量通過 VPN 路由,或者 LAN 的指標是可以繼續為本地流量提供服務。