在 Linux 上打开 VPN:错误:Linux 路由添加命令失败:外部程序以错误状态退出:2。我该如何解决这个问题?

在 Linux 上打开 VPN:错误:Linux 路由添加命令失败:外部程序以错误状态退出:2。我该如何解决这个问题?

好的,所以我正在运行一个开放的 vpn 客户端,尝试连接到我的学校使用的服务器,并且我必须修复配置文件中的错误才能让 vpn 在我的 ubuntu 机器上运行。

错误日志:

2021-02-08 01:24:58 TCP/UDP: Preserving recently used remote address: [AF_INET][server-ip]
2021-02-08 01:24:58 UDP link local: (not bound)
2021-02-08 01:24:58 UDP link remote: [AF_INET][server ip]
2021-02-08 01:24:58 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
2021-02-08 01:25:04 [server] Peer Connection Initiated with [AF_INET][server ip]
2021-02-08 01:25:10 TUN/TAP device tun0 opened
2021-02-08 01:25:10 /sbin/ip link set dev tun0 up mtu 1500
2021-02-08 01:25:10 /sbin/ip link set dev tun0 up
2021-02-08 01:25:10 /sbin/ip addr add dev tun0 10.255.255.36/24
Error: Invalid prefix for given prefix length.
2021-02-08 01:25:10 ERROR: Linux route add command failed: external program exited with error status: 2
Error: Invalid prefix for given prefix length.
2021-02-08 01:25:10 ERROR: Linux route add command failed: external program exited with error status: 2
Error: Invalid prefix for given prefix length.
2021-02-08 01:25:10 ERROR: Linux route add command failed: external program exited with error status: 2
Error: Invalid prefix for given prefix length.
2021-02-08 01:25:10 ERROR: Linux route add command failed: external program exited with error status: 2
2021-02-08 01:25:10 Initialization Sequence Completed

配置文件:

client
dev tun
proto udp
remote [server ip]
resolv-retry infinite
remote-cert-tls server
nobind
persist-key
persist-tun
cipher AES-256-CFB
data-ciphers AES-256-CFB
auth SHA256
auth-user-pass
route 192.168.10.0 255.255.255.0
route 192.168.20.0 255.255.255.0
route 192.168.30.0 255.255.255.0

我尝试过推送“路由...”,但得到的响应相同,删除路由命令也会出现同样的错误消息。更改路由(包括添加 /24)只会给我带来更多错误。

另外,vpn 当前是否正在运行?谢谢。

编辑:使用动词 3 运行会在日志末尾给出以下内容:

2021-02-09 17:51:06 /sbin/ip addr add dev tun0 10.255.255.36/24
2021-02-09 17:51:06 /sbin/ip route add 192.168.10.0/24 via 10.255.255.1
2021-02-09 17:51:06 /sbin/ip route add 192.168.20.0/24 via 10.255.255.1
2021-02-09 17:51:06 /sbin/ip route add 192.168.30.0/24 via 10.255.255.1
2021-02-09 17:51:06 /sbin/ip route add 192.168.1.1/24 via 10.255.255.1
Error: Invalid prefix for given prefix length.
2021-02-09 17:51:06 ERROR: Linux route add command failed: external program exited with error status: 2
2021-02-09 17:51:06 /sbin/ip route add 192.168.10.1/24 via 10.255.255.1
Error: Invalid prefix for given prefix length.
2021-02-09 17:51:06 ERROR: Linux route add command failed: external program exited with error status: 2
2021-02-09 17:51:06 /sbin/ip route add 192.168.20.1/24 via 10.255.255.1
Error: Invalid prefix for given prefix length.
2021-02-09 17:51:06 ERROR: Linux route add command failed: external program exited with error status: 2
2021-02-09 17:51:06 /sbin/ip route add 192.168.30.1/24 via 10.255.255.1
Error: Invalid prefix for given prefix length.
2021-02-09 17:51:06 ERROR: Linux route add command failed: external program exited with error status: 2
2021-02-09 17:51:06 /sbin/ip route add 192.168.11.0/24 via 10.255.255.1
2021-02-09 17:51:06 Initialization Sequence Completed
^C2021-02-09 17:53:08 event_wait : Interrupted system call (code=4)
2021-02-09 17:53:08 /sbin/ip route del 192.168.10.0/24
2021-02-09 17:53:08 /sbin/ip route del 192.168.20.0/24
2021-02-09 17:53:08 /sbin/ip route del 192.168.30.0/24
2021-02-09 17:53:08 /sbin/ip route del 192.168.1.1/24
Error: Invalid prefix for given prefix length.
2021-02-09 17:53:08 ERROR: Linux route delete command failed: external program exited with error status: 2
2021-02-09 17:53:08 /sbin/ip route del 192.168.10.1/24
Error: Invalid prefix for given prefix length.
2021-02-09 17:53:08 ERROR: Linux route delete command failed: external program exited with error status: 2
2021-02-09 17:53:08 /sbin/ip route del 192.168.20.1/24
Error: Invalid prefix for given prefix length.
2021-02-09 17:53:08 ERROR: Linux route delete command failed: external program exited with error status: 2
2021-02-09 17:53:08 /sbin/ip route del 192.168.30.1/24
Error: Invalid prefix for given prefix length.
2021-02-09 17:53:08 ERROR: Linux route delete command failed: external program exited with error status: 2
2021-02-09 17:53:08 /sbin/ip route del 192.168.11.0/24
2021-02-09 17:53:08 Closing TUN/TAP interface
2021-02-09 17:53:08 /sbin/ip addr del dev tun0 10.255.255.36/24
2021-02-09 17:53:08 SIGINT[hard,] received, process exiting

因此,显然它试图在末尾添加这些配置文件中没有的奇怪路由。为什么它尝试使用 1 进行连接?

运行动词 5 并没有给我带来更多,除了:

WRR2021-02-09 18:01:46 us=534750 PUSH: Received control message: 'PUSH_REPLY,route 192.168.1.1 255.255.255.0,route 192.168.10.1 255.255.255.0,route 192.168.20.1 255.255.255.0,route 192.168.30.1 255.255.255.0,dhcp-option DOMAIN [school_url],route 192.168.11.0 255.255.255.0 10.255.255.1,route-gateway 10.255.255.1,topology subnet,ping 10,ping-restart 60,ifconfig 10.255.255.36 255.255.255.0,peer-id 1'

配置文件

enp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 5c:f9:dd:44:07:cc  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 6780  bytes 718813 (718.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6780  bytes 718813 (718.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.141  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 2602:304:cd49:ce89:7339:c912:850e:503c  prefixlen 64  scopeid 0x0<global>
        inet6 2602:304:cd49:ce89:30ac:f9d6:9b72:9fa8  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::6dbb:3d0f:ff63:d0da  prefixlen 64  scopeid 0x20<link>
        ether 68:5d:43:97:7b:8d  txqueuelen 1000  (Ethernet)
        RX packets 348014  bytes 368671357 (368.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 232910  bytes 38136412 (38.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

相关内容