问题原文
原帖链接 · Sam · CC BY-SA 4.0
I have found some old threads regarding this, but they seems to be some years old. E.g. openVPN - Split-tunneling DNS priority
I'm on Windows.
I'm connected to a local network with local DNS.
I use OpenVPN to connect to another network, this network have resources available at *.example.com.
Is it even possible to have one DNS for *.example.com and another for everything else? I know I can setup a local DNS on my machine to solve it, or enter all the hostnames of example.com in my local hosts-file.
已采纳解答
原帖链接 · Wyatt McGehee · CC BY-SA 4.0
I'm on Windows 10 w/ OpenVPN and I've been fighting this problem for some time, and only had partial successes with the interface metric method others have suggested. I've been using "OpenVPN GUI v11.13.0.0" for some time.
The article @till linked just blew my mind. The section titled "Split-DNS when using DNS Resolution Zones" had the magic:
Please note that not all OpenVPN clients out there support this and there are some differences in behavior between versions of OpenVPN as well. The best results can be achieved by using OpenVPN Connect v3 client software.
When you use split-DNS, you will not see the DNS server that is being pushed in your ipconfig or ifconfig output. The DNS server will not get implemented at the network interface configuration level. Instead, it will be implemented in the DNS system in a DNS resolution policy table.
The article mentions things like the V3 client and some useful commands:
netsh namespace show effectivepolicy
ipconfig /all
But it turns out on Windows 7+, if you have access to Administrator PowerShell, that shows the policies from:
Get-DnsClientNrpt(Global|Policy|Rule)
Add-DnsClientNrptRule -Namespace ".domainfromvpn.com" -NameServers "192.168.0.100"
Remove-DnsClientNrptRule -Namespace ".domainfromvpn.com"
where ".domainfromvpn.com" is the special domain you want looked up via the OpenVPN DNS, and 192.168.0.100 is the (pushed route) IP of that internal DNS server.
I now have working Split-DNS using OpenVPN Connect v3 on a Windows 10 machine with single domain resolution happening over the VPN's connection via the remote/internal DNS.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
