# 在 Linux 下快速设置 DoH

- URL: https://www.9bingyin.com/archives/fast-doh-4-linux.html
- Date: 2022-10-09
- Updated: 2023-10-31
- Categories: Linux, DNS

突然发现 Linux 下没有一个很方便的快速设置 DoH 的方法，就参考了 [DNS.SB 的教程](https://dns.sb/doh/linux/)写了一个简单的脚本，已经开源在了 Github

https://github.com/9bingyin/Fast-DoH

这个脚本可以一键配置 DNSProxy 客户端使用常见的 DoH，如果需要自定义 DoH，可以先运行一次脚本并随便选择一个选项，等待执行完成后修改 `/etc/systemd/system/dnsproxy.service` 中的内容

```ini
[Unit]
Description=DNS Proxy Service
Documentation=https://github.com/9bingyin/Fast-DoH
After=network.target
Wants=
Requires=

[Service]
ExecStart=/usr/bin/dnsproxy -l 127.0.0.1 -p 53 -u 自定义 DoH 地址（如 https://223.5.5.5/dns-query）
ExecStop=
ExecReload=/usr/bin/dnsproxy -l 127.0.0.1 -p 53 -u 同上
Type=simple

[Install]
WantedBy=multi-user.target
```

然后重启服务即可

```bash
systemctl daemon-reload
systemctl restart dnsproxy
```

更多关于 DNSProxy 的用法可以查看 https://github.com/AdguardTeam/dnsproxy
