我的情况是,我的服务器的 IP 范围为 192.168.255.0/24,子网的范围为 10.0.0.0/24
我在添加配置之前先在这里说明问题。我正在将路由推送到服务器网络,
push "route 192.168.255.0 255.255.255.0 192.168.255.1"
我用两台不同的客户端机器进行了测试
测试1
第一个抛出错误,告诉
RTNETLINK answers: Network is unreachable
ip 路由表没有获取任何相关条目
root@127:/etc/openvpn/client# ip route
default via 192.168.88.1 dev eth0 proto dhcp metric 100
10.0.0.0/24 dev tun0 proto kernel scope link src 10.0.0.1
192.168.88.0/24 dev eth0 proto kernel scope link src 192.168.88.154 metric 100
213.136.74.54 via 192.168.88.1 dev eth0
当我尝试手动添加时也会发生同样的情况
ip route add 192.168.255.0/24 via 192.168.255.1 dev tun0
测试2 第二个是mac,它不会抛出任何错误,但将路由放入错误的接口中,我猜它应该是utun3而不是en0
Internet:
Destination Gateway Flags Netif Expire
default 192.168.88.1 UGScg en0
10/24 10.0.0.2 UGSc utun3
10.0.0.2 10.0.0.2 UH utun3
192.168.255 192.168.255.1 UGSc en0
这是我的配置
server 192.168.255.0 255.255.255.0
verb 3
key /etc/openvpn/pki/private/VPN.greenhive.at.key
ca /etc/openvpn/pki/ca.crt
cert /etc/openvpn/pki/issued/VPN.greenhive.at.crt
dh /etc/openvpn/pki/dh.pem
tls-auth /etc/openvpn/pki/ta.key
key-direction 0
keepalive 10 60
persist-key
persist-tun
proto udp
port 1194
dev tun
status /tmp/openvpn-status.log
topology subnet
client-config-dir ccd
#user nobody
#group nogroup
comp-lzo no
client-to-client
### Route Configurations Below
route 192.168.255.0 255.255.255.0
route 10.0.0.0 255.255.255.0
route 10.0.1.0 255.255.255.0
### Push Configurations Below
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "comp-lzo no"
push "route 192.168.255.0 255.255.255.0 192.168.255.1"