简体   繁体   English

获取所有DNS记录

[英]Get all DNS records

I'm looking for a way to get all DNS records by web address. 我正在寻找一种通过网址获取所有DNS记录的方法。
Is there a way to do this with C#, without any library? 没有任何库,有没有办法用C#做到这一点?

It is not really easy without any library. 没有任何库,这并不是一件容易的事。

You can use native code though, DnsQueryEx is a good starting point... You'll need tons of code to get it working in C# though. 但是,您可以使用本机代码, DnsQueryEx是一个很好的起点……您将需要大量代码才能使其在C#中工作。

Why not just use an existing library? 为什么不只使用现有的库?

I just wrote one for donet core /xplat support for example: https://github.com/MichaCo/DnsClient.NET 我只是为donet核心/ xplat支持编写了一个示例: https : //github.com/MichaCo/DnsClient.NET

which is really straight forward to use 这真的很容易使用

var lookup = new LookupClient();
var result = await lookup.QueryAsync("google.com", QueryType.ANY);

var record = result.Answers.ARecords().FirstOrDefault();
var address = record?.Address;

See also http://dnsclient.michaco.net for more details/docs 另请参阅http://dnsclient.michaco.net了解更多详细信息/文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM