自建 DNS,当域名解析到 CloudFlare 时自动优选 IP

100 天前
 LYRYRYlo

众所周知,CloudFlare CDN 在内地访问速度一般。刚刚突然想到如果在家里自建 DNS ,当识别到域名解析到 CloudFlare 时自动解析到优选 IP ,内地直连访问会不会好一点

为什么这么做?

并非所有套 CloudFlare CDN 的网站都会使用优选 IP

而且今年 CloudFlare 更新了 TOS 不允许用户将域名解析至非默认分配的 IP,不知道这种类似自动改 Hosts 的方法算不算一种曲线救国的方法)。

或许有 V 友问为什么不上代理?因为有些 IPTV 直播源网站就套了 CF CDN ,如果能直接使用优选 IP 的话就没必要浪费这么多流量了

所以我想问啥

不知道各位 V 友有没有具体实例,或者说这个方法是否可行,先感谢各位 V 友了

3837 次点击
所在节点    宽带症候群
40 条回复
gentrydeng
100 天前
我个人认为所谓的“优选 IP”就是种伪需求。

既然你知道目前 December 3, 2024 版本的 Cloudflare Self-Serve Subscription Agreement 2.2 Use of Services - 2.2.1 Restrictions 条款包含以下限制:

---
Unless otherwise expressly permitted in writing by Cloudflare, you will not and you have no right to:

(b) interfere with, disrupt, alter, or modify the Services or any part thereof, or create an undue burden on the Services or the networks (including Cloudflare’s peering partners’ networks) or services connected to the Services, including, but not limited to, causing (whether directly or indirectly) traffic for your Cloudflare-proxied domain to be sent to an IP address that was not assigned by Cloudflare for the domain;
gentrydeng
100 天前
#1 那么你就不该考虑这个方案,因为:

This Agreement is effective when you click to accept it, use or access the Services, or otherwise indicate your acceptance of the Agreement.

条款的限制就算是“access the Services”也算数。
yeh
100 天前
多了去了,比如 https://cf.090227.xyz/
LYRYRYlo
100 天前
@gentrydeng 那没法了
Love4Taylor
100 天前
你是否在寻找 NovaXNS

LYRYRYlo
100 天前
@Love4Taylor 和我想的一样,感谢 V 友!
LYRYRYlo
100 天前
@Love4Taylor 不过这个好像不支持私有化部署?要是支持就好了
yxmyxmyyy
100 天前
试过不好用,运营商主动 qos aws 和 cf 的 ip ,aws 我试过任何位置(us.jp.sg),都是电信直连不丢包,但是都被限速到 20m(也有可能是 aws 搞的鬼),cf 就是白天可以,晚高峰根本用不了,优不优选没啥区别
ZeroClover
100 天前
@gentrydeng #2 这些条款仅针对网站所有者,网站的访客不是 Cloudflare 的客户,不受 Cloudflare 任何条款约束
hadoop
100 天前
@Love4Taylor 求一个邀请码
LYRYRYlo
100 天前
@hadoop TG 一进群就会发
heiher
100 天前
@gentrydeng #1 这种有点说不清,除非 cloudflare 掌握证据或就不和用户讲道理直接关停。用户自己只能控制 DNS 解析结果,却无法阻止有心的访问者自定义解析 IP 绕过,因此造成相关的责任不应直接由用户承担。
LYRYRYlo
100 天前
@gentrydeng 不过“access the Services”的对象应该是网站管理员吧,总不可能访客自定义解析 IP 就把访客 IP 给 ban 了吧
longsays
100 天前
https://github.com/XIU2/CloudflareSpeedTest 优选出自己本地最好的 IP ,然后 geoip:cloudflare 指向
NSAgold
100 天前
mosdns 有相关功能(实验性)
当解析出来的 ip 属于 cloudflare 的 ip 段时,返回优选 ip
XIU2
100 天前
我就是 CloudflareST 的作者,我最初也是和你一个想法和需求才写的这玩意,一开始我是用 hosts 但太麻烦于是后来研究出使用本地代理重定向的方式实现,但也有缺陷,最终我“进化”成了自己目前使用的方案也就是本地自建 DNS (运行在路由器上),另外这 3 种方案我都写过相关教程在我的项目里。

我目前用的是 mosdns ( V4 ,因为 V5 改动太大,也没啥吸引我的,就懒得更新),核心配置就 4 段,分别是一个用来判断上游解析结果 IP 是不是匹配 Cloudflare CDN IP 的、一个是是用来判断 cname 是不是 Cloudflare CDN 的,一个是用来指定要修改为的 IP 地址的,最后一个则是实际判断代码。

你可以去看一下别人在我项目里发的 mosdns 使用说明(不过后续都是我在排版更新完善):
https://github.com/XIU2/CloudflareSpeedTest/discussions/317
strobber16
100 天前
可行,但是有很多细节问题。cloudflare 的 ip 段不只是他们公开的那些,你需要一个有人维护的 ip 段表(否则域名判断会有漏网之鱼);并不是所有 ip 都是平等的,某些 ip 搭配某些域名会返回 403 。不过真要做的话,还有很多好玩的玩法,比如对没开启 ech/h3 的 cf 站点返回 https 记录使其支持 ech/h3
asshell
100 天前
@Love4Taylor 能给个邀请码吗? email:ZGZraXNxQGdtYWlsLmNvbQ
xiaonian233
100 天前
@LYRYRYlo 求个邀请码 email:d2Roay5yaWNlY2FrZUBvdXRsb29rLmNvbQ==
xiaonian233
100 天前
@Love4Taylor 求个邀请码 email:d2Roay5yaWNlY2FrZUBvdXRsb29rLmNvbQ==
@LYRYRYlo 抱歉 at 错了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://ex.noerr.eu.org/t/1127903

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX