![OpenVPN - 点击接口和默认网关](https://linux22.com/image/798963/OpenVPN%20-%20%E7%82%B9%E5%87%BB%E6%8E%A5%E5%8F%A3%E5%92%8C%E9%BB%98%E8%AE%A4%E7%BD%91%E5%85%B3.png)
简单问一下,确认我没有发疯。如果使用设备模式“tap”,我就能获得功能齐全的连接,也就是说,我可以毫无问题地从客户端 ping 到服务器。
但是,我想强制我的流量通过 VPN,这样无论如何都不会泄露任何信息。我对此感到困惑,但这在 中不应该有效吗server.ovpn
?
mode server
tls-server
...
dev tap
dev-node TAP1
ifconfig 192.168.0.1 255.255.255.0
ifconfig-pool 192.168.0.10 192.168.0.20
route-gateway 192.168.0.1
route 192.168.0.0 255.255.255.0 192.168.0.1
client-to-client
push "route 192.168.0.0 255.255.255.0 192.168.0.1"
push "route-gateway 192.168.0.1"
push "redirect-gateway def1"
看起来client.ovpn
像:
client
tls-client
dev tap
dev-node TAP1
...
pull
连接建立之后,客户端日志的输出如下:
ROUTE default_gateway=<external IP gateway>
PUSH: Recieved control message: 'PUSH_REPLY,route 192.168.0.0 255.255.255.0 192.168.0.1,route-gateway...
Notified TAP-Win32 driver to set a DHCP IP/netmask of 192.168.0.10/255.255.255.0 on interface ...
Successful ARP Flush
Added routes 139.. 127.. 192...
一切似乎都很好,只是检查时没有设置默认网关ipconfig /all
输出如下route print
所示:
Destination Netmask Gateway
0.0.0.0 0.0.0.0 <external Gateway> <-- Wrong?
192.168.0.0 255.255.255.0 On-link
192.168.0.0 255.255.255.0 192.168.0.1
路由表好像关闭了?
答案1
All appears to be fine except that a default gateway just isn't
set when checking
...
push "redirect-gateway def1"
如果使用该选项,则无需设置默认网关。相反,应为VPN添加0.0.0.0/1
和两个路由。128.0.0.0/1
答案2
我意识到这是一个老问题,但我想补充一点,根据我的经验,如果除了设置默认网关之外一切正常,以管理员身份运行 OpenVPN 将解决 Windows 10 上的问题。