如何获得MX记录与System.Net.DNS DNS名称?(How to get mx records for a dns name with System.Net.DNS)

   IT问题网   2019-08-13 00:00:00

问 题

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

亚历山大
解决方案

在 arsoft.tools.net 库赖纳特看来,做这项工作pretty的好。

这是从的nuget:

pm安装,包装arsoft.tools.net
 

导入命名空间:

 使用arsoft.tools.net.dns;
 

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

var响应= dnsclient.default.resolve("gmail.com",recordtype.mx);
变种记录= response.answerrecords.oftype&其中; mxrecord();
的foreach(在记录var记录){
console.writeline(record.exchangedomainname);
}
 

这给我们的输出:

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

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

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

标签:如何获得取得获取记录名称



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

我为什么要preFER单曲“等待Task.WhenAll”在多个等待着?(Why should I prefer single 'await Task.WhenAll' over multiple awaits)

problem in case i don't care about the order ...

我该如何分析和转换日期时间的到RFC 822的日期,时间格式?(How do I parse and convert DateTime’s to the RFC 822 date-time format)

problem how do i convert a datetime structure to its equi ...

有什么区别呢.AsNoTracking()做什么呢?(What difference does .AsNoTracking() make)

problem i have a question regarding the .asnotracking() e ...

实体框架/ LINQ到SQL:跳过和放大器;采取(Entity Framework/Linq to SQL: Skip & Take)

problem just curious as to how skip amp; take are suppose ...

StreamWriter.Flush()和StreamWriter.Close()之间的区别是什么?(What is the difference between StreamWriter.Flush() and StreamWriter.Close())

problem what is the difference in functionality between s ...

现净switch语句散列或索引?(Are .Net switch statements hashed or indexed)

problem does .net 4 (or any prior version) perform any so ...

使用LINQ生成没有选择直接更新(Use linq to generate direct update without select)

problem g'day everyone. i'm still learning l ...

是否有可能拦截控制台输出?(Is it possible to intercept Console output)

problem i call a method, say, fizzbuzz(), over which i ha ...

当使用排序列表 TKEY的,TValue在一个SortedDictionary TKEY的,TValue?(When to use a SortedList<TKey, TValue> over a SortedDictionary<TKey, TValue>)

problem this may appear to be a duplicate of this questio ...

如何初始化列表 T给定的尺寸(相对于容量)?(How to initialize a List<T> to a given size (as opposed to capacity))

problem .net offers a generic list container whose perfor ...

如何使用XPath用的XDocument?(how to use XPath with XDocument)

problem there is a similar question, but it seems that th ...

什么是WebConfigurationManager和ConfigurationManager中的区别?(What's the difference between the WebConfigurationManager and the ConfigurationManager)

problem what's the difference between the webconfiguratio ...

NUnit的测试运行秩序(NUnit Test Run Order)

problem by default nunit tests run alphabetic ...

如何恢复从C#数据库(How to restore a database from C#)

problem i have a sql 2008 db. i am running a form that ba ...

调用堆栈不说"你来自哪里"但是"你要去哪里,下一个"?(The call stack does not say "where you came from", but "where you are going next")

problem in a previous question (get object ca ...

如何读取和写入ID3标签在C#中的MP3?(How to read and write ID3 tags to an MP3 in C#)

problem is there a library for reading and writing id3 ta ...

如何设置读取权限的X.509证书从.NET私钥文件(How to set read permission on the private key file of X.509 certificate from .NET)

problem here is the code to add a pfx to the cert store. ...

获取列表视图的项目双击事件(Get the item doubleclick event of listview)

problem how to get the item double click event of listvie ...

MongoDB的交易?(MongoDB transactions)

problem playing around with mongodb and norm in .net. th ...

确定是否.NET程序集是从相同的源代码构建(Determine whether .NET assemblies were built from the same source)

problem does anyone know of a way to compare two .net ass ...