• 企业400电话
  • 微网小程序
  • AI电话机器人
  • 电商代运营
  • 全 部 栏 目

    企业400电话 网络优化推广 AI电话机器人 呼叫中心 网站建设 商标✡知产 微网小程序 电商运营 彩铃•短信 增值拓展业务
    Shell脚本获取国内各大运营商网段脚本分享

    亚太地区网络信息记录在这里,每天都有更新。

    http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest

    下面这个脚本将对这段文本进行编辑,输出国内几大运营商网段。

    复制代码 代码如下:

    #!/bin/sh
    #auto get the IP Table
    #get the newest delegated-apnic-latest
    rm delegated-apnic-latest

    if type wget
    then wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
    else fetch http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest
    fi
    grep 'apnic|CN|ipv4' delegated-apnic-latest | cut -f 4,5 -d '|' | tr '|' ' ' | while read ip cnt
    do
    mask=$(bc END | tail -1
    pow=32;
    define log2(x) {
    if (x=1) return (pow);
    pow--;
    return(log2(x/2));
    }
    log2($cnt);
    END
    )
    echo $ip/$mask';'>>cnnet

    resultext=`whois $ip@whois.apnic.net | grep -e ^netname -e ^descr -e ^role -e ^mnt-by | cut -f 2 -d ':' | sed 's/ *//'`

    if echo $resultext | grep -i -e 'railcom' -e 'crtc' -e 'railway'
    then echo $ip/$mask';' >> crc
    elif echo $resultext | grep -i -e 'cncgroup' -e 'netcom'
    then echo $ip/$mask';' >> cnc
    elif echo $resultext | grep -i -e 'chinanet' -e 'chinatel'
    then echo $ip/$mask';' >> telcom_acl
    elif echo $resultext | grep -i -e 'unicom'
    then echo $ip/$mask';' >> unicom
    elif echo $resultext | grep -i -e 'cmnet'
    then echo $ip/$mask';' >> cmnet
    else
    echo $ip/$mask';' >> other_acl
    fi

    done

    上一篇:Shell中使用plink工具实现远程批量关机
    下一篇:Shell脚本查看网卡实时流量
  • 相关文章
  • 

    © 2016-2020 巨人网络通讯 版权所有

    《增值电信业务经营许可证》 苏ICP备15040257号-8

    Shell脚本获取国内各大运营商网段脚本分享 Shell,脚本,获取,国内,各大,