在 VPN 连接上,我收到“Linux 路由添加命令失败”,但我没有在 server.conf 上推送任何路由

在 VPN 连接上,我收到“Linux 路由添加命令失败”,但我没有在 server.conf 上推送任何路由

我有一台 Ubuntu 16.04 服务器。我配置了 2 个客户端和服务器。目标是将这两个客户端连接到服务器,并通过 ssh 从一个客户端连接到另一个客户端。我可以在 Linux Mint 上连接,通过右键单击互联网连接图标并指定 .ovpn 文件来添加 vpn 连接。不幸的是,我无法使用以下方法连接到 Raspberry Pi Stretch 上的同一台服务器和第二个类似的客户端配置:

sudo openvpn --config client2.ovpn

我越来越

ERROR: Linux route add command failed: external program exited with error status: 2

完整回复:

Wed Nov 20 11:33:49 2019 OpenVPN 2.4.7 arm-unknown-linux-gnueabihf [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Feb 20 2019
Wed Nov 20 11:33:49 2019 library versions: OpenSSL 1.1.1c  28 May 2019, LZO 2.10
Wed Nov 20 11:33:49 2019 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Wed Nov 20 11:33:50 2019 Outgoing Control Channel Authentication: Using 256 bit message hash 'SHA256' for HMAC authentication
Wed Nov 20 11:33:50 2019 Incoming Control Channel Authentication: Using 256 bit message hash 'SHA256' for HMAC authentication
Wed Nov 20 11:33:50 2019 TCP/UDP: Preserving recently used remote address: [AF_INET]51.75.127.237:1194
Wed Nov 20 11:33:50 2019 Socket Buffers: R=[163840->163840] S=[163840->163840]
Wed Nov 20 11:33:50 2019 UDP link local: (not bound)
Wed Nov 20 11:33:50 2019 UDP link remote: [AF_INET]xx.xx.xx.xx:1194
Wed Nov 20 11:33:50 2019 NOTE: UID/GID downgrade will be delayed because of --client, --pull, or --up-delay
Wed Nov 20 11:33:50 2019 TLS: Initial packet from [AF_INET]xx.xx.xx.xx:1194, sid=bd06e3d1 f7c41b7e
Wed Nov 20 11:33:50 2019 VERIFY OK: depth=1, C=PL, ST=PDK, L=X, O=K, OU=K, CN=K CA, name=server, emailAddress=some_email
Wed Nov 20 11:33:50 2019 VERIFY KU OK
Wed Nov 20 11:33:50 2019 Validating certificate extended key usage
Wed Nov 20 11:33:50 2019 ++ Certificate has EKU (str) TLS Web Server Authentication, expects TLS Web Server Authentication
Wed Nov 20 11:33:50 2019 VERIFY EKU OK
Wed Nov 20 11:33:50 2019 VERIFY OK: depth=1, C=PL, ST=PDK, L=X, O=K, OU=K, CN=K CA, name=server, emailAddress=some_email
Wed Nov 20 11:33:50 2019 Control Channel: TLSv1.2, cipher TLSv1.2 DHE-RSA-AES256-GCM-SHA384, 2048 bit RSA
Wed Nov 20 11:33:50 2019 [server] Peer Connection Initiated with [AF_INET]xx.xx.xx.xx:1194
Wed Nov 20 11:33:51 2019 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1)
Wed Nov 20 11:33:51 2019 PUSH: Received control message: 'PUSH_REPLY,route 10.8.0.0 255.255.255.0,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.10 10.8.0.9'
Wed Nov 20 11:33:51 2019 OPTIONS IMPORT: timers and/or timeouts modified
Wed Nov 20 11:33:51 2019 OPTIONS IMPORT: --ifconfig/up options modified
Wed Nov 20 11:33:51 2019 OPTIONS IMPORT: route options modified
Wed Nov 20 11:33:51 2019 Outgoing Data Channel: Cipher 'AES-128-CBC' initialized with 128 bit key
Wed Nov 20 11:33:51 2019 Outgoing Data Channel: Using 256 bit message hash 'SHA256' for HMAC authentication
Wed Nov 20 11:33:51 2019 Incoming Data Channel: Cipher 'AES-128-CBC' initialized with 128 bit key
Wed Nov 20 11:33:51 2019 Incoming Data Channel: Using 256 bit message hash 'SHA256' for HMAC authentication
Wed Nov 20 11:33:51 2019 ROUTE_GATEWAY 192.168.8.1/255.255.255.0 IFACE=eth1 HWADDR=0c:5b:8f:27:9a:64
Wed Nov 20 11:33:51 2019 TUN/TAP device tun1 opened
Wed Nov 20 11:33:51 2019 TUN/TAP TX queue length set to 100
Wed Nov 20 11:33:51 2019 /sbin/ip link set dev tun1 up mtu 1500
Wed Nov 20 11:33:51 2019 /sbin/ip addr add dev tun1 local 10.8.0.10 peer 10.8.0.9
Wed Nov 20 11:33:51 2019 /etc/openvpn/update-resolv-conf tun1 1500 1570 10.8.0.10 10.8.0.9 init
Wed Nov 20 11:33:51 2019 /sbin/ip route add 10.8.0.0/24 via 10.8.0.9
RTNETLINK answers: File exists
Wed Nov 20 11:33:51 2019 ERROR: Linux route add command failed: external program exited with error status: 2
Wed Nov 20 11:33:51 2019 GID set to nogroup
Wed Nov 20 11:33:51 2019 UID set to nobody
Wed Nov 20 11:33:51 2019 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Wed Nov 20 11:33:51 2019 Initialization Sequence Completed

我的server.conf:

port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key  # This file should be kept secret
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
client-to-client
keepalive 10 120
tls-auth ta.key 0 # This file is secret
key-direction 0
cipher AES-128-CBC   # AES
auth  SHA256
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3

我的客户端.ovpn:

client
dev tun
proto udp
remote xx.xx.xx.xx 1194
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
remote-cert-tls server
cipher AES-128-CBC
auth SHA256
key-direction 1
comp-lzo
verb3
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
<ca>
...
</ca>
<cert>
...
</cert>
<key>
...
</key>
<tls-auth>
...
</tls-auth>

非常感谢您提出的任何想法。

答案1

您正在推送一条路由,即到您的 OpenVPN 网关(和/或子网)的路由:

/sbin/ip route add 10.8.0.0/24 via 10.8.0.9 正在调用,则错误源于您已经有到该主机或子网的路由。请检查客户端上的活动路由(例如ip r)以确认。

你也不应该在加密中使用 LZO 压缩,因为沃拉克尔

答案2

RTNETLINK answers: File exists通常,当 OpenVPN 客户端尝试添加客户端计算机上已存在的路由时,会发生错误。然后,OpenVPN 将生成一条错误消息:

错误:Linux 路由添加命令失败:外部程序因错误状态退出:2

您能否检查该客户端机器的网络设置,以确保您没有任何10.8.0.0/24网络路由?

相关内容