Total Pageviews

Sunday, 22 December 2019

利用dns-dispatcher解决dns污染问题

在mac机器上。
git clone https://github.com/cathuhoo/dns-dispatcher  dns-dispatcher-by-cathuhoo
cd dns-dispatcher-by-cathuhoo
make
(会在当前目录下,生成可执行文件dns-dispatch)

nano dns-dispatch.config
(把daemonize的值改为no)
cat dns-dispatch.config
; This is a test configuration file

[main]

file_resolvers = resolvers.txt
file_policy = policy.txt
file_log = /var/log/dns-dispatch.log
file_pid = /var/run/dns-dispatch.pid

num_threads = 3

service_port = 53

#tcpservice_port = 53

daemonize = no

nano resolvers.txt
cat resolvers.txt
#secret|184.22.34.216|5300|5300|burst
#tsinghua|166.111.8.28|53
#ccert|202.112.57.6|53
#telecom|219.141.136.10
#cnnic|1.2.4.8
#google|8.8.8.8
#google2|8.8.4.4
#opendns|208.67.222.222
#opendns2|208.67.220.220
myvps|vps-ip|dnsmasq-port-number-on-vps
#dnsmasq|127.0.0.1|5353
#local_bind|127.0.0.1|5300
#locao_unbound|127.0.0.1|5303
#office|166.111.133.223|53
#cernet|101.7.8.9
#114|114.114.114.114

nano policy.txt
cat policy.txt
#blacklist_ip.txt| * | Drop
#* | youtube-domain.txt | Forward:dnsmasq
#* | blacklist_domain.txt| Forward:local_bind
#* | * | Forward:cernet
#* | * | Forward:opendns
* | * | Forward:myvps 
#* | * | Forward:tsinghua
#* | * | Forward:local_bind

然后,
sudo ./dns-dispatch -c dns-dispatch.config

项目地址:https://github.com/cathuhoo/dns-dispatcher

上面的vps-ip|dnsmasq-port-number-on-vps的意思请参见https://briteming.blogspot.com/2 019/12/vpsdnsmasq.html里的“在自己的vps上安装dnsmasq”部分。