zoukankan      html  css  js  c++  java
  • dns dig 查看支持ipv6网站

    1.处理zone文件
    A.先格式化区文件数据,去掉不需要的数据,生成新的文件 com.zone.sample
    cat com.zone |grep -P IN' 'NS|awk -F ' ' '{print $1","$4}' >> com.zone.sample
    格式如下:

    waiyuren.com.,ns6.ctrlcache.com.
    jmtcq.com.,ns5.myhostadmin.net.
    

    B.获取到所有的ns数据,并且去重,并生成新的文件/home/cnzone/com_sort.zone
    cat com.zone |grep -P IN' 'NS|awk -F ' ' '{print $4}'|sort|uniq >> com_sort.zone
    格式如下:

    zyd1.dnspod.net.
    zyd.dnspod.net.
    zz.baidu.com.
    

    C.如果com_sort.zone文件比较大,最好按行分成多分文件,同时运行脚本
    详见:[linux 查看某几行内容与文件分割] (https://www.cnblogs.com/wt11/p/9351021.html)

    2.批量dig ns,获取支持ipv6的ns

    [root@localhost home]# cat dns.py 
    import sh
    import json
    
    ns = {}
    def validation_ipv6(domain):
        ns = {}
        num = 0
        try:
            dig = sh.dig(domain, "AAAA", "+short")
            num = sh.wc(dig, "-l")
            print(domain +'-----------------------'+ str(int(num)))
        except:
            with open('unreachd_domain.txt', 'a+', encoding='utf8') as f2:
                f2.write(domain + '
    ')
        if int(num) > 0:
            ns[domain] = int(num)
            #print(ns)
            datas = json.dumps(ns, ensure_ascii=False, indent=4)
            with open('ipv6_ns.txt', 'a+', encoding='utf8', buffering=1) as ff:
                ff.write(datas+',')
    def save():
        with open('cn.ns.sort', 'r', encoding='utf8') as f:
            for i in f:
                i = i.strip()
                validation_ipv6(i)
    
    if __name__ == '__main__':
        save()
    
    

    3.根据对应的ns,获取支持ipv6的网站

    [root@localhost home]# cat get_v6.py 
    import json
    
    alls = {}
    
    def ana():
        with open('ipv6_ns.txt', 'r', encoding='utf8') as f:
            data = json.load(f)
            for item in data:
                for key in item:
                    alls[key] = item[key]
    
    
    def gets():
        n = 0
        with open('com.zone.sample', 'r', encoding='utf8') as ff:
            for line in ff:
                line = line.strip()
                key = line.split(',')[1]
                num = alls.get(key, 0)
                print(str(n) + '-------------->'+ line +'------------>' + key + '>>>>>>>' + str(num))
                n = n + 1
                if num > 0:
                    with open('support_ipv6_site.txt', 'a+', encoding='utf8') as fc:
                        fc.write(line.split(',')[0] + '
    ')
    
    if __name__ == '__main__':
        ana()
        gets()
    
  • 相关阅读:
    将aspx页面编译成dll
    Jquery 验证数字
    c#反编译生成DLL过程
    c#进制转换
    Spring Mvc 实例
    wamp phpMyAdmin error #1045
    Tomcat相关知识点总结(jsp)
    Java ---学习笔记(泛型)
    Java IO ---学习笔记(文件操作与随机访问文件)
    Java IO ---学习笔记(字符流)
  • 原文地址:https://www.cnblogs.com/wt11/p/9352053.html
Copyright © 2011-2022 走看看