Linux 上没有问题,但是在 Win 10 上 OpenVPN,配置中写入了route-nopull
,发现没有用,因为发现所有流量都走了 VPN。
这是我的路由表
IPv4 路由表
===========================================================================
活动路由:
网络目标 网络掩码 网关 接口 跃点数
0.0.0.0 0.0.0.0 192.168.3.1 192.168.3.160 35
10.0.0.0 255.0.0.0 10.8.0.1 10.8.0.5 259
10.8.0.0 255.255.255.0 在链路上 10.8.0.5 259
10.8.0.5 255.255.255.255 在链路上 10.8.0.5 259
10.8.0.255 255.255.255.255 在链路上 10.8.0.5 259
127.0.0.0 255.0.0.0 在链路上 127.0.0.1 331
127.0.0.1 255.255.255.255 在链路上 127.0.0.1 331
127.255.255.255 255.255.255.255 在链路上 127.0.0.1 331
192.168.3.0 255.255.255.0 在链路上 192.168.3.160 291
192.168.3.160 255.255.255.255 在链路上 192.168.3.160 291
192.168.3.255 255.255.255.255 在链路上 192.168.3.160 291
224.0.0.0 240.0.0.0 在链路上 127.0.0.1 331
224.0.0.0 240.0.0.0 在链路上 10.8.0.5 259
224.0.0.0 240.0.0.0 在链路上 192.168.3.160 291
255.255.255.255 255.255.255.255 在链路上 127.0.0.1 331
255.255.255.255 255.255.255.255 在链路上 10.8.0.5 259
255.255.255.255 255.255.255.255 在链路上 192.168.3.160 291
===========================================================================
有人遇到了相同的问题吗?
看到status 里的log
Thu Dec 27 10:15:14 2018 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 8.8.8.8,dhcp-option DNS 8.8.4.4,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig 10.8.0.5 255.255.255.0'
Thu Dec 27 10:15:14 2018 Pushed option removed by filter: 'redirect-gateway def1 bypass-dhcp'
Thu Dec 27 10:15:14 2018 Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS])
Thu Dec 27 10:15:14 2018 Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS])
Thu Dec 27 10:15:14 2018 OPTIONS IMPORT: timers and/or timeouts modified
Thu Dec 27 10:15:14 2018 OPTIONS IMPORT: --ifconfig/up options modified
Thu Dec 27 10:15:14 2018 OPTIONS IMPORT: route-related options modified
问题所在就在与DNS查询上 开了VPN,DNS都查不了了
nslookup www.baidu.com
DNS request timed out.
timeout was 2 seconds.
服务器: UnKnown
Address: 8.8.8.8
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** 请求 UnKnown 超时
1
hjc4869 2018-12-27 09:56:08 +08:00
完整配置发一下?是不是带了 redirect-gateway 之类的
|
2
salamanderMH OP @hjc4869 这是我的 ovpn 配置
client dev tun proto udp sndbuf 0 rcvbuf 0 remote **.**.**.** **** resolv-retry infinite nobind persist-key persist-tun remote-cert-tls server auth SHA512 cipher AES-256-CBC setenv opt block-outside-dns key-direction 1 verb 3 <ca> -----BEGIN CERTIFICATE----- **** </ca> <cert> -----BEGIN CERTIFICATE----- ** </cert> <key> -----BEGIN PRIVATE KEY----- *** </key> <tls-auth> -----BEGIN OpenVPN Static key V1----- ****** -----END OpenVPN Static key V1----- </tls-auth> route-nopull route 10.0.0.0 255.0.0.0 vpn_gateway |
3
BOYPT 2018-12-27 10:03:00 +08:00
https://community.openvpn.net/openvpn/wiki/IgnoreRedirectGateway
客户端忽略 redirect gateway 的 3 种方法 |
4
salamanderMH OP @hjc4869 我的服务端配置确实带了 push "redirect-gateway def1 bypass-dhcp"
|
5
salamanderMH OP @BOYPT 我客户端已经添加了 --route-nopull
|
6
BOYPT 2018-12-27 13:09:34 +08:00
@salamanderMH #5 那三种都试试啊
|
7
salamanderMH OP @BOYPT 我都试了,日志里写着
``` Thu Dec 27 10:15:14 2018 SENT CONTROL [server]: 'PUSH_REQUEST' (status=1) Thu Dec 27 10:15:14 2018 PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 8.8.8.8,dhcp-option DNS 8.8.4.4,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig 10.8.0.5 255.255.255.0' Thu Dec 27 10:15:14 2018 Pushed option removed by filter: 'redirect-gateway def1 bypass-dhcp' Thu Dec 27 10:15:14 2018 Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS]) Thu Dec 27 10:15:14 2018 Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS]) Thu Dec 27 10:15:14 2018 OPTIONS IMPORT: timers and/or timeouts modified Thu Dec 27 10:15:14 2018 OPTIONS IMPORT: --ifconfig/up options modified Thu Dec 27 10:15:14 2018 OPTIONS IMPORT: route-related options modified Thu Dec 27 10:15:14 2018 Outgoing Data Channel: Cipher 'AES-256-CBC' initialized with 256 bit key Thu Dec 27 10:15:14 2018 Outgoing Data Channel: Using 512 bit message hash 'SHA512' for HMAC authentication Thu Dec 27 10:15:14 2018 Incoming Data Channel: Cipher 'AES-256-CBC' initialized with 256 bit key Thu Dec 27 10:15:14 2018 Incoming Data Channel: Using 512 bit message hash 'SHA512' for HMAC authentication Thu Dec 27 10:15:14 2018 interactive service msg_channel=820 Thu Dec 27 10:15:14 2018 ROUTE_GATEWAY 192.168.3.1/255.255.255.0 I=13 HWADDR=00:e0:4b:68:02:31 ``` |
8
salamanderMH OP @BOYPT 可是还是不行,流量还是都走了 VPN
|
9
dnsjia 2018-12-27 13:56:22 +08:00
检查你客户端配置文件中是否配置了 redirect-gateway def1, 如果有该参数所有流量都会走 vpn
|
10
salamanderMH OP @dnsjia 客户端没有这个配置,服务端有`push "redirect-gateway def1 bypass-dhcp"`
|
11
BOYPT 2018-12-27 14:02:19 +08:00
@salamanderMH #8
Thu Dec 27 10:15:14 2018 Pushed option removed by filter: 'redirect-gateway def1 bypass-dhcp' 这里说明选项生效了呀,对比下链接前后的路由表是什么影响的; 你贴的路由表,只有 0.0.0.0 0.0.0.0 192.168.3.1 192.168.3.160 35 10.0.0.0 255.0.0.0 10.8.0.1 10.8.0.5 259 说明默认网关走 192.168.3.1,只有 10.x.x.x 走 VPN,看起来是正确的了呀,检查看看你的 有 def redirect 的话,除了替换默认网关,会还有一句是 服务器 ip->192.168.3.1 这样的,你的路由表都没有,说明 def1 已经不起效了,你再确认一下 |
12
salamanderMH OP @BOYPT 大佬,你好,我也发现了,路由表是设置对了,我发现了错误所在,就是 DNS 查询默认用了 VPN 网关,这个问题是不是跟那个错误日志有关:
``` Thu Dec 27 10:15:14 2018 Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS]) Thu Dec 27 10:15:14 2018 Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS]) ``` |
13
salamanderMH OP @BOYPT 如何修改这个行为呢??好奇怪
|
14
zhouyut001 2018-12-27 15:39:33 +08:00
@salamanderMH 這個 PUSH 不就是推送參數到客戶端嗎?你客戶端沒有設定直接接受服務器推送,當然走全局
|
15
zhouyut001 2018-12-27 15:40:03 +08:00
把服務器的 PUSH 刪了
|
16
salamanderMH OP @zhouyut001 我客户端配置了 route-nopull,不接受推送,看日志也生效了
|
17
BOYPT 2018-12-27 16:05:22 +08:00
@salamanderMH #13 这个好像跟 windows 有关的, 因为 win 下每个网卡都可以配置 DNS,而选择哪个 DNS 则按照网卡顺序,也就是 route print 命令里面开始的“接口列表”,里面数字小的就有高优先级。估计你那里,vpn 的 tap 网卡次序比正常网卡小。
这个次序可以修改,参考这里 https://www.ghacks.net/2016/12/02/change-network-adapter-priorities-in-windows-10/ |
18
salamanderMH OP @BOYPT
我已经调整 TAP 的优先级了,然而还是不行 ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore ------- -------------- ------------- ------------ --------------- ---- --------------- ----------- 22 以太网 2 IPv6 1500 35 Disabled Disconnected ActiveStore 12 TAP IPv6 1500 3 Enabled Connected ActiveStore 13 以太网 IPv6 1500 35 Enabled Connected ActiveStore 1 Loopback Pseudo-Interface 1 IPv6 4294967295 75 Disabled Connected ActiveStore 22 以太网 2 IPv4 1500 35 Enabled Disconnected ActiveStore 12 TAP IPv4 1500 200 Enabled Connected ActiveStore 13 以太网 IPv4 1500 3 Enabled Connected ActiveStore 1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore |
19
zk8802 2018-12-27 16:38:15 +08:00 via iPhone 1
楼主设置了 block-outside-dns ?这样 OpenVPN 会添加 Windows 防火墙记录,拦掉除 tap 以外的所有网络接口上的 DNS 请求。把这行从你配置文件中删掉试试。
|
20
salamanderMH OP @zk8802 感谢!! 删掉这个就解决了
|