joken-前端工程师

  :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: :: 管理 ::
wget -c http://ftp.apnic.net/stats/apnic/delegated-apnic-latest

cat delegated-apnic-latest | awk -F '|' '/CN/&&/ipv4/ {print $4 "/" 32-log($5)/log(2)}'|cat >ip.txt

 

导入ipset

ipset create chinaip hash:net maxelem 1000000

 for ip in $(cat './ip.txt'); do
      ipset add chinaip $ip
 done

ipset save chinaip -f china-ipset.txt //保存为文件,这样可以restore 恢复

这里需要用hash:net才能存储ip段,如果时hash:ip则只能存储固定ip,不能存储大量的ip。用net才能存储ip段,才能有效实现录入大量的ip。

posted on 2018-07-12 21:23  joken1310  阅读(1408)  评论(0编辑  收藏  举报