比如说,我现在的站点做了国内外的 DNS 智能解析,国外的会使用 Cloudflare 的 CDN 节点,而国内的则会使用腾讯云 EO 的节点

现在尝试 ping 一下

 ~ % ping s3.juniortree.com
PING s3.juniortree.com.eo.dnse0.com (1.194.175.139): 56 data bytes
64 bytes from 1.194.175.139: icmp_seq=0 ttl=53 time=18.405 ms
64 bytes from 1.194.175.139: icmp_seq=1 ttl=53 time=17.914 ms
64 bytes from 1.194.175.139: icmp_seq=2 ttl=53 time=18.625 ms
^C
--- s3.juniortree.com.eo.dnse0.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 17.914/18.315/18.625/0.297 ms

然后查一下 IP 归属,很好,是一个河南的 IP,应该是命中了国内腾讯云的节点

image.png

通过一些在线多地 ping 的工具,我们可以拿到国内其他地点响应的 CDN 节点,为了测试,我选了一个离我很远的节点

通过使用 curl 来进行测试,对于支持 SNI 和 Host Header 的 CDN(如 Cloudflare、Akamai、阿里云 CDN、腾讯云 CDN 等),它会根据 Host 决定要服务的域名资源

~ % curl https://s3.juniortree.com/pic/2025/05/bcd6f4a69f3aae29a5e9692e819fa3cb.webp --resolve s3.juniortree.com:443:14.116.174.54
Warning: Binary output can mess up your terminal. Use "--output -" to tell 
Warning: curl to output it to your terminal anyway, or consider "--output 
Warning: <FILE>" to save to a file.

这里显示已经成功了,传输回来的是二进制文件,可以本地保存看一下

~ % curl https://s3.juniortree.com/pic/2025/05/bcd6f4a69f3aae29a5e9692e819fa3cb.webp --resolve s3.juniortree.com:443:14.116.174.54 --output test.webp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  176k  100  176k    0     0   673k      0 --:--:-- --:--:-- --:--:--  674k

现在测试一下使用 Cloudflare 的节点,还是没有问题

~ % curl https://s3.juniortree.com/pic/2025/05/bcd6f4a69f3aae29a5e9692e819fa3cb.webp --resolve s3.juniortree.com:443:104.21.64.114 --output test.webp 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  176k  100  176k    0     0  77251      0  0:00:02  0:00:02 --:--:-- 77254

总结

这东西本质和改 hosts 文件进行 IP 优选是一样的,境内外分离的本质优势还是就近解析,提高用户的访问体验,通过智能解析而希望能依赖 Cloudflare 抵抗境外的全部攻击是不合理和可行的

不过可以在腾讯云把海外的 IP 全给 ban 掉,海外请求就一定是走 Cloudflare 的,但是这个比较依赖于智能 DNS 的可靠性,比较好的方法是设置默认的请求给 Cloudflare,然后国内请求给腾讯云 EO

最后修改:2025 年 05 月 30 日
如果觉得我的文章对你有用,请随意赞赏