Notes on Setting Up a Reliable VPN
Original Chinese title: 稳定翻墙小计
The Problem
- To me, the GFW used to just mean occasionally hopping over to take a look around—until a few days ago, when Dropbox suddenly got blocked too. As my main cloud storage tool, losing it basically brought my workflow to a halt. Without Dropbox, keeping files synced across multiple environments is a massive headache.
- I first considered domestic cloud drives. I have a Baidu Netdisk account, which I normally just use for movies and photos. I once tried putting my QQ chat history
.mscfiles on Baidu Cloud, only to discover its sync strategy can’t handle incremental updates properly: every single time I chatted with someone, it created a dated conflict file. By contrast, Dropbox’s incremental sync is awesome and handles it seamlessly. With Baidu Cloud, I’d have to turn off sync whenever QQ was open and manually sync everything after closing QQ. - That’s completely anti-human—and besides, I don’t really trust domestic cloud drives anyway—so I still wanted to stick with Dropbox.
- At first I tried routing Dropbox through GoAgent as a proxy, but it wouldn’t update, kept throwing errors, and GoAgent itself was getting more and more unstable.
- On Moonlight Blog I saw a workaround using OpenDNS. That actually did let Dropbox update, except changing the DNS on the campus network broke access to internal campus sites. Had to give up on that too.
- Finally, I went with an approach shared by some guru on Zhihu: buy an overseas VPS and set up a personal VPN once and for all. A junior labmate recommended DigitalOcean’s SSD VPS: $5/month for 512MB RAM, a 20GB SSD, and 1TB of bandwidth—more than enough for my needs. That’s the route I took.
DigitalOcean
- Nothing too tricky on this step. If you don’t have a foreign credit card, don’t enter your card info directly during sign-up—I have a dual-currency card, and it got rejected upon submission.
- Cleverly, I used my credit card to register a PayPal account instead, since DigitalOcean accepts PayPal. Payment went right through. When spinning up the droplet, just pick the lowest tier—the $5/month plan.
- For the OS, I picked CentOS 6.4 x64. Given the limited RAM, 32-bit probably would’ve been better, though since it’s only running a VPN, it doesn’t really matter.
Setting Up the VPN
- I went with a PPTP VPN. The main downside of this protocol is that one IP normally only supports a single connection, though most routers seem to handle this better—even my basic TP-Link router lets multiple devices connect to the VPN through one IP.
- I won’t paste a full tutorial here; a quick Google search brings up tons of guides. The main things to watch out for are the Linux firewall rules and packet forwarding settings.
Watch Out for ISP Quirks (Especially Certain Broadband Providers)
- When setting up a VPN on PPPoE (dial-up broadband), you might hit weird issues like losing internet completely the moment the VPN connects. After three days of troubleshooting and endless Googling and Baidu searches, we realized the ISP was tampering with the traffic. Here are two workarounds:
- Use CCProxy. This domestic tool is surprisingly solid and has been verified to work across different broadband ISPs.
- If you prefer sticking with a regular VPN, there’s another trick: install the VPN inside a virtual machine using NAT and shared networking to get past the ISP’s restrictions. Essentially, it disguises the VPN connection as a regular process from the host machine. So far, this completely bypasses the PPPoE limitation.
- Of course, you can also just use out-of-the-box solutions like OpenVPN.
That’s Pretty Much It~
遇到的问题
- GFW其实对我来说一直都是偶尔出去看一下,直到前几天突然发现dropbox也惨遭墙,作为自己云存储的主力。这让人有点无法工作。没有dropbox,多环境下同步确实是一个很头疼的问题。
- 首先考虑国内的网盘,有一个百度的网盘,但是一般都用来存一些film和pic文件,曾近尝试将qq聊天记录msc文件放在百度云盘上,竟然发现百度的同步策略无法做增,我每和人聊天一次,就会生成一个日期的冲突版本,反观dropbox的增策略很棒,完美识别。如果要用百度盘,则需要在qq开启的时候把同步关了,关了qq之后统一同步。
- 反人类啊,再加上我还是不太信任国内的网盘,所以我还是想着用dropbox
- 开始考虑的使用goagent做dropbox的代理,但是无奈更新不了,频频报错,而且goangent越来越不稳定。
- 在月光blog上看到用opendns的方式,确实能实现更新,但是改了校园网的dns,直接导致校园网内都上不了。无奈放弃。
- 最后考虑zhihu上的某个大神的做法,买一个国外的vps搭建一个个人的vpn,一劳永逸。由实验室的师弟推荐digital ocean 家的ssd vps。 一个月5刀。512 ram 20g ssd 1T流量。完全够用。最后采取这个方案。
digital ocean
- 这一步没啥注意的。注册的时候如果没有国外的信用卡,那就不要在注册的时候填写card信息了,我有一张双币卡,结果在commite之后不识别。
- 机智的我还是用信用卡注册了一个palpay。因为digital ocean是支持palpay的。顺利购买。创建的时候买个最低配置就是那个每个月5刀的。
- 配置的时候我选的是centos 6.4 x64 其实应该选32位的,因为ram有限,但是考虑只做一个vpn,也无所谓了。
VPN篇
- 用的是pptp协议的vpn,这个协议下最不好的是就一个ip只能做一个连接,但是貌似如果用了路由器都是做了优化。。我用的tp-link最简单的路由器就可以实现多台机器一个ip连接刀vpn
- 具体的教程就不贴了。网上google 一大把。几个注意点就是linux防火墙和转发策略。
尤其有一些运行商的东西(xx通)
- 搭建vpn的时候如果你用的是pppoe ,也就是拨号的话,会遇到一些奇怪的问题,例如开了vpn就断网的情况,我们在摸索了三天+无数google百度之后才发觉其实是运营商做了一些手脚。这里有两个解决方案提供。
- 使用ccproxy,这个国内的软件确实厉害,验证了各个运营商下的宽带都是可以用的。
- 如果你还是喜欢vpn的模式,我们也有一个解决思路,就是使用虚拟机,把vpn 架设在虚拟机里面,通过nat 和共享上网的思路也能骗过运营商,其实就是将vpn作为主机的一个进程。目前完美解决了pppoe的限制。
- 当然你也可以用openvpn这些现成的解决方案。