大网数据广告活动
服务器运维问答

Split DNS on OpenVPN

· 52CE 我爱测

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 n…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-02-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。