VPN:错误:Linux路由添加命令失败


12

我已经配置了VPN服务器

local 192.168.0.250
dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server-vpn.crt
key /etc/openvpn/easy-rsa/keys/server-vpn.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig 10.8.0.1 10.8.0.2
push "route 10.8.0.1 255.255.255.255"
push "route 10.8.0.0 255.255.255.0"
push "route 192.168.0.250 255.255.255.0"
push "dhcp-option DNS 8.8.8.8"
push "redirect-gateway def1"
client-to-client
duplicate-cn
keepalive 10 120
tls-auth /etc/openvpn/easy-rsa/keys/ta.key 0
cipher AES-128-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status /var/log/openvpn-status.log 20
log /var/log/openvpn.log
verb 1

当使用以下命令从Linux终端连接openvpn客户端时:

openvpn --config /home/user/myfile.ovpn

我有这个错误:

OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Dec  1 2014
Control Channel Authentication: tls-auth using INLINE static key file
UDPv4 link local: [undef]
UDPv4 link remote: [AF_INET]xx.xx.xx.xx:1194
[server-vpn] Peer Connection Initiated with [AF_INET]xx.xx.xx.xx:1194
TUN/TAP device tun0 opened
do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
/sbin/ip link set dev tun0 up mtu 1500
/sbin/ip addr add dev tun0 local 10.8.0.14 peer 10.8.0.13
RTNETLINK answers: Invalid argument
ERROR: Linux route add command failed: external program exited with error status: 2
RTNETLINK answers: File exists
ERROR: Linux route add command failed: external program exited with error status: 2
Initialization Sequence Completed

Answers:


4

以下路线是错误的。您不能添加前两个(并且不需要手动添加),因为它们是您已配置的隧道的vpn ip范围。(这两个也是冗余的,因为10.8.0.1是10.8.0.0网络的一部分。)第三个是您的本地网络,将被自动添加。因此,将其全部删除并查看。

push "route 10.8.0.1 255.255.255.255"
push "route 10.8.0.0 255.255.255.0"
push "route 192.168.0.250 255.255.255.0"

参见:https : //openvpn.net/index.php/open-source/documentation/howto.html

推送路由用于将路由添加到其他专用子网

# Push routes to the client to allow it
# to reach other private subnets behind
# the server.  Remember that these
# private subnets will also need
# to know to route the OpenVPN client
# address pool (10.8.0.0/255.255.255.0)
# back to the OpenVPN server.
;push "route 192.168.10.0 255.255.255.0"
;push "route 192.168.20.0 255.255.255.0"

我删除了两行,并有相同的错误,但一次而不是两次
hellb0y77

@ hellb0y77,哦,您也有push "route 192.168.0.250 255.255.255.0",也将其删除并查看。
钻石
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.