• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >linux shell > Shell脚本获取国内各大运营商网段脚本分享

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

作者:junjie 字体:[增加 减小] 来源:互联网

junjie 通过本文主要向大家介绍了shell脚本,shell脚本编程,shell脚本学习指南,shell脚本实例,linux shell脚本等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

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

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
</div>

</div>

您可能想查找下面的文章:

  • Shell脚本监控目录内文件改动
  • 实现自动清除日期目录shell脚本实例代码
  • 使用Linux shell脚本实现FTP定时执行批量下载指定文件
  • shell脚本连接并重启远程服务器的方法
  • shell 脚本安装PHP扩展的简单方法
  • Linux shell脚本输出日志笔记整理(必看篇)
  • shell脚本实现分日志级别输出的方法
  • shell将脚本输出结果记录到日志文件的实现
  • 输出执行操作和打印日志的shell脚本实例
  • shell脚本 自动创建用户详解及实例代码

相关文章

  • Linux常用命令全集(超全面)
  • Shell中实现字符串反转方法分享
  • CentOS 6.3下给PHP添加mssql扩展模块教程
  • linux命令切换目录的使用方法
  • linux中mysql备份shell脚本代码
  • shell脚本实现的网站日志分析统计(可以统计9种数据)
  • linux shell脚本基础知识学习
  • Shell交互批量更改主机名的方法
  • 一波实用的Bash Shell整理
  • expect实现批量修改linux密码脚本分享

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • linux命令之find命令简单概述
    • 一天一个shell命令 linux好管家--磁盘--df命令详解
    • Centos下查看网卡的实时流量命令
    • 设置Linux系统的空闲等待时间TMOUT的方法
    • ssh,scp自动登陆的实现方法
    • shell脚本中执行python脚本并接收其返回值的例子
    • 查找目录下同名但不同后缀名文件的shell脚本代码
    • Shell脚本实现乱序排列文件内容的多种方法(洗牌问题)
    • Linux Shell脚本系列教程(七):脚本调试
    • Shell脚本编写Nagios插件监控程序资源占用

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有