Pages

Wednesday, 1 January 2020

利用dnsocks-go解决dns污染问题(又一款可以套上一层socks proxy的dns代理程序)

首先fork此项目:https://github.com/zyfworks/dnsocks-go ,我fork后的地址为
https://github.com/luckypoem/dnsocks-go
你需要fork为你的地址,luckypoem替换为你的用户名

然后,在这里https://github.com/luckypoem/dnsocks-go/blob/master/config.json ,编辑配置文件config.json,我的config.json文件已经编辑为如下内容:
{
"listenAddress" : "0.0.0.0",
"listenPort" : "53",
"dnsAddress" : "8.8.8.8",
"dnsPort" : "53",
"proxyEnabled" : true,
"proxyAddress" : "127.0.0.1",
"proxyPort" : "1080"
}

然后,
git clone https://github.com/luckypoem/dnsocks-go dnsocks-go-by-luckypoem
cd dnsocks-go-by-luckypoem

go build
(会在当前目录下,生成可执行文件dnsocks-go-by-luckypoem)

sudo ./dnsocks-go-by-luckypoem
会显示:
─────I N F O R M A T I O N ─────
 Successfully read the config file

 SOCKS5 proxy enabled on 127.0.0.1:1080
 Remote DNS is 8.8.8.8:53

 DNS started listening at 0.0.0.0:53

因为配置文件config.json里面启用了socks代理,所以需要运行一个本地的socks proxy,比如ss客户端程序。


使用例子:
sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1

sudo wg-quick up wg0

sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1

cd ~/dnsocks-go-by-luckypoem && sudo ./dnsocks-go-by-luckypoem
(不要忘了运行一个本地的socks proxy,比如ss客户端程序)

dnsocks-go实际上是又一个可以套上一层socks proxy的dns代理程序。

项目地址:
https://github.com/zyfworks/dnsocks-go
https://github.com/luckypoem/dnsocks-go

相关帖子:https://briteming.blogspot.com/2019/07/dns-querysocks.html