使用dnscrypt-proxy搭建dns代理服务器(doh、dot)
系统环境 |
centos7.9 |
# 更改yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
# 把dnscrypt-proxy源码包上传到服务器
tar zxf dnscrypt-proxy-linux_x86_64-2.1.1.tar.gz
cd linux-x86_64/
cp example-dnscrypt-proxy.toml dnscrypt-proxy.toml
vi dnscrypt-proxy.toml
# 修改监听地址、服务器名称'dnspod-doh','alidns-doh'分别是腾讯和阿里的doh
listen_addresses = [0.0.0.0:53]
server_names = ['dnspod-doh','alidns-doh']
# 安装、启动dnscrypt-proxy服务
./dnscrypt-proxy -service install
./dnscrypt-proxy -service start
# 查看状态及开启自启
systemctl status dnscrypt-proxy
systemctl enable dnscrypt-proxy
# 查看dns服务是否正常
yum install bind-utils -y
nslookup www.baidu.com
./dnscrypt-proxy -resolve github.com
# 防火墙设置
firewall-cmd --zone=public --add-port=53/tcp --permanent
firewall-cmd --zone=public --add-port=53/udp --permanent
firewall-cmd --reload
# 自定义资源设置 https://dnscrypt.info/stamps/
# 修改 dnscrypt-proxy.toml文件,添加360-doh
server_names = ['dnspod-doh','alidns-doh','360-doh']
[static]
# [static.myserver]
# stamp = 'sdns://AQcAAAAAAAAAAAAQMi5kbnNjcnlwdC1jZXJ0Lg'
# https://dnscrypt.info/stamps/
[static.360-doh]
stamp = 'sdns://AgAAAAAAAAAADDExMi42NS42OS4xNQAKZG9oLjM2MC5jbgovZG5zLXF1ZXJ5'
企业内使用按需修改,如果有域控服务器,可以把转发器设置到代理服务器
max_clients = 250
###########################
# DNS cache #
###########################
## Enable a DNS cache to reduce latency and outgoing traffic
cache = true
## Cache size
cache_size = 4096
## Minimum TTL for cached entries
cache_min_ttl = 2400
## Maximum TTL for cached entries
cache_max_ttl = 86400
## Minimum TTL for negatively cached entries
cache_neg_min_ttl = 60
## Maximum TTL for negatively cached entries
cache_neg_max_ttl = 600