为特定域使用特定的 dns 服务器

dst*_*str 9 networking windows dns windows-10

我在工作时使用 unblock-us.com dns 服务器来访问 pandora.com。我们公司正在使用大量 *.mycompany.internal 域来存放公司内容。当然 unblock-us 无法解决它们,我真的厌倦了将它们中的每一个都添加到主机文件中。有没有办法将公司 dns 服务器用于 mycompany.internal 域和其他 dns 服务器?这是我的个人电脑,无法更改公司 dns 设置的任何内容。

解决方案:

感谢 Jens Ehrich,我最终使用了用于 MaraDNS 的递归 dns 服务器 Deadwood。这是我的 Deadwood 配置文件 (dwood3rc.txt):

# Please note that each upstream_servers entry takes up space in Deadwood's
# cache and that maximum_cache_elements will need to be increased to store
# a large number of these entries.
upstream_servers = {}
upstream_servers["."] = "8.8.8.8, 8.8.4.4" # Google DNS as example

# To have Deadwood perform DNS queries for a small LAN and have the DNS server
#  on 192.168.1.111 resolve queries ending in "internal":
root_servers = {}
root_servers["internal."]="<my.company.dns.ip1>, <my.company.dns.ip2>"

# The IP this program has 
bind_address="127.0.0.1"

# The IPs allowed to connect and use the cache
recursive_acl = "127.0.0.1/16"

# The file containing a hard-to-guess secret
random_seed_file = "secret.txt" # created with mkSecretTxt.exe from MaraDNS

# By default, for security reasons, Deadwood does not allow IPs in the
# 192.168.x.x, 172.[16-31].x.x, 10.x.x.x, 127.x.x.x, 169.254.x.x,
# 224.x.x.x, or 0.0.x.x range.  If using Deadwood to resolve names
# on an internal network, uncomment the following line:
filter_rfc1918 = 0
Run Code Online (Sandbox Code Playgroud)

然后只是install.bat在 Deadwood 文件夹中使用。

aoe*_*lks 11

你试过这个 PowerShell 命令吗?似乎轻松了许多。

Add-DnsClientNrptRule -Namespace "pqr.com" -NameServers "10.0.0.1"

参考:https : //docs.microsoft.com/en-us/powershell/module/dnsclient/add-dnsclientnrptrule?view=win10-ps

  • @WoJ 如果您希望所有子域都转到自定义名称服务器,则需要在域前面添加一个点。另外 nslookup 不支持 NRPT,因此您无法使用它进行测试(请尝试使用 ping 代替)。示例:Add-DnsClientNrptRule -Namespace ".example.com" -DnsSecEnable -NameServers "10.0.0.1" (3认同)

Hel*_*Sam 9

回应 @aoetalks 的回答,如果我.在命名空间中放入 a,它就像一个魅力。

Add-DnsClientNrptRule -Namespace ".example.local" -NameServers "10.0.0.1"
Run Code Online (Sandbox Code Playgroud)


Jen*_*ich 5

您可以使用DNS 区域委派来完成此操作

首先,设置另一个使用 unblock-us.com DNS 作为转发器的 DNS 服务器(在您自己的机器上即可)。您可以使用 Simple DNS、MaraDNS 或运行 Linux 或 Windows Server 的本地虚拟机之类的东西。

其次,为您公司的网络添加一个指向您公司的 DNS 服务器的委托区域。

第三,配置您的网卡以使用您的新 DNS 服务器作为主要名称服务器。