如何从Windows查询TXT和SRV记录?

发布于 2024-10-19 06:19:52 字数 941 浏览 6 评论 0原文

我正在尝试使用裸主机名(例如 _service._proto)查询一组 SRV 记录,但是除非我还包含域名,否则会失败。这很奇怪,因为其他工具(例如 nslookup)工作正常,并且使用相同的 API 调用来查询 A 记录对于裸主机名也可以正常工作。

dsRet = DnsQuery("_service._udp",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("collector",DNS_TYPE_A,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL); //==ERROR_SUCCESS

我当然可以查询系统以获取主域名,甚至可能是所有配置的搜索域,但我很确定我不必这样做。我发现很少有关于 Windows DNS API 的参考,所以我想知道是否有更好的方法来查询 TXT 和 SRV 记录。有谁在 Windows 下有过这方面的经验吗?

感谢您的任何建议, 罗伯特

I am attempting to query a set of SRV records using the naked host name (e.g. _service._proto) however this fails unless I also include the domain name. This is strange because other tools such as nslookup work fine and also using the same API call to query A records works fine with naked host names.

dsRet = DnsQuery("_service._udp",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==DNS_ERROR_RCODE_NAME_ERROR
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_SRV,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("_service._udp.example.com",DNS_TYPE_TEXT,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL);//==ERROR_SUCCESS
dsRet = DnsQuery("collector",DNS_TYPE_A,DNS_QUERY_STANDARD,NULL,&pQueryResultsSet,NULL); //==ERROR_SUCCESS

I can of course query the system to get the primary domain name and maybe even all of the configured search domains but I'm pretty sure I shouldn't have to do that. I can find very little reference to the Windows DNS APIs out there so I'm wondering if there is a better way to query TXT and SRV records. Does anyone have any experience with this under Windows?

Thanks for any suggestions,
Robert

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无法回应 2024-10-26 06:19:52

它在 nslookup 下工作的原因是 Windows 使用其配置的域后缀执行所有搜索。要查看实际情况,请启动 nslookup,然后发出“set debug”命令。现在执行搜索,您将看到您的计算机发送和接收的请求和响应。在附加和匹配配置的域后缀之一之前,“裸主机名”将有一个未应答的主机名。

希望这有帮助。

Jonathan

这是一个免费的 DNS 客户端库,您可以使用它来查询 DNS 的不同类型的查询:http://www.simpledns.com/dns-client-lib.aspxhttp://arsofttoolsnet。 codeplex.com

The reason that it works under nslookup is that windows is performing all the searches using the domain suffixes that it is configured with. To see this in action start up nslookup and then issue the "set debug" command. Now perform your search and you will see the requests and responses send and received by your machine. There will be an unanaswered one for the "naked host name" before one of the configured domain suffixes is appended and matched.

Hope that this helps.

Jonathan

Here is a free DNS client library that you can use to query the DNS for different types of query: http://www.simpledns.com/dns-client-lib.aspx also http://arsofttoolsnet.codeplex.com

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文