我无法让我的 openVPN 客户端机器(Windows 10)通过 VPN 隧道传递 DNS 查询。
我正在10.0.0.1
作为 DNS 服务器推送,并且 VPN 连接显示它是该连接的 DNS 服务器。
Ethernet adapter Ethernet 3:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Apple Mobile Device Ethernet
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 172.20.10.2(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.240
Lease Obtained. . . . . . . . . . : 03 September 2015 09:55:59
Lease Expires . . . . . . . . . . : 04 September 2015 12:05:04
Default Gateway . . . . . . . . . : 172.20.10.1
DHCP Server . . . . . . . . . . . : 172.20.10.1
DNS Servers . . . . . . . . . . . : 172.20.10.1
NetBIOS over Tcpip. . . . . . . . : Enabled
Ethernet adapter Ethernet 2:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TAP-Win32 Adapter V9
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.8.0.4(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : 03 September 2015 11:25:47
Lease Expires . . . . . . . . . . : 02 September 2016 12:19:32
Default Gateway . . . . . . . . . :
DHCP Server . . . . . . . . . . . : 10.8.0.254
DNS Servers . . . . . . . . . . . : 10.0.0.1
NetBIOS over Tcpip. . . . . . . . : Enabled
连接创建此路由表
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 172.20.10.1 172.20.10.2 20
0.0.0.0 128.0.0.0 10.8.0.1 10.8.0.4 31
10.0.0.0 255.255.255.0 10.8.0.1 10.8.0.4 31
10.8.0.0 255.255.255.0 On-link 10.8.0.4 286
10.8.0.4 255.255.255.255 On-link 10.8.0.4 286
10.8.0.255 255.255.255.255 On-link 10.8.0.4 286
**.***.***.*** 255.255.255.255 172.20.10.1 172.20.10.2 21 <-- Public VPN Address
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
128.0.0.0 128.0.0.0 10.8.0.1 10.8.0.4 31
172.20.10.0 255.255.255.240 On-link 172.20.10.2 276
172.20.10.2 255.255.255.255 On-link 172.20.10.2 276
172.20.10.15 255.255.255.255 On-link 172.20.10.2 276
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 10.8.0.4 286
224.0.0.0 240.0.0.0 On-link 172.20.10.2 276
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 10.8.0.4 286
255.255.255.255 255.255.255.255 On-link 172.20.10.2 276
===========================================================================
服务器配置文件
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
tls-server
tls-auth ta.key 0
dev tun
local 10.0.0.250
port 1194
proto udp
topology subnet
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1"
push "dhcp-option DNS 10.0.0.1"
keepalive 10 120
cipher BF-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
ifconfig-pool-persist ipp.txt
status openvpn-status.log
log openvpn.log
verb 6
nslookup 结果如下:
C:\Windows\system32>nslookup alpha.intranet.app
Server: UnKnown
Address: 172.20.10.1
Non-authoritative answer:
Name: alpha.intranet.app
Address: 127.0.53.53
但是,强制 nslookup 使用所需的 DNS 服务器会导致:
C:\Windows\system32>nslookup alpha.intranet.app 10.0.0.1
Server: lan.router
Address: 10.0.0.1
Non-authoritative answer:
Name: alpha.intranet.app
Address: 10.0.0.251
如果我手动将 DNS 服务器更改为Ethernet adapter Ethernet 3
nslookup 10.0.0.1
,则无需强制使用 DNS 服务器,我的内联网页面就可以正常加载。
有没有想过为什么物理连接的 DNS 服务器比 VPN 更受青睐,以及如何改变这种情况?
谢谢
答案1
我在 dnsleaktest.com 上找到了一组脚本,这些脚本会在创建隧道之前删除所有现有的 DNS 解析器链接,并添加 VPN 连接的链接。连接关闭后,它也会反转此操作。