安装HomeBrew

HomeBrew官方推荐快速安装Homebrew

1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

安装cloudflared

用Homebrew快速安装cloudflared

1
brew install cloudflare/cloudflare/cloudflared

设置cloudflared

DNS服务节点地址:iQDNS

创建cloudflared配置文件:

1
2
mkdir -p /usr/local/etc/cloudflared
vim /usr/local/etc/cloudflared/config.yaml

粘贴以下内容:

1
2
3
4
5
6
7
proxy-dns: true
proxy-dns-upstream:
- https://a.passcloud.xyz/dns-query
- https://adh.avpclub.gq/dns-query
- https://dns.futa.gg/dns-query
- https://1.1.1.1/dns-query
- https://1.0.0.1/dns-query

保存退出。

启动cloudflared

1
sudo cloudflared service install

cloudflared Service 执行命令启动后,以后开机都会自动启动cloudflared DNS 服务器,会在本机监听port 53。

删除cloudflared

1
sudo cloudflared service uninstall

修改macOS系统网络设置

打开macOS的 「系统偏好设置」,依次找到「网络」->「高级」->「DNS」,在DNS服务器填入 本机IP127.0.0.1即可。

Reference

如何在 macOS 使用 DNS over Https(DoH)