GFW真是太不要脸了,现在给google来了个中间人攻击,把他的证书替换了,真是吊的飞起。现在就算用dnscrypt也没有用了。因为GFW没有阻止ip,直接就是攻击。CTMD。不过我偶然发现只要DNS不是解析到中国的就不会遭受中间人攻击。因为CDN的关系,DNS可以根据客户端ip来解析对应的服务器ip。我如果解析到美国的google ip就不会被中间人攻击。当然,全局的转发也是可以的,比如socks,但速度还是有区别的。
注意:这里说的都是在教育网,没有在其他网络尝试。
unbound + dnscrypt + opendns
opendns的ip是208.67.222.222,208.67.220.220 {443, 53, 5353},支持加密传输。这在之前dnscrypt和unbound已经讨论过。但这种方法已经不适合。因为他会解析到google对应东南亚的ip。
ssh tunnel + nc
这个是比较蛋疼,也比较复杂。我也没有试过,总体来说,先建立ssh本地转发tunnel,然后用nc将udp转为tcp,经ssh tunnel转发。那么解析的ip就不一样了。具体看链接。
ssh tunnel + unbound
我认为这是最合适的方法。先要启用unbound tcp-upstream,并设置forward-zone。我的unbound.conf文件见文末。然后启用ssh tunnel: ssh -L 9053:8.8.8.8:53 server-ip 。最后是修改resolv.conf文件。只要改为 nameserver 127.0.0.1 ,一切ok,测试结果见文末。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | server: username: "unbound" directory: "/etc/unbound" interface: 0.0.0.0 interface: ::0 access-control: 59.78.11.0/24 allow access-control: ::1 allow use-syslog: yes do-not-query-localhost: no port:53 tcp-upstream: yes forward-zone: name: "." forward-addr: 127.0.0.1@9053 |
ssh reverse tunnel + unbound
这个也行,原理跟上面类似,但这里用的是ssh reverse tunnel。比如 ssh -R 9053:8.8.8.8:53 user@china-host 。这个命令要在国外主机运行,他的意思是连接到china-host,并将通过china-host:9053的流量,经过国外主机(本主机)转发到8.8.8.8:53。有点小复杂。原理是一样的,也是能跑起来的。
测试结果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ########################################################### # opendns ########################################################### ;; ANSWER SECTION: www.google.com. 300 IN A 173.194.127.49 www.google.com. 300 IN A 173.194.127.50 www.google.com. 300 IN A 173.194.127.52 www.google.com. 300 IN A 173.194.127.51 www.google.com. 300 IN A 173.194.127.48 ;; Query time: 229 msec ;; SERVER: 208.67.220.220#53(208.67.220.220) ;; WHEN: Tue Sep 2 14:00:54 2014 ;; MSG SIZE rcvd: 123 ########################################################### # tunnel to US ########################################################### ;; ANSWER SECTION: www.google.com. 233 IN A 74.125.239.114 www.google.com. 233 IN A 74.125.239.116 www.google.com. 233 IN A 74.125.239.115 www.google.com. 233 IN A 74.125.239.112 www.google.com. 233 IN A 74.125.239.113 ;; Query time: 426 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Tue Sep 2 17:59:32 2014 ;; MSG SIZE rcvd: 123 ########################################################### # tunnel to Japan ########################################################### ;; ANSWER SECTION: www.google.com. 300 IN A 173.194.38.80 www.google.com. 300 IN A 173.194.38.81 www.google.com. 300 IN A 173.194.38.84 www.google.com. 300 IN A 173.194.38.83 www.google.com. 300 IN A 173.194.38.82 ;; Query time: 861 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Tue Sep 2 18:29:45 2014 ;; MSG SIZE rcvd: 123 |
链接