Closed zmz125000 closed 6 months ago
下面2个方法都试试
$ curl -4fsSkL https://ftp.apnic.net/stats/apnic/delegated-apnic-latest | fgrep ipv4 | fgrep '|8.'
apnic|SG|ipv4|8.128.0.0|4194304|19921201|allocated
apnic|SG|ipv4|8.208.0.0|1048576|19921201|allocated
apnic这边搜到了两个8.开头的ip段,但属地是SG(新加坡)。
也许可以考虑换个ip库?有哪些推荐的?
@zfl9 @cattyhouse
$dig lantianwenshi.com
;; ANSWER SECTION:
lantianwenshi.com. 3 IN CNAME 1109.hiezs.net.
1109.hiezs.net. 3 IN A 8.140.245.97
域名/IP获取的IP地址数字地址运营商IP的物理位置
8.140.245.978.140.245.97143455585阿里云中国北京北京 ip138提供
你好,测试网站用的是 8.140 开头的北京阿里云IP,目前看来这个项目提供的ip库比较准确 https://github.com/Hackl0us/GeoIP2-CN https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt
手动用上面的 ip 库生成 chnroute.ipset ,大小为 196KB https://github.com/zhanhb/cidr-merger
我用的上面的 pexcn 的数据,见上面链接。
ipset test chnroute 8.140.245.97 :
8.140.245.97 is in set chnroute.
@cattyhouse 多谢,我改用 pexcn 了。 现在用 xargs (findutils-xargs) 导入 ipset,不知道有没有更好的办法
xargs -a "$file_path" -I CIDR ipset add chnroute CIDR
你们上面提到的两个库(v4),来源是 ipip.net + 纯真ip/apnic。
另外,目前大多数 chnroute6.txt 的数据源都来自于 apnic。
后面的版本我会将 chnroute/chnroute6.txt 改为 pexcn 的源。
@cattyhouse 多谢,我改用 pexcn 了。 现在用 xargs (findutils-xargs) 导入 ipset,不知道有没有更好的办法
xargs -a "$file_path" -I CIDR ipset add chnroute CIDR
更快的方法:
printf '%s\n' "create chnroute hash:net family inet" > chnroute.ipset
printf 'add chnroute %s\n' $(cat /path/to/chnroute.txt) >> chnroute.ipset
ipset -q -exist restore -file chnroute.ipset
最新的 chnroute.ipset/nftset 已经改为 pexcn 的源了,测试了没问题。
$ ipset list aliyun_ip
Name: aliyun_ip
Type: hash:net
Revision: 7
Header: family inet hashsize 1024 maxelem 65536 bucketsize 12 initval 0x0cd1525a
Size in memory: 504
References: 0
Number of entries: 1
Members:
8.128.0.0/10
$ ipset test aliyun_ip 8.140.245.97
Warning: 8.140.245.97 is in set aliyun_ip.
发现缺少了阿里云 8. 开头的IP段 https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt