从apnic提取ip信息脚本分享_linux shell

复制代码 代码如下:

#!/bin/bash

# download from apnic
rm -f delegated-apnic-latest
wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest

# IPs allocated to china.
grep 'apnic|CN|ipv4|' delegated-apnic-latest | cut -f 4 -d'|' > delegated-apnic-CN

# get detail of echo IP from apnic database.
rm -f apnic_CN.txt
while read ip
do
    # query apnic database
    echo "query who is $ip"
    whois -h whois.apnic.net $ip > tmp.txt
    grep inetnum  tmp.txt >> apnic_CN.txt          # IP range
    grep netname  tmp.txt >> apnic_CN.txt          # netname which include sp information 
    grep descr    tmp.txt >> apnic_CN.txt          # description which include province information
    echo ""  >> apnic_CN.txt          
done < delegated-apnic-CN

# clean up
rm -f tmp.txt
rm -f delegated-apnic-latest
rm -f delegated-apnic-CN

时间: 2024-08-30 19:12:19

从apnic提取ip信息脚本分享_linux shell的相关文章

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

Linux服务器硬件运行状态及故障邮件提醒的监控脚本分享_linux shell

监控硬件运行状况 shell 监控cpu,memory,load average,记录到log,当负载压力时,发电邮通知管理员. 原理: 1.获取cpu,memory,load average的数值 2.判断数值是否超过自定义的范围,例如(CPU>90%,Memory<10%,load average>2) 3.如数值超过范围,发送电邮通知管理员.发送有时间间隔,每小时只会发送一次. 4.将数值写入log. 5.设置crontab 每30秒运行一次. ServerMonitor.sh #

自动生成linux网卡配置脚本分享_linux shell

补充:这是对于第一次添加的网卡有效,如果需要重复添加和删除后自动配置,需要更改脚本,改为根据ip a命令的信息来修改. 复制代码 代码如下: #!/bin/bash#update:2013-02-25#author:ihuotui#version 0.1 cdate=$(date '+%Y%m%d')num=$(ifconfig -a | grep eth | wc -l)echo "ethX=" $num >> ethX for ((n=1;n<${num};n++

Linux下实现SSH免密码登录和实现秘钥的管理、分发、部署SHELL脚本分享_linux shell

环境: ssh server: 192.168.100.29  server.example.com ssh client: 192.168.100.30  client.example.com 通过root用户建立秘钥认证实现SHELL脚本管理,分发,部署 首先client端创建秘钥对,并将公钥分发给需要登录的SSH服务端 注:公钥相当于锁,私钥相当于钥匙,我们这里相当于在客户端创建一对钥匙和锁,想要做到SSH免密码登录,就相当于我们将锁分发到服务端并装锁,然后客户端就可以利用钥匙开锁. 一.

expect实现批量修改linux密码脚本分享_linux shell

最近对linux批量执行的脚本很感兴趣,在网上到处找有关expect批量执行脚本,今天就给大家共享一个批量修改密码的脚本. 脚本内容: 复制代码 代码如下: #!/usr/bin/expect if { $argc<2 } {     send_user "usage: $argv0 <host file> <cmd file> \n"     exit }   # 机器列表数据格式:  IP  端口  旧密码  新密码 set hostfile    [

Shell实现的iptables管理脚本分享_linux shell

以前的脚本是用save模式,现在把命令附加到一个文件里面,这样的话,可以方便的二次修改什么的 脚本基本是这样的,大家可以跟自己的情况再次修改~  增加功能什么的. 复制代码 代码如下: #!/bin/bash while true do clear echo "----------------------menu----------------------" echo "(1) service iptables restart" echo "(2) ipt

阿里云主机一键安装lamp、lnmp环境的shell脚本分享_linux shell

阿里云主机一键安装lamp,lnmp,自动安装脚本,由阿里云主机分享 一键安装包下载地址:点击下载 1.阿里云分享的一键安装lamp,lnmp,此安装包包含的软件及版本为: 复制代码 代码如下: nginx:1.0.15.1.2.5.1.4.4 apache:2.2.22.2.4.2 mysql:5.1.73.5.5.35.5.6.15 php:5.3.18.5.4.23.5.5.7 php扩展:memcache.Zend Engine/ OPcache ftp:(yum/apt-get安装)

一键配置CentOS iptables防火墙的Shell脚本分享_linux shell

手里几台VPS配置iptables太繁琐,看到了朱哥的LNMP脚本里有一个自动配置iptables防火墙的脚本,借来改了一下,给需要的人用: 只提供常用端口的设置,如果你有特殊需求只需自行添加或减少相应的端口即可: 使用方法: 复制代码 代码如下: chmod +x iptables.sh ./iptables.sh 设置iptables开机自动启动: 复制代码 代码如下: chkconfig --level 345 iptables on 完整Shell: 复制代码 代码如下: #!/bin/

8个实用的Shell脚本分享_linux shell

几个Shell脚本的例子,觉得还不错. [例子:001]判断输入为数字,字符或其他 复制代码 代码如下: #!/bin/bash  read -p "Enter a number or string here:" input    case $input in     [0-9]) echo -e "Good job, Your input is a numberic! \n" ;;  [a-zA-Z]) echo -e "Good job, Your i