架设dnscrypt和unbound

架设dnscryptunbound

DNS 污染还是很严重(也只有这儿,所以就不写在github),自己架设一个DNS服务器,可以解决很多问题。

目前主要做法有如下几种:
-dnscrypt only
-dnsmasq only
-unbound only
-dnscrypt + dnsmasq
-dnscrypt + unbound

dnscrypt

如其名,就是把DNS请求加密,***再如何强大,目前也不可能破解。虽然很好安装,但还是走特殊协议和端口。不是很好用。
如何安装呢,只要下载如下软件

但其实最简单是下载Yandex浏览器 链接,霸气地直接内建DNSCrypt

Linux使用如下安装

$ sudo apt-get install dnscrypt-proxy

设置 /etc/dnscrypt-proxy/dnscrypt-proxy.conf 如下,标准DNS端口为53,但等会需要用于unbound,所以设置为5301

ResolverName cisco #最主要就这个
LocalAddress 127.0.0.1:5301 #设置DNScrypt port,这个在使用systemd系统无效

systemd系统需要修改 /lib/systemd/system/dnscrypt-proxy.socket

ListenStream=127.0.0.1:5301  #设置DNScrypt port
ListenDatagram=127.0.0.1:5301 #设置DNScrypt port

重启dnscrypt

$ sudo systemctl daemon-reload # 读取dnscrypt最新设置
$ sudo systemctl restart dnscrypt-proxy

dnsmasqunbound

合并介绍,都是用来快速架设DNS服务器和提供自定DNS列表,目前看不出有何差异。安装就比较复杂,等会只提供Linux安装方法。

dnscryptdnsmasq

只是同时用来解决两个问题,希望能不被污染的查询到IP,但又希望可以很方便做分流和缓存DNS历史。
如下使用Raspberry Pi(Debian)安装。

$ sudo apt-get install dnscrypt-proxy dnsmasq

当初看这文章设置,没什么需要特别修改,如下设置即可。

conf-dir=/etc/dnsmasq.d
no-resolv
no-poll
# 设置为DNScrypt服务器
server=127.0.0.1#5301
cache-size=1500

dnscryptunbound

用途和dnscrypt+dnsmasq相同,但网上说unbound比较稳定,这不予置评。
如下使用Raspberry Pi(Debian)安装。

$ sudo apt-get install dnscrypt-proxy unbound

当初是看这文章设置,但有些地方要调整,不然无法使用。
先拷贝设置到如下位置,Raspbianunbound架构有点不同,但大同小异。

$ sudo cp /usr/share/doc/unbound/examples/unbound.conf /etc/unbound/unbound.conf.d/

修改点设置

$ sudo vim /etc/unbound/unbound.conf.d/unbound.conf

修改点如下

num-threads: 4 #可以设置为CPU数量,cat /proc/cpuinfo取得
interface: 0.0.0.0 # 侦听所有 IPv4 地址
interface: ::0 # 侦听所有 IPv6 地址
so-rcvbuf: 4m
so-sndbuf: 4m
so-reuseport: yes
msg-cache-size: 64m
rrset-cache-size: 128m
cache-max-ttl: 3600
outgoing-num-tcp: 256
incoming-num-tcp: 1024
do-ip4: yes
do-ip6: yes
do-udp: yes
do-tcp: yes
tcp-upstream: no
access-control: 0.0.0.0/0 allow # 这个很重要,如果想分享给其他电脑,需要设置
root-hints: "/etc/unbound/root.hints" # 没有的话在 wget ftp://FTP.INTERNIC.NET/domain/named.cache 下载一份
hide-identity: yes
hide-version: yes
harden-glue: yes
unwanted-reply-threshold: 10000000
do-not-query-localhost: no
prefetch: yes
minimal-responses: yes
forward-zone:
    name: "."
    forward-addr: 127.0.0.1@5301 # 这是设置为用DNSCrypt查询

重启unbound

sudo systemctl restart dnscrypt-proxy unbound

其他电脑如果要使用架设的dns服务器,需要在网络手动设置DNS服务器。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值