您现在的位置是:网站首页> 编程资料编程资料
Shell脚本获取国内各大运营商网段脚本分享_linux shell_
2023-05-26
360人已围观
简介 Shell脚本获取国内各大运营商网段脚本分享_linux 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 <
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工具实现远程批量关机_linux shell_
- Shell脚本实现根据端口号kill相应进程功能_linux shell_
- Shell脚本编写Nagios插件监控程序资源占用_linux shell_
- 实时查看系统流量的Shell脚本分享_linux shell_
- Shell脚本自动备份MySQL到FTP并定期清理过期备份_linux shell_
- shell脚本监控系统负载、CPU和内存使用情况_linux shell_
- Nginx和PHP-FPM的启动、重启、停止脚本分享_linux shell_
- Shell脚本统计当前目录下目录和文件的数量_linux shell_
- Shell定时删除指定时间之前的文件_linux shell_
- Shell监控iptables运行状态_linux shell_
