{"id":13841875,"url":"https://github.com/burpheart/cdnlookup","last_synced_at":"2026-01-16T17:30:31.753Z","repository":{"id":44395485,"uuid":"500092472","full_name":"burpheart/cdnlookup","owner":"burpheart","description":"一个使用 Edns-Client-Subnet(ECS) 遍历智能CDN节点IP地址的工具","archived":false,"fork":false,"pushed_at":"2022-06-07T06:20:01.000Z","size":17,"stargazers_count":145,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-05T17:29:42.164Z","etag":null,"topics":["dns","infosec","security","security-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/burpheart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-05T12:32:15.000Z","updated_at":"2024-07-22T04:02:52.000Z","dependencies_parsed_at":"2022-07-15T03:00:41.027Z","dependency_job_id":null,"html_url":"https://github.com/burpheart/cdnlookup","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burpheart%2Fcdnlookup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burpheart%2Fcdnlookup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burpheart%2Fcdnlookup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/burpheart%2Fcdnlookup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/burpheart","download_url":"https://codeload.github.com/burpheart/cdnlookup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225729732,"owners_count":17515158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns","infosec","security","security-tools"],"created_at":"2024-08-04T17:01:23.323Z","updated_at":"2026-01-16T17:30:31.738Z","avatar_url":"https://github.com/burpheart.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"#  前言 \n前不久我遇到了一个关于获取CDN节点ip列表的问题:\n\n**如何快速获取一家CDN节点在全国的范围内的节点ip？**\n\n为了解决这个问题，我分析了智能DNS的工作原理。根据原理，我写出了一个使用 Edns-Client-Subnet(ECS)  伪造客户端ip用于遍历cdn节点ip的小工具。\n\n之前为了获取多个地理位置的的CDN节点需要使用大量代理服务器去发起DNS查询。但是寻找合适的代理服务器非常困难。这个工具解决了这个问题。 \n\n**该工具无需使用代理，只需要提供要模拟的客户端ip地址，就可以轻松获取对应ip地址地理位置的DNS解析结果。**\n\n#  cdnlookup \n一个使用 Edns-Client-Subnet(ECS) 遍历智能DNS节点IP地址的工具\n\n## 原理\n\n#### 智能DNS\nCDN 为了让用户连接到地理位置更近的服务器，在DNS解析时使用了一种叫做智能DNS解析的操作。 CDN的权威DNS服务器会根据客户端IP地址来判断用户所在区域及运营商，来返回距离较近的节点。\n\n早期，权威DNS服务器通常无法直接获取到客户端ip，只能获取到上级公共递归DNS服务器地址。\n\n####  Edns Client Subnet(ECS)\n\nECS 是由Google提交的一份DNS扩展协议，主要作用是传递用户的IP地址给权威DNS服务器。\n\n[rfc7871](https://datatracker.ietf.org/doc/html/rfc7871) （2016 年 5 月）\n\n遵循ECS标准的公共DNS，会将经遮罩脱敏后的客户端ip添加至DNS扩展区域( [EDNS rfc6891](https://datatracker.ietf.org/doc/html/rfc6891))传递至权威DNS （IPV4 遮罩通常为/24  IPV6 为 /56）\n\n这样权威DNS服务器就可以获取到模糊的客户端ip，这足以用于判断用户运营商和位置信息。\n\n####  cdnlookup\n这个工具会直接发送包含自定义IP的ECS数据的DNS请求，诱导NS服务器返回对应IP的解析结果。\n\n经测试，国内大部分公共DNS都不支持自定义ECS。  谷歌DNS 8.8.8.8 可以正常使用\n\n除了公共递归DNS，也可以直接将带有ECS数据的DNS请求发送到目标权威DNS服务器，获取解析结果。\n\n# 使用\n````\n-d 域名  (默认 www.taobao.com)\n\n-i 只输出IP地址列表\n\n-ip 客户端ip\n\n-r 请求重复轮数\n\n-s DNS服务器地址 (默认 8.8.8.8:53)\n\n-6 AAAA 查询 (IPV6)\n````\n\n自定义客户端ip\n````\ncdnlookup.exe -d www.taobao.com  -ip 1.2.3.4\n\n219.147.75.XXX\n219.147.75.XXX\n````\n\n使用内置实例ip列表 (内置列表可能会出现判断错误. 建议使用家宽ip段地址定位. )\n````\ncdnlookup.exe -d www.taobao.com\n\n北京市 教育网\n36.99.228.XXX\n36.99.228.XXX\n吉林 长春 移动\n111.26.147.XXX\n111.26.147.XXX\n辽宁 沈阳 电信\n59.47.225.XXX\n59.47.225.XXX\n......\n````\nIPV6 查询\n\n````\ncdnlookup.exe -d www.jd.com -6 -ip 240e:382:701:7700:600c:5c8:0000:0000\n\n240e:c3:2800::26\n240e:c3:2800::22\n240e:95d:c02:200::3a\n\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburpheart%2Fcdnlookup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fburpheart%2Fcdnlookup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fburpheart%2Fcdnlookup/lists"}