To configure Pi-hole on Ubuntu to use Cloudflare DNS over HTTPS (DoH), you will need to modify the Pi-hole DNS settings and install the jq
utility.
jq
by running the following command:sudo apt-get install jq
sudo pihole -a setdns cloudflare "https://cloudflare-dns.com/dns-query"
This will set Cloudflare DNS as the primary DNS resolver for Pi-hole.
To enable DoH, you will need to obtain a Cloudflare API key. You can do this by visiting the Cloudflare dashboard and creating a new API key.
Once you have obtained an API key, you can use the following script to configure Pi-hole to use DoH:
#!/bin/bash # Set Cloudflare API key CLOUDFLARE_API_KEY=your_api_key # Set Cloudflare email address CLOUDFLARE_EMAIL=your_email@example.com # Set Cloudflare zone ID CLOUDFLARE_ZONE_ID=your_zone_id # Set Pi-hole URL PIHOLE_URL=http://localhost/admin/ # Set Pi-hole API password PIHOLE_API_PASSW