zfl9 / chinadns-ng

chinadns 重构增强版,支持域名分流、ipset/nftset、UDP/TCP/DoT
GNU Affero General Public License v3.0
1.09k stars 184 forks source link

chnroute.ipset 国内IP库不全 #146

Closed zmz125000 closed 6 months ago

zmz125000 commented 8 months ago

发现缺少了阿里云 8. 开头的IP段 https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt

cattyhouse commented 8 months ago

下面2个方法都试试

  1. 运行 https://github.com/zfl9/chinadns-ng/blob/master/update-chnroute.sh , 更新下再看看?

  2. 同这个比较下看看? https://github.com/pexcn/daily/blob/gh-pages/chnroute/chnroute.txt

zfl9 commented 8 months ago
$ 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
zfl9 commented 8 months ago

apnic这边搜到了两个8.开头的ip段,但属地是SG(新加坡)。

也许可以考虑换个ip库?有哪些推荐的?

zmz125000 commented 8 months ago

@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

cattyhouse commented 8 months ago

我用的上面的 pexcn 的数据,见上面链接。

ipset test chnroute 8.140.245.97 :

8.140.245.97 is in set chnroute.

cattyhouse commented 8 months ago

看起来他用了2个 source

https://github.com/pexcn/daily/blob/master/scripts/chnroute/chnroute.sh

zmz125000 commented 8 months ago

@cattyhouse 多谢,我改用 pexcn 了。 现在用 xargs (findutils-xargs) 导入 ipset,不知道有没有更好的办法

xargs -a "$file_path" -I CIDR ipset add chnroute CIDR
zfl9 commented 8 months ago

你们上面提到的两个库(v4),来源是 ipip.net + 纯真ip/apnic。

另外,目前大多数 chnroute6.txt 的数据源都来自于 apnic。


后面的版本我会将 chnroute/chnroute6.txt 改为 pexcn 的源。

cattyhouse commented 8 months ago

@cattyhouse 多谢,我改用 pexcn 了。 现在用 xargs (findutils-xargs) 导入 ipset,不知道有没有更好的办法

xargs -a "$file_path" -I CIDR ipset add chnroute CIDR

更快的方法:

zfl9 commented 6 months ago

最新的 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.