美文网首页python自动化运维
dnspython实现MX记录查询

dnspython实现MX记录查询

作者: 如来自然 | 来源:发表于2016-01-14 19:53 被阅读449次

    [root@bogon dns]# vim MX.py

    !/usr/bin/env python

    import dns.resolver

    domain = raw_input('Please input an domain: ')
    MX = dns.resolver.query(domain, 'MX')
    for i in MX:
    print 'MX preference =', i.preference, 'mail exchanger =', i.exchange

    测试:

    [root@bogon dns]# python MX.py
    Please input an domain: baidu.com
    MX preference = 20 mail exchanger = mx50.baidu.com.
    MX preference = 20 mail exchanger = jpmx.baidu.com.
    MX preference = 10 mail exchanger = mx.n.shifen.com.
    MX preference = 20 mail exchanger = mx1.baidu.com.
    [root@bogon dns]#

    相关文章

      网友评论

        本文标题:dnspython实现MX记录查询

        本文链接:https://www.haomeiwen.com/subject/sdhhkttx.html