<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Gimo on Medium]]></title>
        <description><![CDATA[Stories by Gimo on Medium]]></description>
        <link>https://medium.com/@gimo?source=rss-adf236c96817------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xdpTN0Gws7pQowg1.jpg</url>
            <title>Stories by Gimo on Medium</title>
            <link>https://medium.com/@gimo?source=rss-adf236c96817------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 19:36:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gimo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[实用翻墙指南]]></title>
            <link>https://medium.com/@gimo/%E5%AE%9E%E7%94%A8%E7%BF%BB%E5%A2%99%E6%8C%87%E5%8D%97-390a7151d6bc?source=rss-adf236c96817------2</link>
            <guid isPermaLink="false">https://medium.com/p/390a7151d6bc</guid>
            <category><![CDATA[openwrt]]></category>
            <category><![CDATA[chinadns]]></category>
            <category><![CDATA[shadowsocks]]></category>
            <dc:creator><![CDATA[Gimo]]></dc:creator>
            <pubDate>Sun, 17 Jan 2016 07:53:05 GMT</pubDate>
            <atom:updated>2016-01-17T08:14:24.309Z</atom:updated>
            <content:encoded><![CDATA[<h4>Pandorabox + Shadowsocks</h4><p>使用路由器翻墙的一个好处是，只要搞定路由器其他连接路由器的设备不需要配置，比较简单实用。</p><p>首先假设已经拥有：</p><ul><li>一款支持 <a href="https://wiki.openwrt.org/toh/start">OpenWrt</a> 的路由器</li><li>一个稳定的 <a href="https://shadowsocks.com/">Shadowsocks 配置</a></li></ul><p>笔者这里使用的是比较廉价的 <a href="http://www.newbandeng.com/forum-113-1.html">Newifi mini(Y1)</a> ，搭配的 ROM 是 <a href="http://downloads.openwrt.org.cn/PandoraBox/Lenovo-Y1_RY-1S/firmware/testing/">Pandorabox</a> 看中的是已经内置了 Shadowsocks 和 <a href="https://github.com/shadowsocks/ChinaDNS">ChinaDNS</a> 等翻墙的基础设施。</p><p>先要灌入 ROM，这个各个设备的方法不一而足，暂且不表。</p><p>之后经过一些简单的配置保证能正常上网，比如我这边的网络环境需要使用无线中继，一般只要配置好 PPPoE 就好了，然后是配置好软件源，比如我的是这样：</p><pre>src/gz r3_base http://downloads.pandorabox.org.cn/pandorabox/packages/mt7620/packages/base<br>src/gz r3_management http://downloads.pandorabox.org.cn/pandorabox/packages/mt7620/packages/management<br>src/gz r3_oldpackages http://downloads.pandorabox.org.cn/pandorabox/packages/mt7620/packages/oldpackages<br>src/gz r3_packages http://downloads.pandorabox.org.cn/pandorabox/packages/mt7620/packages/packages<br>src/gz r3_routing http://downloads.pandorabox.org.cn/pandorabox/packages/mt7620/packages/routing<br>src/gz r3_telephony http://downloads.pandorabox.org.cn/pandorabox/packages/mt7620/packages/telephony</pre><p>这样，基本工作就准备好了。</p><p>然后在 Shadowsocks 配置页填入客制化配置，这里有几个不同的走向：</p><ol><li>开不开启透明代理？不开启的话默认是全局流量都通过 Shadowsocks 转发，基本上不是我们所乐见的，一方面很多 Shadowsocks 配置对于流量有限制，另外很多国内的网站去国外绕一圈没有太大必要。那么，我们需要一个路由表，用来区分哪些是中国的 IP，如果是中国的 IP 那么我们就直接访问就好。当然，这样也有不合理的地方，比如有些国外的网站并没有被墙，那么这部分其实也不需要透过 Shadowsocks 访问，要做到这一点 redsock2 据说可以用来判断是否被墙，当然对于我这种懒人来说，区分国内外的方式已经是可以接受的了。至于如何获得这份路由表，文章后面会谈到。</li><li>是不是使用 UDP 转发？如果你的 Shadowsocks 配置支持 UDP 转发，那么皆大欢喜，使用 UDP 转发可以省去 DNS 部分的处理。如果不支持就需要继续往下看。</li></ol><p>一般 DNS 查询使用 UDP，但是很多公共 DNS 会受到污染。这里基本上又有两个走向（都会使用到 ChinaDNS，之后谈到怎么配置 ChinaDNS）：</p><ol><li>如果你拥有一台可以直接访问的 VPS 或是其他中转设备，那么可以在上面搭建一个 DNS 转发服务，这里尽量不要使用 53 端口。这么做有效建立在你的 ISP 对于 UDP 没有过于严苛的过滤，即你可以无污染地、无阻隔地访问自己搭建的 DNS 转发服务。</li><li>如果你没有这样一个 VPS 或者你的 ISP 对于 UDP 比较严苛，那么需要让你的路由器通过 TCP 去查询域名并且缓存一段时间，我们可不希望每次 DNS 查询耗费 300ms 以上。因为根据之前的配置国外的流量会走 Shadowsocks，所以我们需要有一个强制通过 TCP 去查询域名的软件比如 unbound 和 pdnsd，前者没有在软件源里找到，所以我就使用后者了。</li></ol><p>好了，上面提到的几个东西，一一来解释配置。</p><h4>获取中国 IP 路由表</h4><p>我们可以通过亚太互联网络信息中心（APNIC）上发布的信息经过处理得到一份，网络上已经有人做了这部分工作：</p><pre>curl ‘http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest&#39; | grep ipv4 | grep CN | awk -F\| ‘{ printf(“%s/%d\n”, $4, 32-log($5)/log(2)) }’ &gt; /etc/chinadns_chnroute.txt</pre><p>下载完成后就会生成 /etc/chinadns_chnroute.txt 文件，填入上面提到的透明代理的配置中，另外之后提到的 ChinaDNS 也会用到。</p><h4>关于 ChinaDNS</h4><p>至于为什么要使用 ChinaDNS 可能会有疑问，如果我有一台不会被投毒的 DNS 转发服务器，或是通过强制 TCP 走 Shadowsocks 的方式来查询域名就可以得到正确的解析结果，那么，为什么还要加一层 ChinaDNS 呢？嗯，解析结果正确没有错，但是有个问题，正确的未必是合适的。诚如 ChinaDNS 在 GitHub 上的 README 开宗明义的讲到：</p><blockquote>Traditional way to bypass DNS poisoning is to send all queries to a foreign DNS server via VPN. <strong>However some Chinese websites will get bad results if they have CDNs outside the country.</strong></blockquote><blockquote>The second way is to maintain a list of domains of which you want to resolve from local DNS or foreign DNS. This list changes too often, taking too much effort to maintain.</blockquote><blockquote><strong>ChinaDNS automatically queries local DNS servers to resolve Chinese domains and queries foreign DNS servers to resolve foreign domains. It is smart enough to work only with a Chinese IP range file, which doesn’t change often.</strong></blockquote><p>因为 CDN 的存在，如果全都透过国外的 Server 去查询域名，就会得到非最优的解析结果，就和 CDN 的精神相悖。ChinaDNS 就是来解决这个问题的，具体的原理没有进一步调查，总之会需要之前的 /etc/chinadns_chnroute.txt 文件，另一个需要留意的是配置里需要提供两个 DNS 地址，一个是国内公共 DNS，可以是 ISP 提供的也可以使用 BAT 家提供的，另一个是国外的 DNS 地址，可以是自己搭建的境外 DNS 转发服务地址、或是路由器本地搭建的 TCP 强制转发的 DNS，也可以直接填 Google、OpenDNS 等公共服务地址，如果你的 Shadowsocks 开启了 UDP 转发 53 端口流量的话。</p><h4>pdnsd 配置</h4><p>关于搭建本地的 TCP DNS 服务，可以参考 <a href="https://cokebar.info/archives/1053">https://cokebar.info/archives/1053</a> 里的配置即可。</p><p>最后，在 DHCP/DNS 选项卡里填入 ChinaDNS 的地址如 127.0.0.1#1053，记得勾选 忽略解析文件选项就大功告成了。</p><p>本文主要参考了 <a href="https://cokebar.info/">https://cokebar.info/</a> 上的系列文章。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=390a7151d6bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>