正在加载...
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]
因为都是在线生成和查询,所以要耗费时间,我已经生成电信,网通等的ip段.红色字体为程序或者命令.

一.PHP脚本,本人兴趣所写,如有不足,请更正修改,使用方法,保存为ip.php,因为在shell/命令行下使用的,运行方法为:php ip.php :
        $iplist=file_get_contents("http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest");
        $ipsplit=split("[\n]+",$iplist);
        foreach($ipsplit as $val){
                if(preg_match("/apnic\|CN\|ipv4\|/",$val)){
                list($nic,$CN,$ver,$ip,$mask)=preg_split("/\|/",$val);
                $iparray['set'][]=array("ip"=>$ip,"mask"=>$mask);
                }
        }
        
        foreach($iparray['set'] as $val){
                echo $val['ip']."\t".(32-log($val['mask'],2))."\n";
                $flag=GetWhois($val['ip']);
                switch($flag){
                        case "CHINANET":
                                $fpc=fopen("CHINANET","a+");
                                fwrite($fpc,$val['ip']."/".(32-log($val['mask'],2))."\n");
                                break;
                        case "CNC":
                                $fpc=fopen("CNC","a+");
                                fwrite($fpc,$val['ip']."/".(32-log($val['mask'],2))."\n");
                                break;
                                break;
                        case "CRTC":
                                $fpc=fopen("CRTC","a+");
                                fwrite($fpc,$val['ip']."/".(32-log($val['mask'],2))."\n");
                                break;

                        default:        
                                $fpc=fopen("OTHERS","a+");
                                fwrite($fpc,$val['ip']."/".(32-log($val['mask'],2))."\n");
                                break;
                }
                        
        }        


        function GetWhois($IP){
                $rootwhois = 'whois.apnic.net';
                $buffer1 = ReadSocket($rootwhois,$IP);
                $flag="";
                $buffer_result=nl2br($buffer1);
                if(preg_match("/CHINANET/",$buffer_result)){
                        $flag="CHINANET";
                        return $flag;
                }
                if(preg_match("/CNC/",$buffer_result)){
                         $flag="CNC";
                         return $flag;
                }
                if(preg_match("/CRTC/",$buffer_result)){
                         $flag="CRTC";
                         return $flag;
                 }
                 if(!preg_match("/CHINANET|CRTC|CNC/",$buffer_result)){
                         $flag="OTHERS";
                         return $flag;
                 }
        }
function ReadSocket($whois,$ip)
{
  $buffer = '';
  if (!$sock = fsockopen( $whois, 43, $errNum, $errStr, 20))
{
        echo "Sorry,Can't fsockopen it";
  }
  else
  {
    fputs($sock,"$ip\n");
    //$buffer = fread($sock, 8192);
    while(!feof($sock))        $buffer.=fgets($sock, 8192);
    fclose($sock);
  }
  return $buffer;
}
?>
方法二.在Linux/Unix/BSD下,保存以下内容,比如保存为ip_apinc.sh,改其权限为可以执行,然后运行。

#!/bin/sh
FILE=/home/ip_apnic
rm -f $FILE
rm -f CNC
rm -f OTHER
rm -f CHINANET
rm -f CRTC
wget http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O $FILE
grep 'apnic|CN|ipv4|' $FILE | cut -f 4,5 -d'|'|sed -e 's/|/ /g' | while read ip cnt
do
    mask=$(cat << EOF | bc | tail -1
pow=32;
define log2(x) {
if (x<=1) return (pow);
pow--;
return(log2(x/2));
}
log2($cnt)
EOF)
        echo $ip/$mask
        echo $ip/$mask>> cn.net
        NETNAME=`whois $ip | grep ^netname | sed -e 's/.*:      \(.*\)/\1/g' | sed -e 's/-.*//g'`
echo $NETNAME;
        case $NETNAME in
        CNC)
                echo $ip/$mask >> CNC
        ;;
        CNCGROUP)
                echo $ip/$mask >> CNC
        ;;
        CHINANET)
                echo $ip/$mask >> CHINANET
        ;;
        CHINATELECOM)
                echo $ip/$mask >> CHINANET
        ;;
        CRTC)
                echo $ip/$mask >> CRTC
        ;;
        *)
                echo $ip/$mask >> OTHER
        ;;
        esac
done

方法三,这个也是在Linux/Unix/BSD下的:

APNIC是管理亚太地区IP地址分配的机构,它有着丰富准确的IP地址分配库,同时这些信息也是对外公开的!下面就让我们看看如何在Linux下获得一些电信运营商的IP地址分配情况:

-bash-2.05b$ http://ftp.apnic.net/apnic/dbase/tools/ripe-dbase-client-v3.tar.gz
-bash-2.05b$ tar xzvf ripe-dbase-client-v3.tar.gz
-bash-2.05b$ cd whois-3.1
-bash-2.05b$ ./configure
-bash-2.05b$ make;make install完成上述编译安装工作后,我们开始获取IP地址段;

中国网通:-bash-2.05b$ whois3 -h whois.apnic.net -l -i mb MAINT-CNCGROUP > /var/cnc

中国电信:-bash-2.05b$ whois3 -h whois.apnic.net -l -i mb MAINT-CHINANET > /var/chinanet

中国铁通:-bash-2.05b$ whois3 -h whois.apnic.net -l -i mb MAINT-CN-CRTC > /var/crtc
打开获取后的文件可以看到里面的信息非常详细,甚至可以看到各个分公司的负责人、电话、电子邮件等等信息。如果想得到一份整齐干净的IP地址段文件,只要用grep和awk简单过滤就可以了:)

方法四,在win下的,利用电信路由生成器.exe/网通路由生成器.exe,这两个工具来生成.

#!/bin/sh

apnic_ip_info="apnic_ip_info"
apnic_all_ip="apnic_all_ip"
save_dir="./"

if [ -e "$apnic_ip_info" ];then
rm -f $apnic_ip_info
fi

if [ -e "$apnic_all_ip" ];then
rm -f $apnic_all_ip
fi

if [ -e $save_dir/CNC_GROUP ];then
rm -f $save_dir/CNC_GROUP
fi

if [ -e $save_dir/CHINATELECOM_GROUP ];then
rm -f $save_dir/CHINATELECOM_GROUP
fi

if [ -e $save_dir/CERNET_GROUP ];then
rm -f $save_dir/CERNET_GROUP
fi

if [ -e $save_dir/CRTC_GROUP ];then                  
rm -f $save_dir/CRTC_GROUP
fi

if [ -e $save_dir/CHINAMOBILE_GROUP ];then
rm -f $save_dir/CHINAMOBILE_GROUP
fi

if [ -e $save_dir/CHINAUNICOM_GROUP ];then          
rm -f $save_dir/CHINAUNICOM_GROUP
fi

if [ -e $save_dir/OTHERNET_GROUP ];then          
rm -f $save_dir/OTHERNET_GROUP
fi

wget -q http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest -O $apnic_ip_info

grep "apnic|CN|ipv4|" "$apnic_ip_info" | awk -F'|' '{print $4}' > "$apnic_all_ip"
while read line
do

isp_info=`whois $line | grep -E "(mnt-|netname)" | awk '{print $2}' | xargs`

into_cnc=`echo $isp_info | sed -n '/CNC/p'`
into_chinatelecom=`echo $isp_info | sed -n '/CHINANET/p'`
into_cernet=`echo $isp_info | sed -n '/CERNET/p'`
into_crtc=`echo $isp_info | sed -n '/CRTC/p'`
into_cmcc=`echo $isp_info | sed -n '/CMCC/p'`
into_unicom=`echo $isp_info | sed -n '/UNICOM/p'`

if [ "${into_cnc}" != "" ];then
   echo "$line CNC_GROUP" >> ${save_dir}/CNC_GROUP
elif [ "${into_chinatelecom}" != "" ];then
     echo "$line CHINATELECOM_GROUP" >> ${save_dir}/CHINATELECOM_GROUP
elif [ "${into_cernet}" != "" ];then
     echo "$line CERNET_GROUP" >> ${save_dir}/CERNET_GROUP
elif [ "${into_crtc}" != "" ];then
     echo "$line CRTC_GROUP" >> ${save_dir}/CRTC_GROUP
elif [ "${into_cmcc}" != "" ];then
     echo "$line CHINAMOBLIE_GROUP" >> ${save_dir}/CHINAMOBILE_GROUP
elif [ "${into_unicom}" != "" ];then
     echo "$line CHINAUNICOM_GROUP" >> ${save_dir}/CHINAUNICOM_GROUP
else
     echo "$line OTHERNET_GROUP" >> ${save_dir}/OTHERNET_GROUP
fi

done<$apnic_all_ip
Tags: , , ,
网通电信地址列表  
      
中国电信    中国网通  
58.32.0.0/13  202.97.32.0/19  58.16.0.0/16  202.99.208.0/20
58.40.0.0/15  202.97.64.0/19  58.17.0.0/17  202.99.224.0/21
58.42.0.0/16  202.97.96.0/20  58.17.128.0/17  202.99.232.0/21
58.43.0.0/16  202.97.112.0/20  58.18.0.0/16  202.99.240.0/20
58.44.0.0/14  202.98.32.0/21  58.19.0.0/16  202.102.128.0/21
58.48.0.0/13  202.98.48.0/20  58.20.0.0/16  202.102.224.0/21
58.59.128.0/17  202.98.64.0/19  58.21.0.0/16  202.102.232.0/21
58.60.0.0/14  202.98.96.0/21  58.22.0.0/15  202.106.0.0/16
58.208.0.0/12  202.98.128.0/19  58.240.0.0/15  202.107.0.0/17
59.32.0.0/13  202.98.160.0/21  58.242.0.0/15  202.108.0.0/16
59.40.0.0/15  202.98.168.0/21  58.244.0.0/15  202.110.0.0/17
59.42.0.0/16  202.98.192.0/21  58.246.0.0/15  202.111.128.0/18
59.44.0.0/14  202.98.200.0/21  58.248.0.0/13  203.93.8.0/24
59.48.0.0/16  202.98.208.0/20  60.0.0.0/13  203.93.192.0/18
59.49.0.0/17  202.98.224.0/21  60.8.0.0/15  210.13.128.0/17
59.49.128.0/17  202.98.232.0/21  60.10.0.0/16  210.14.160.0/19
59.50.0.0/16  202.98.240.0/20  60.11.0.0/16  210.14.192.0/19
59.51.0.0/17  202.99.192.0/21  60.12.0.0/16  210.15.32.0/19
59.51.128.0/17  202.100.96.0/21  60.13.0.0/18  210.15.96.0/19
59.52.0.0/14  202.100.104.0/21  60.13.128.0/17  210.15.128.0/18
59.56.0.0/14  202.100.112.0/20  60.14.0.0/15  210.21.0.0/16
59.60.0.0/15  202.100.136.0/21  60.16.0.0/13  210.52.128.0/17
59.62.0.0/15  202.100.160.0/21  60.24.0.0/14  210.53.0.0/17
60.160.0.0/15  202.100.168.0/21  60.30.0.0/16  210.53.128.0/17
60.162.0.0/15  202.100.176.0/20  60.31.0.0/16  210.74.96.0/19
60.164.0.0/15  202.100.192.0/21  60.208.0.0/13  210.74.128.0/19
60.166.0.0/15  202.100.208.0/20  60.216.0.0/15  210.82.0.0/15
60.168.0.0/13  202.100.224.0/19  60.218.0.0/15  218.8.0.0/14
60.176.0.0/12  202.101.0.0/18  60.220.0.0/14  218.12.0.0/16
61.133.128.0/17  202.101.64.0/19  61.48.0.0/13  218.21.128.0/17
61.134.0.0/18  202.101.96.0/19  61.133.0.0/17  218.24.0.0/14
61.134.64.0/19  202.101.128.0/18  61.134.96.0/19  218.56.0.0/14
61.136.128.0/17  202.101.224.0/21  61.134.128.0/17  218.60.0.0/15
61.137.0.0/17  202.102.0.0/19  61.135.0.0/16  218.67.128.0/17
61.138.192.0/18  202.102.32.0/19  61.137.128.0/17  218.68.0.0/15
61.139.0.0/17  202.102.64.0/18  61.138.0.0/17  218.104.0.0/14
61.139.192.0/18  202.103.0.0/21  61.138.128.0/18  219.154.0.0/15
61.140.0.0/14  202.103.8.0/21  61.139.128.0/18  219.156.0.0/15
61.144.0.0/14  202.103.16.0/20  61.148.0.0/15  219.158.0.0/17
61.152.0.0/14  202.103.32.0/19  61.156.0.0/16  219.158.128.0/17
61.157.0.0/16  202.103.96.0/21  61.159.0.0/18  219.159.0.0/18
61.159.64.0/18  202.103.192.0/19  61.161.0.0/18  220.252.0.0/16
61.159.128.0/17  202.103.224.0/21  61.161.128.0/17  221.0.0.0/15
61.160.0.0/16  202.104.0.0/15  61.162.0.0/16  221.2.0.0/16
61.161.64.0/18  202.107.128.0/17  61.163.0.0/16  221.3.0.0/17
61.164.0.0/15  202.109.0.0/16  61.167.0.0/16  221.3.128.0/17
61.166.0.0/16  202.110.128.0/18  61.168.0.0/16  221.4.0.0/16
61.169.0.0/16  202.111.0.0/17  61.176.0.0/16  221.5.0.0/17
61.170.0.0/15  218.4.0.0/15  61.179.0.0/16  221.5.128.0/17
61.172.0.0/14  218.6.0.0/16  61.181.0.0/16  221.6.0.0/16
61.177.0.0/16  218.13.0.0/16  61.182.0.0/16  221.7.0.0/19
61.178.0.0/16  218.14.0.0/15  61.189.0.0/17  221.7.32.0/19
61.180.0.0/17  218.16.0.0/14  125.32.0.0/16  221.7.64.0/19
61.183.0.0/16  218.20.0.0/16  125.35.128.0/17  221.7.96.0/19
61.184.0.0/14  218.21.0.0/17  125.36.0.0/14  221.10.0.0/16
61.188.0.0/16  218.22.0.0/15  125.40.0.0/13  221.11.0.0/17
61.189.128.0/17  218.62.128.0/17  202.96.0.0/18  221.11.128.0/18
61.190.0.0/15  218.63.0.0/16  202.96.64.0/21  221.11.192.0/19
125.64.0.0/13  218.64.0.0/15  202.96.72.0/21  221.12.0.0/17
125.72.0.0/16  218.66.0.0/16  202.97.128.0/18  221.12.128.0/18
125.73.0.0/16  218.67.0.0/17  202.97.224.0/21  221.13.0.0/18
125.74.0.0/15  218.70.0.0/15  202.97.240.0/20  221.13.64.0/19
125.76.0.0/17  218.72.0.0/13  202.98.0.0/21  221.13.96.0/19
125.80.0.0/13  218.80.0.0/12  202.98.8.0/21  221.13.128.0/17
125.88.0.0/13  219.128.0.0/12  202.99.64.0/19  221.14.0.0/15
125.104.0.0/13  219.144.0.0/13  202.99.96.0/21  221.192.0.0/15
125.112.0.0/12  219.152.0.0/15  202.99.128.0/19  221.194.0.0/16
202.96.96.0/21  219.159.64.0/18  202.99.160.0/21  221.195.0.0/16
202.96.104.0/21  219.159.128.0/17  202.99.168.0/21  221.196.0.0/15
202.96.112.0/20  220.160.0.0/11  202.99.176.0/20  221.198.0.0/16
202.96.128.0/21  221.224.0.0/13  221.208.0.0/14  221.199.0.0/19
202.96.136.0/21  221.232.0.0/14  221.212.0.0/16  221.199.32.0/20
202.96.144.0/20  221.236.0.0/15  221.213.0.0/16  221.199.128.0/18
202.96.160.0/21  221.239.128.0/17  221.216.0.0/13  221.199.192.0/20
202.96.168.0/21  222.72.0.0/15  222.128.0.0/14  221.200.0.0/14
202.96.176.0/20  222.75.0.0/16  222.132.0.0/14  221.204.0.0/15
202.96.200.0/21  222.76.0.0/14  222.136.0.0/13  221.206.0.0/16
202.96.208.0/20  222.80.0.0/15  222.160.0.0/15  221.207.0.0/18
202.96.224.0/21  222.82.0.0/16  222.162.0.0/16  221.207.64.0/18
202.97.0.0/21  222.83.0.0/17  222.163.0.0/19  221.207.128.0/17
202.97.8.0/21  222.83.128.0/17  222.163.32.0/19  222.163.64.0/18
202.97.16.0/20  222.84.0.0/16  222.163.128.0/17
222.219.0.0/16  222.85.128.0/17    
222.220.0.0/15  222.86.0.0/15    
222.240.0.0/13  222.90.0.0/15    
58.56.0.0/15  222.92.0.0/14    
58.58.0.0/16  222.172.128.0/17    
58.59.0.0/17  222.176.0.0/13    
221.238.0.0/16  222.184.0.0/13    
221.239.0.0/17  222.208.0.0/13    
222.74.0.0/16  222.216.0.0/15    
222.85.0.0/17  222.218.0.0/16    
222.88.0.0/15  222.172.0.0/17    
222.168.0.0/15  222.173.0.0/16    
222.174.0.0/15    
222.222.0.0/15    

双出口、多出口策略地址列表
Tags: ,
分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]