# How to install DoH client on Linux

We use dnsproxy (opens new window) from AdguardTeam as DoH Client on Linux system.

DNS Proxy is a simple DNS proxy server that supports all existing DNS protocols including DNS-over-TLS, DNS-over-HTTPS, DNSCrypt, and DNS-over-QUIC. Moreover, it can work as a DNS-over-HTTPS, DNS-over-TLS or DNS-over-QUIC server.

# 1. Install DNS Proxy

VERSION=$(curl -s https://api.github.com/repos/AdguardTeam/dnsproxy/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest AdguardTeam dnsproxy version is $VERSION"
wget -O dnsproxy.tar.gz "https://github.com/AdguardTeam/dnsproxy/releases/download/${VERSION}/dnsproxy-linux-amd64-${VERSION}.tar.gz"
tar -xzvf dnsproxy.tar.gz
cd linux-amd64
mv dnsproxy /usr/bin/dnsproxy

# 2. Connect DNS.SB DoH Server

dnsproxy -l -p 53 -u https://doh.dns.sb/dns-query -b

Now we can open another terminal to test DNS

root@dns ~ # dig example.com @

; <<>> DiG 9.16.15-Debian <<>> example.com @
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22295
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

; EDNS: version: 0, flags:; udp: 4096
;example.com.			IN	A

example.com.		1094	IN	A

;; Query time: 3 msec
;; WHEN: Fri Jul 02 13:07:43 UTC 2021
;; MSG SIZE  rcvd: 56

We can see the response server SERVER: is working fine.

# 3. Keep DNS Proxy running in background

We use Supervisor (opens new window):

apt install supervisor -y

Then create a config file

cat > /etc/supervisor/conf.d/dnsproxy.conf <<EOF
command = dnsproxy -l -p 53 -u https://doh.dns.sb/dns-query -b
user = root
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/dnsproxy.log
stderr_logfile = /var/log/supervisor/dnsproxy.error.log
environment = LANG="en_US.UTF-8"

Now let's restart Supervisor

systemctl restart supervisor

# 4. Change /etc/resolv.conf

We can use the same method like How to change DNS settings on Linux, open /etc/resolv.conf

vim /etc/resolv.conf

Replace the nameserver lines with


Save the file and it's working now.