使用 OpenVPN 设置默认路由

使用 OpenVPN 设置默认路由

我的 OpenVPN 客户端(版本 2.5.5)不知为何无法设置默认路由。

路由完全由客户端 ovpn 文件

route-gateway 10.24.0.1
route 152.66.182.241 255.255.255.255 net_gateway
route 192.168.24.0   255.255.255.0
route 192.168.0.0    255.255.0.0     net_gateway
route 10.24.0.0      255.255.0.0
route 10.0.0.0       255.0.0.0       net_gateway
route 0.0.0.0        0.0.0.0

但是,我看到openvpn 输出

$ sudo openvpn my-file.ovpn
...
2022-09-05 15:28:01 us=617368 net_route_v4_best_gw query: dst 0.0.0.0
2022-09-05 15:28:01 us=617478 net_route_v4_best_gw result: via 192.168.0.1 dev eno1
2022-09-05 15:28:01 us=617521 ROUTE_GATEWAY 192.168.0.1/255.255.255.0 IFACE=eno1 HWADDR=34:48:ed:66:e8:29
2022-09-05 15:28:01 us=617909 TUN/TAP device tun0 opened
2022-09-05 15:28:01 us=617948 do_ifconfig, ipv4=1, ipv6=0
2022-09-05 15:28:01 us=617998 net_iface_mtu_set: mtu 1500 for tun0
2022-09-05 15:28:01 us=618052 net_iface_up: set tun0 up
2022-09-05 15:28:01 us=618959 net_addr_v4_add: 10.24.0.4/16 dev tun0
2022-09-05 15:28:01 us=619619 net_route_v4_add: [redacted server address]/32 via 192.168.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=619825 net_route_v4_add: 192.168.24.0/24 via 10.24.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=620030 net_route_v4_add: 192.168.0.0/16 via 192.168.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=620273 net_route_v4_add: 10.24.0.0/16 via 10.24.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=621728 net_route_v4_add: 10.0.0.0/8 via 192.168.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=622187 net_route_v4_add: 0.0.0.0/0 via 10.24.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=622239 sitnl_send: rtnl: generic error (-101): Network is unreachable
2022-09-05 15:28:01 us=622260 ERROR: Linux route add command failed
2022-09-05 15:28:01 us=622275 net_route_v4_add: 192.168.24.0/24 via 10.24.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=622308 sitnl_send: rtnl: generic error (-101): Network is unreachable
2022-09-05 15:28:01 us=622325 ERROR: Linux route add command failed
2022-09-05 15:28:01 us=622337 net_route_v4_add: 152.66.182.241/32 via 192.168.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=622372 net_route_v4_add: 152.66.0.0/16 via 10.24.0.1 dev [NULL] table 0 metric -1
2022-09-05 15:28:01 us=622403 sitnl_send: rtnl: generic error (-101): Network is unreachable
2022-09-05 15:28:01 us=622418 ERROR: Linux route add command failed
...
2022-09-05 15:28:01 us=622457 Initialization Sequence Completed

因此,我的流量不会通过我的 VPN。但是,当我强制使用 tun0 接口(例如使用 ping -I tun0)时,VPN 工作正常。我可能会错过什么?

相关内容