MX记录查找和检查 [英] MX Record lookup and check

查看:110
本文介绍了MX记录查找和检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个工具来检查域实时mx记录是否符合预期(我们的一些员工摆弄了他们的问题,导致所有传入的邮件都重定向到空白中)

I need to create a tool that will check a domains live mx records against what should be expected (we have had issues with some of our staff fiddling with them and causing all incoming mail to redirected into the void)

现在我不会说谎,我一点也不称职!我大约有40页进入深入Python",并且可以阅读和理解最基本的代码.但是我愿意学习,而不仅仅是得到答案.

Now I won't lie, I'm not a competent programmer in the slightest! I'm about 40 pages into "dive into python" and can read and understand the most basic code. But I'm willing to learn rather than just being given an answer.

那么任何人都可以建议我应该使用哪种语言?

So would anyone be able to suggest which language I should be using?

我当时正在考虑使用python并从使用0s.system()开始(dig + nocmd domain.com mx + noall + answer)来提取记录的方式开始,然后我得到了一点对于如何将其与现有记录集进行比较感到困惑.

I was thinking of using python and starting with something along the lines of using 0s.system() to do a (dig +nocmd domain.com mx +noall +answer) to pull up the records, I then get a bit confused about how to compare this to a existing set of records.

对不起,这听起来像是胡说八道!

Sorry if that all sounds like nonsense!

谢谢 克里斯

推荐答案

使用 dnspython 模块(非内置在其中,您必须pip install它):

With dnspython module (not built-in, you must pip install it):

>>> import dns.resolver
>>> domain = 'hotmail.com'
>>> for x in dns.resolver.query(domain, 'MX'):
...     print(x.to_text())
...
5 mx3.hotmail.com.
5 mx4.hotmail.com.
5 mx1.hotmail.com.
5 mx2.hotmail.com.

[更新]

对于python 3,它是pip install dnspython3.

For python 3 it is pip install dnspython3.

这篇关于MX记录查找和检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆