arloan / prdns Goto Github PK
View Code? Open in Web Editor NEWPurified DNS: a CDN friendly and anti-pollution DNS forwarder server that does not rely on GeoIP/GeoDomain db.
License: GNU General Public License v3.0
Purified DNS: a CDN friendly and anti-pollution DNS forwarder server that does not rely on GeoIP/GeoDomain db.
License: GNU General Public License v3.0
若输入的域名不存在或者查询超时,这边就会发生错误
| Errno::ECONNRESET: An existing connection was forcibly closed
by the remote host. - recvmsg(2)
| → C:/Ruby27-x64/lib/ruby/2.7.0/socket.rb 444
| C:/Ruby27-x64/lib/ruby/2.7.0/socket.rb 444
| C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/async-io-1.27.3/lib/
async/io/generic.rb 216
| C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/async-io-1.27.3/lib/
async/io/generic.rb 62
| C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/async-dns-1.2.5/lib/
async/dns/handler.rb 73
| C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/async-dns-1.2.5/lib/
async/dns/server.rb 114
| C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/async-io-1.27.3/lib/
async/io/socket.rb 169
| C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/async-1.24.2/lib/asy
nc/task.rb 258
5m28s warn: <> UDP response failed: #<IOError: closed stream>! [pid=13688]
[2020-03-03 20:39:44 +0800]
-a的说明里面看着不大对,另外-p和-a命令写了好像没用,还是用的114和208这两个ip
hi.
在mac上。
yudeMacBook-Air:~ brite$ gem install prdns
ERROR: Loading command: install (LoadError)
dlopen(/usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/x86_64-darwin16/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/x86_64-darwin16/openssl.bundle
Reason: image not found - /usr/local/Cellar/ruby/2.6.3/lib/ruby/2.6.0/x86_64-darwin16/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
yudeMacBook-Air:~ brite$ which gem
/usr/local/opt/ruby/bin/gem
yudeMacBook-Air:~ brite$ which ruby
/usr/local/opt/ruby/bin/ruby
yudeMacBook-Air:~ brite$ gem --version
3.0.3
yudeMacBook-Air:~ brite$
怎么解决?
第一次查询www.google.com的ip结果为31.13.73.1
第二次查询www.google.com的ip结果为31.13.73.1
第三次查询www.google.com的ip结果为172.217.27.132
`root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig www.google.com @127.0.0.1 -p 5400
; <<>> DiG 9.10.3-P4-Debian <<>> www.google.com @127.0.0.1 -p 5400
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23259
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 60 IN A 31.13.73.1
;; Query time: 32 msec
;; SERVER: 127.0.0.1#5400(127.0.0.1)
;; WHEN: Sun Apr 12 11:26:42 CST 2020
;; MSG SIZE rcvd: 48
root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig www.google.com @127.0.0.1 -p 5400
; <<>> DiG 9.10.3-P4-Debian <<>> www.google.com @127.0.0.1 -p 5400
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46933
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 60 IN A 31.13.73.1
;; Query time: 32 msec
;; SERVER: 127.0.0.1#5400(127.0.0.1)
;; WHEN: Sun Apr 12 11:26:53 CST 2020
;; MSG SIZE rcvd: 48
root@iZwz9d1rjhrzzxa4lsoi93Z:~# dig www.google.com @127.0.0.1 -p 5400
; <<>> DiG 9.10.3-P4-Debian <<>> www.google.com @127.0.0.1 -p 5400
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57115
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.google.com. IN A
;; ANSWER SECTION:
www.google.com. 119 IN A 172.217.27.132
;; Query time: 35 msec
;; SERVER: 127.0.0.1#5400(127.0.0.1)
;; WHEN: Sun Apr 12 11:26:56 CST 2020
;; MSG SIZE rcvd: 48
`
看到你的贴子,可以说是英雄所见略同。大概在一年前根据相似的原理写了一个防DNS污染的小项目。
具体的内容可以参考我这篇博文:https://blog.bgme.me/posts/some-ideas-about-anti-pollution-dns-server/
这篇博文写的有一点早,再加上后来GFW的DNS污染模块做了一些升级(对于AAAA请求,也会返回虚假的AAAA纪录,而不是像博文中写的直接返回A纪录),把项目简单重写了一下。所以看博文时,防火墙缺陷一节看完之后就不用再向下看了。(等一下会对该博文进行一下更新)
大概看了一下项目的源码,感觉可能会存在以下问题:
问题一:上面v友所说的对于泛解析不适用,无法区分该域名是泛解析域名还是被GFW污染的域名。
对于这个问题可以采用我博文中的方法,向境外一未开放53端口的主机发送DNS请求来解决。
问题二:其实是问题一的衍生,鉴于国内某些运营商的DNS劫持行为(甚至直接劫持53端口),如果其对 NXDOMAIN
返回有效的A纪录或AAAA纪录的话,那么你的项目就没有什么用了。方法一中的解决办法也受到很大的限制。
这个一个可能的解决方法是,向境外未开放53端口的主机发送DNS时,不要请求A、AAAA纪录,而是请请求MX、TXT等纪录,并同时附加上 norecurse
flag。如果在这种情况下收到A纪录或AAAA纪录的回复,即证明该域名已被DNS污染。
问题三:对于CNAME至被污染域名的域名无效。
举例说明:现有一域名 test.example.com
CNAME至 www.google.com
。
那么你项目中的测试方法便对这样的域名无效,因为 test.example.com 并不存在于GFW的屏蔽列表之中,所以你构造的 ne-[timestamp].test.example.com
查询并不会得到GFW的伪响应。但由于其CNAME至被污染域名www.google.com,所以你最终得到的解析结果仍是被污染的。
对于第三个问题,说一个现实一点的例子,之前有一段时间 github头像加载不出来。
经过我的分析,问题大致如下:
avatars*.githubusercontent.com
域名本身没有被屏蔽,但是由于被 CNAME 至了 github.map.fastly.net
。
而之前 map.fastly.net
、ssl.fastly.net
被DNS投毒,致使 avatars*.githubusercontent.com
解析至被污染域名。
对于问题三,由于我的项目直接使用bind来递归查询,所以不存在这个问题。
但对于你的项目而言,大概需要对于所有 CNAME 指向的域名再进行二次查询验证。
本来是想直接在 v2ex 原贴下进行回复的,但由于v2ex的奇葩设计,上述文本无法直接发出(需验证手机号),所以特贴在此处。
另外,如果你愿意并且有空的话,可以帮忙转贴至v2ex吗?
环境 ubuntu16.04 ruby2.6
Traceback (most recent call last):
7: from /usr/local/bin/prdns:23:in <main>' 6: from /usr/local/bin/prdns:23:in
load'
5: from /var/lib/gems/2.6.0/gems/prdns-0.1.0/exe/prdns:5:in <top (required)>' 4: from /usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
require'
3: from /usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' 2: from /var/lib/gems/2.6.0/gems/prdns-0.1.0/lib/prdns.rb:1:in
<top (required)>'
1: from /usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in require' /usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in
require': cannot load such file -- async/dns (LoadError)
If the Ruby/gem are not installed for root, and prdns was installed by this limited version of gem,
then prdns won't be able to listen on port 53.
What's the better way to deal with this non-root 53 binding issue?
Could you please suggesting one or two ways? Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.