使用cloudflare的dns over https(DOH)服务以应对dns劫持

使用cloudflare开源程序:https://github.com/cloudflare/cloudflared

环境为 Ubuntu20.04


下载和安装cloudflared

访问 https://github.com/cloudflare/cloudflared/releases

下载符合您系统版本的安装包

以 Ubuntu20.04为例

wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb

dpkg -i cloudflared-linux-amd64.deb

通过输入以下命令验证程序是否已正确安装:

cloudflared --version

将cloudflared作为服务运行

tee /etc/systemd/system/cloudflared-proxy-dns.service >/dev/null <<EOF
[Unit]
Description=DNS over HTTPS (DoH) proxy client
Wants=network-online.target nss-lookup.target
Before=nss-lookup.target
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
DynamicUser=yes
ExecStart=/usr/local/bin/cloudflared proxy-dns
[Install]
WantedBy=multi-user.target
EOF
systemctl enable --now cloudflared-proxy-dns
更改DNS
rm -f /etc/resolv.conf
echo nameserver 127.0.0.1 | sudo tee /etc/resolv.conf >/dev/null

 

 

未经允许不得转载:VPSBOOM!!! » 使用cloudflare的dns over https(DOH)服务以应对dns劫持

赞 (6)

评论