MX记录查找和检查
我需要创建一个工具来检查域的实时 mx 记录是否符合预期(我们的一些员工在摆弄这些记录时遇到了问题,导致所有传入的邮件都被重定向到空白)
现在我不会撒谎,我根本不是一个称职的程序员!我已经阅读了大约 40 页的“深入 Python”,可以阅读和理解最基本的代码。但我愿意学习,而不仅仅是得到答案。
那么有人能建议我应该使用哪种语言吗?
我正在考虑使用 python 并从使用 0s.system() 的方式开始执行 (dig +nocmd domain.com mx +noall +answer) 来提取记录,然后我对如何进行有点困惑将其与现有的记录集进行比较。
抱歉,如果这一切听起来像是废话!
谢谢 克里斯
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)
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?
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!
Thanks
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 dnspython 模块(不是内置的,您必须
pip install
它):With dnspython module (not built-in, you must
pip install
it):看一下dnspython,这个模块应该可以很好地为您进行查找,而无需诉诸系统调用。
Take a look at dnspython, a module that should do the lookups for you just fine without needing to resort to system calls.
上述解决方案是正确的。有些东西我想添加和更新。
dnspython
已更新为可与 python3 一起使用,并且它已取代dnspython3
库,因此建议在dnspython
/strong> 将严格接受域,仅此而已。例如:dnspython.org是有效域名,而不是www.dnspython.org
如果您想获取某个域的邮件服务器,这里有一个函数。
the above solutions are correct. some things I would like to add and update.
dnspython
has been updated to be used with python3 and it has superseeded thednspython3
library so use ofdnspython
is recommendedfor example: dnspython.org is valid domain, not www.dnspython.org
here's a function if you want to get the mail servers for a domain.