Code Monkey home page Code Monkey logo

Comments (6)

GangZhuo avatar GangZhuo commented on June 24, 2024 1

当使用 ECS 的时候,需要把自己的 IP 传递给 DNS 服务器,因此 DNS 服务器可以选择离你最近的 IP 返回给你。
CleanDNS 传递的不是自己的 IP 地址,而是通过 -l 和 -f 选项指定的 IP 地址。
当使用国外 DNS 服务器时,传递 -f 指定的 IP 作为本机 IP 地址;当使用国内 DNS 时,则使用 -l 指定的 IP。
每当 cleandns 接收到解析请求时,都会往国外和国内 DNS 服务器发送请求,然后根据一定的规则,选择国内/国外服务器的解析结果来回应用户。
因此 -l 选项一般指定本机 IP,-f 一般指定 VPS 服务器 IP,这样的话,国外 DNS 服务器可返回离 SS 服务器最近的 IP,国内 DNS 服务器可返回离自己最近的 IP。

ECS 只需要你传递部分 IP 网段,这样 DNS 服务器就可以知道离你最近的 IP 是什么,这也是出于安全原因,因此 /24 的意思就是你指定的 ip 是 114.114.114.114/24,实际上传递给 DNS 服务器的是 114.114.114.0。
/24 也可大概了解为数字越大,传递给 DNS 服务器的 IP 地址越精确,也越能精确的判断离它最近服务器。

工作过程解释有误,见 #2 (comment)

from cleandns.

GangZhuo avatar GangZhuo commented on June 24, 2024 1

上一条的解释中有错误, CleanDNS 没有往两个 DNS 服务器转发请求,而是分别使用 -l 和 -f 指定的 IP 构建两个 ECS 包,并发送给一个 DNS 服务器。
假设 -l 指定本机 IP,-f 指定 VPS IP。那么接收到 DNS 服务器的解析结果后。如果使用本机 IP 的结果中包含国内 IP,或者使用 VPS IP 的结果中包含国内 IP,则选择本机 IP 的解析结果回应用户;否则使用 VPS IP 的结果回应用户。

from cleandns.

pexcn avatar pexcn commented on June 24, 2024

谢谢回复。
另外**大陆现在似乎没有支持 ECS 的 DNS 吧?(好像只能用 8.8.8.8?) 上面提到这一段:

当使用国内 DNS 时,则使用 -l 指定的 IP。......

是不是说明程序已经有那样的逻辑,但是不能那样使用?

from cleandns.

GangZhuo avatar GangZhuo commented on June 24, 2024

CleanDNS 发送请求到 8.8.8.8 时,会被污染的,-m 选项可以过滤掉污染结果(以前可以,现在不知道能不能了)。如果通过代理转发请求则不需要 -m 选项。

from cleandns.

pexcn avatar pexcn commented on June 24, 2024

清楚了,感谢。
另外 -m 选项偶尔会失效,有时候可以,有时候不可以。现在我是把 CleanDNS 作为 ChinaDNS 的国外 DNS 来使用的,运行良好。
CleanDNS 单独使用的时候还会出现一个问题,大概就是说 www.qq.com 在香港会有 CDN,假如你 -l 的参数填深圳的 IP,CleanDNS 就会返回 www.qq.com IP 为香港的解析结果,如果此时配合 shadowsocks 一起使用的话,会导致 www.qq.com 走了代理,速度缓慢了。

from cleandns.

LazyZhu avatar LazyZhu commented on June 24, 2024

路由器的话可以用 dnsmasq-chnroute, 配合dns over tls/https 来使用.

@GangZhuo
CleanDNS 一直在用,比golang那些程序小巧得多,适合路由器.
有空的话可以增加chinadns那样的多个dns upsteam.

from cleandns.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.