Dragon
主机之家测评主机之家测评  2019-08-21 16:41 主机之家测评 隐藏边栏 |   抢沙发  708 
文章评分 0 次,平均分 0.0

无污染 dns 搭建:ChinaDNS 搭建无污染 DNS 教程

简介

什么叫无污染 DNS,这里按自己的理解说一下,我们一般访问网站,第一步是我们输入域名,例如输入 baidu.com,这个域名只是方便记忆的一种形式,网络访问其实都是要访问到具体的 IP,IP 就是存放网页的服务器地址,那么我们输入 baidu.com 的 IP 是多少呢,就是由 DNS 服务器告诉我们的。现在一些国外网站如谷歌访问不了,就是因为 DNS 服务器告诉了我们一个错误的 IP,这个 IP 要能根本就不存在,所以我们就访问不了我们需要访问的网站了,同时有一些 DNS 的服务商还会对你访问的网址进行劫持,例如,我们文章 taobao.com,服务商的系统检测到会自动加上他们淘宝客的推广网站,这样你买东西时候会给他产生这一些佣金,这样我们不轻意之间就别一些垃圾商家利用,所以今天介绍的就是自己搭建一个干净的污染 DNS。

准备工作

1、一台服务器或是 VPS(我用的是阿里云的 ECS)
2、安装 Ubuntu 16.04 x64 纯净系统
3、使用项目为 ChinaDNS 地址:GITHUB
注意:机器必须放在国内,否则是没有作用的。

搭建教程开始

下载脚本并编译

 

1
2
3
4
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

 

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

启动 ChinaDNS 并测试

 

1
./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 地址 查看是否正确解析

守护运行

安装与配置

 

1
2
3
4
5
6
7
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

 

1
vi /etc/rc.local

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

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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 增加权限

 

1
chmod +x /etc/rc.local

启动 supervisor

 

1
supervisord -c /etc/supervisord.conf

查看 chinadns 运行状态

 

1
supervisorctl status|grep "chinadns"

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

本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

发表评论

扫一扫二维码分享