https://github.com/lbp0200/PRCDNS
拿 opendns 做测试对比
dig @23.106.151.177 +tcp -p 3535 google.com.hk #PRCDNS
dig @208.67.222.222 +tcp -p 443 google.com.hk #opendns
dig @23.106.151.177 +tcp -p 3535 img.alicdn.com #PRCDNS
dig @208.67.222.222 +tcp -p 443 img.alicdn.com #opendns
测试 IP 仅供测试, DDoS 留情
1
firefox12 2017-01-25 00:21:45 +08:00 via iPhone
cdn 友好的原理是什么?比如一个北京 ip 访问解析一个 www.sina.com 如何知道改返回一个国内 ip 给它?还是回一个北美 ip
|
2
lbp0200 OP @firefox12 IP 交给 Google , Google 就给了正确答案,我也不知道 Google 如何做到的。
|
5
hzw 2017-01-25 16:22:29 +08:00 via iPhone
家里用一个老的笔电跑了 ubuntu ,现在开的 dnsmasq ,楼主这个可以么?或者换成 pdnsd 后装楼主这个?
|
7
firefox12 2017-01-25 23:54:39 +08:00 via iPhone
原理上说不通啊,标准 dns request 里面并没有客户端的 ip 啊 所以你用标准的 dns 去请求 他返回的是这台转发 dns 请求服务器这个区域的对应 ip 我们知道这是不对的。
|
8
lbp0200 OP @firefox12 TCP 总会知道请求者的 IP 的,拿着请求者的 IP 提交给 Google 的 http 接口,就会得到正确的解析结果,将结果包装成标准的 dns 格式返回。
|
9
q397064399 2017-01-26 14:10:54 +08:00
@lbp0200 #6
pdnsd 好像无法设置上游查询的端口 |
10
csvw 2017-01-26 14:12:53 +08:00
@lbp0200 据我了解,只有域名支持 edns subnet 的, google 才可能给出正确的 ip ,而国内支持 edns subnet 的域名应该没有很多,所以大概率还是没法替代国内的 dns
|
11
q397064399 2017-01-26 14:14:35 +08:00
|
12
tangzho 2017-01-26 20:00:26 +08:00 via Android
pdnsd 和 unbound 都可以非标和强制 tcp 上游,
|
13
tangzho 2017-01-26 20:05:12 +08:00 via Android
dnsmasq 支持非标端口,支持 tcp 但不能强制 tcp
|
14
bazingaterry 2017-01-26 23:06:32 +08:00
|
18
lbp0200 OP |
19
lbp0200 OP |
21
lbp0200 OP @q0000x 一年内不会关, prcdns 需要 Python3.5 ,我也不清楚如何安装到 openwrt 上。文档我一点点写吧。
|
22
lbp0200 OP @q0000x 可以将 114 作为备用,
server { label = "prcdns"; //设置 PRCDNS 作为上游服务器 ip = 23.106.151.177; timeout = 10; port = 3535; } server { label = "114dns"; //备用 114DNS 作为上游服务器 ip = 114.114.114.114,114.114.115.115; timeout = 10; port = 53; } |
26
q0000x 2017-01-29 01:57:59 +08:00
@lbp0200 3.6 不知道行不行,看到你 setup 里写了 3.6 路由上已经把 3.6 的 py 撸好运行后提示
我是吧 setup.py 、 setup.config 下载到路由上执行 root@OpenWrt:~# /tmp/setup.py /tmp/setup.py: line 2: A setuptools based setup module. : not found /tmp/setup.py: line 5: from: not found /tmp/setup.py: line 6: from: not found /tmp/setup.py: line 8: from: not found /tmp/setup.py: line 10: syntax error: unexpected "(" |
32
maojy1989 2017-02-07 12:01:03 +08:00
遇到一个很尴尬的问题,我在 centos7 上安装 Python3.5.1 然后 pip install PRCDNS 当我用 yum 安装 Supervisor 的时候遇到问题了 Supervisor 启动不起来
pkg_resources.DistributionNotFound: The 'supervisor==3.1.3' distribution was not found and is required by the application 搜了很久也没找到怎么解决这个问题了,然后想试试用 pip install Supervisor 得到以下结果 ollecting supervisor Downloading supervisor-3.3.1.tar.gz (415kB) 100% |████████████████████████████████| 419kB 2.4MB/s Complete output from command python setup.py egg_info: Supervisor requires Python 2.4 or later but does not work on any version of Python 3. You are using version 3.5.1 (default, Feb 7 2017, 03:41:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]. Please install using a supported version. ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-qadut3c0/supervisor/ 好像是 supervisor 不支持 python3 这就很尴尬了,怎么搞? |
33
maojy1989 2017-02-07 13:07:12 +08:00
已经解决了,果然把默认 python 换成 3.5 不是个好主意 好多地方要把 #!/usr/bin/python 换成 #!/usr/bin/python2.7
|
34
mike163 2017-02-09 13:56:17 +08:00
不能支持 udp 吗?这样可以用 dnsmasq 直接访问了
|
36
q0000x 2017-02-11 09:28:39 +08:00
@lbp0200 话说我在你的博客上怎么找不到你的微信
python3 PRCDNS python3: can't open file 'PRCDNS': [Errno 2] No such file or directory pip3 install PRCDNS Requirement already satisfied: PRCDNS in /opt/python-3.6.0/lib/python3.6/site-packages Requirement already satisfied: asyncio in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: aiohttp in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: aiodns in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: cchardet in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: dnslib in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: argparse in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: IPy in /opt/python-3.6.0/lib/python3.6/site-packages (from PRCDNS) Requirement already satisfied: chardet in /opt/python-3.6.0/lib/python3.6/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: multidict>=2.1.4 in /opt/python-3.6.0/lib/python3.6/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: async_timeout>=1.1.0 in /opt/python-3.6.0/lib/python3.6/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: yarl>=0.8.1 in /opt/python-3.6.0/lib/python3.6/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: pycares>=1.0.0 in /opt/python-3.6.0/lib/python3.6/site-packages (from aiodns->PRCDNS) 直接 PRCDNS 的话就是一个光标一直在闪,不能进行任何操作了 |
38
lbp0200 OP @q0000x 对,这样程序就运行起来了,可以测试下,需要一直运行的话,搭配 supervisor
|
44
matsuz 2017-02-12 09:06:57 +08:00 via Android
这个如果放在本地路由器上的话应该是没办法做到 CDN 友好的吧。
Google Public DNS 是通过用户的 ip 来实现 cdn 友好的,如果部署在本地的话,你的 ip 是一个内网 ip , google 是没法对一个内网 ip 进行 cdn 优化的。 我也写过一个这种程序,不过是用 Java 写的。依我之见,必须得找个 vps 部署到服务器上。 |
45
lbp0200 OP @matsuz 先通过 http://ipinfo.io/的接口拿到本地公网 ip ,然后把本地公网 IP 作为参数传给 Google 的 DNS 接口,所以部署在本地是可以的。
|
48
lbp0200 OP @q0000x https://dns.google.com/resolve?name=域名&edns_client_subnet=你的公网 ip/24
访问 Google 的接口,直接看 Google 给的结果。 我在使用中发现 china.com 的解析有问题,所以在 pdnsd 里,添加 114 做补充,不过无所谓了,我不看中华网。 |
49
titanium98118 2017-02-14 13:20:52 +08:00
在 PRCDNS 可以手动指定一个 EDNS IP 吗?
|
50
lbp0200 OP 没有这个功能
|
51
lbp0200 OP @titanium98118 没有这个功能
|
52
HalloCQ 2017-02-17 18:01:11 +08:00
[root@localhost ~]# python PRCDNS
python: can't open file 'PRCDNS': [Errno 2] No such file or directory 怎么回事啊? |
54
HalloCQ 2017-02-18 22:27:54 +08:00
[root@localhost ~]# PRCDNS &
[1] 15402 [root@localhost ~]# -bash: PRCDNS: command not found [1]+ Exit 127 PRCDNS [root@localhost ~]# PRCDNS -bash: PRCDNS: command not found @q0000x |
55
HalloCQ 2017-02-18 22:29:32 +08:00
@q0000x
[root@localhost ~]# pip install PRCDNS Requirement already satisfied: PRCDNS in /usr/local/python3/lib/python3.5/site-packages Requirement already satisfied: asyncio in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: aiohttp in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: aiodns in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: cchardet in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: dnslib in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: argparse in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: IPy in /usr/local/python3/lib/python3.5/site-packages (from PRCDNS) Requirement already satisfied: yarl<0.10,>=0.9.8 in /usr/local/python3/lib/python3.5/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: multidict>=2.1.4 in /usr/local/python3/lib/python3.5/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: async-timeout>=1.1.0 in /usr/local/python3/lib/python3.5/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: chardet in /usr/local/python3/lib/python3.5/site-packages (from aiohttp->PRCDNS) Requirement already satisfied: pycares>=1.0.0 in /usr/local/python3/lib/python3.5/site-packages (from aiodns->PRCDNS) [root@localhost ~]# PRCDNS -bash: PRCDNS: command not found |
58
HalloCQ 2017-02-19 08:28:17 +08:00
可以了
|
59
lbp0200 OP @q0000x 结果看起来貌似是对的
dig @23.106.151.177 +tcp -p 3535 fast.com ; <<>> DiG 9.10.3-P4-Ubuntu <<>> @23.106.151.177 +tcp -p 3535 fast.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50980 ;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;fast.com. IN A ;; ANSWER SECTION: fast.com. 19 IN A 23.48.253.70 ;; Query time: 398 msec ;; SERVER: 23.106.151.177#3535(23.106.151.177) ;; WHEN: Mon Feb 20 14:24:47 CST 2017 ;; MSG SIZE rcvd: 42 |
62
q0000x 2017-02-24 00:25:13 +08:00
|
63
lbp0200 OP |
66
HalloCQ 2017-02-24 11:12:38 +08:00
@lbp0200
Loaded plugins: fastestmirror base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 extras/7/x86_64/primary_db | 122 kB 00:00 Loading mirror speeds from cached hostfile * base: mirror.supremebytes.com * extras: mirror.supremebytes.com * updates: mirror.supremebytes.com No package polipo available. Error: Nothing to do |
67
q0000x 2017-02-24 14:49:04 +08:00
@lbp0200 应该是 pdnsd 上 edns 那个参数的影响,我把那个 OFF 掉还算正常,不能用 114 做备用,会被抢答掉
|
69
lbp0200 OP |
71
HalloCQ 2017-02-24 21:14:45 +08:00
我把 s-s 和 prcdns 部署到同一台服务器上,然后在路由器开启 s-s 和 pdnsd
如果 ss 和 pdnsd 都是用我服务器的 ip 的话就不能用,非要一个不是我服务器 ip 才行 这是怎么回事? |
72
HalloCQ 2017-02-24 21:22:19 +08:00
不对,发现问题了。是开 gfw 模式才这样, ip 模式可以用
|
74
q0000x 2018-02-26 16:27:13 +08:00 1
@lbp0200 proxy_client.py 代码要更新了
async def fetch(session, url, proxy=None): with aiohttp.Timeout(10): aiohttp.Timeout(10):这个在某些版本比较新的 centos 和 debian 上不被支持,要 import async_timeout 使用 async_timeout.timeout(10):代替 详情参考: https://pypi.python.org/pypi/aiohttp |