如何获得MX记录与System.Net.DNS DNS名称?

编程入门 行业动态 更新时间:2024-10-25 04:23:02
本文介绍了如何获得MX记录与System.Net.DNS DNS名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有建在.NET库,将返回所有的MX记录给定域的方法?我看你怎么弄CNAMES,但不是MX记录。

Is there any built in method in the .NET library that will return all of the MX records for a given domain? I see how you get CNAMES, but not MX records.

推荐答案

在 ARSoft.Tools.Net 库赖纳特看来,做这项工作pretty的好。

The ARSoft.Tools.Net library by Alexander Reinert seems to do the job pretty well.

这是从的NuGet:

PM> Install-Package ARSoft.Tools.Net

导入命名空间:

Import the namespace:

using ARSoft.Tools.Net.Dns;

然后做一个同步查找是简单的:

Then making a synchronous lookup is as simple as:

var response = DnsClient.Default.Resolve("gmail", RecordType.Mx); var records = response.AnswerRecords.OfType<MxRecord>(); foreach (var record in records) { Console.WriteLine(record.ExchangeDomainName); }

这给我们的输出:

Which gives us the output:

alt3.gmail-smtp-in.l.google alt4.gmail-smtp-in.l.google gmail-smtp-in.l.google alt1.gmail-smtp-in.l.google alt2.gmail-smtp-in.l.google

在底层,它看起来像库构建UDP(或TCP)数据包要发送到解析器,就像你所期望的。图书馆甚至有逻辑(与 DnsClient.Default 调用)来发现要查询的DNS服务器。

Underneath the hood, it looks like the library constructs the UDP (or TCP) packets necessary to send to the resolver, like you might expect. The library even has logic (invoked with DnsClient.Default) to discover which DNS server to query.

完整文档可以在这里找到 。

Full documentation can be found here.

更多推荐

如何获得MX记录与System.Net.DNS DNS名称?

本文发布于:2023-11-12 04:40:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580526.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   名称   MX   System   Net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!