ChinaDNS|无污染DNS|搭建属于自己的无污染DNS服务器

cera cera

前些日子买了阿里云的学生机,1M小水管用处不大,一直在吃灰,不如搭建一个无污染DNS

注意:当前GFW对部分网站(Steam社区、Pixiv、日亚等)实施了SNI封锁,即使无污染DNS也无法访问(本质上和hosts方法相同),建议使用梯子。

ChinaDNS

由clowwindy大佬开发,Github

初始环境

阿里云上海 ecs.n4.small (1C2G1M)

Ubuntu 16.04 x64 纯净系统

PS.机器必须位于墙内(过墙会被抢答,无法防污染)

开始搭建

下载源码并编译

wget --no-check-certificate  https://github.com/shadowsocks/ChinaDNS/releases/download/1.3.2/chinadns-1.3.2.tar.gz
tar -zxvf chinadns-1.3.2.tar.gz
cd chinadns-1.3.2
./configure && make

更新 CHNRouter

curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| '{ printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > chnroute.txt

启动ChinaDNS并测试

./src/chinadns -m -c chnroute.txt -s 119.29.29.29,208.67.220.222:443

这里采用的是国内DNSPod,国外OpenDNS,可以自行更改,注意国外DNS不能通过UDP53查询。
正常启动后不会输出任何信息,请使用nslookup或访问 http://tool.chinaz.com/dns/?type=1&host=steamcommunity.com&ip=VPS的IP地址 查看是否正确解析。

守护运行

安装与配置

apt-get install supervisor    #安装supervisor
echo_supervisord_conf > /etc/supervisord.conf
echo "[program:chinadns]
command=(运行ChinaDNS的指令,注意需要绝对路径,例如:/root/chinadns-1.3.2/src/chinadns -m -c chnroute.txt -s 119.29.29.29,208.67.220.222:443)
user = root
autostart = true
autorestart = true" >> /etc/supervisord.conf

使supervisor开机自启动,编辑 /etc/rc.local

vi /etc/rc.local

将 supervisord -c /etc/supervisord.conf 加入 exit 0 之前,编辑后的 rc.local 如下:


#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

supervisord -c /etc/supervisord.conf
exit 0
~
~
~
~

为rc.local增加权限

chmod +x /etc/rc.local

启动 supervisor

supervisord -c /etc/supervisord.conf

查看chinadns运行状态

supervisorctl status|grep "chinadns"

如果显示 RUNNING 即为成功,可以使用nslookup等方式确认是否正常运作。

cera cloudiplc tengxunyun

相关推荐

mjjping.com cera cera cloudiplc