Configure Ubuntu Pi-hole for Cloudflare DNS over HTTPS

Originally published at: https://www.cyberciti.biz/faq/configure-ubuntu-pi-hole-for-cloudflare-dns-over-https/

I installed OpenVPN VPN solutions on Ubuntu for my businesses to secure all data communications. I also set up Pin-hole ad blocker on Ubuntu server along with OpenVPN. How do I force Pi-hole to use Cloudflare DNS over HTTPS (DoH) to increase my privacy and security by preventing eavesdropping and manipulation of DNS data by man-in-the-middle attacks?

So, I have also setup pihole Using https via cloud flare. But After the user connect via OpenVPN, how do you set the client to point to PIHole DNS with OpenVPN? The openvpn tend to use google DNS.

1 Like

Edit openvpn config /etc/openvpn/server.conf on server.

vi /etc/openvpn/server.conf

Delete or comment out existing DNS entries:

##Stop using Google DNS for our OpenVPN###
#push "dhcp-option DNS 8.8.8.8"
#push "dhcp-option DNS 8.8.4.4"

Next add our PI-Hole DNS IP address i.e. OpenVPN DNS address:

push "dhcp-option DNS 10.8.0.1"

Save and close the file. Restart the OpenVPN server:

sudo systemctl restart openvpn@server

Read for more info (see section Update OpenVPN config to push our PI-hole dns server):

Once done. Test your DNS using any online service that shows your current DNS. It should now show cloudflare. For example (look for Cloudflare):

curl http://$RANDOM.dns.whatsmydnsserver.com/api

Hi Thank you for your instruction, I followed it up however I am experiencing some issues and was hoping you can help:

when I get to:
sudo systemctl enable cloudflared
sudo systemctl start cloudflared
echo $?
sudo systemctl status cloudflared
it seems like the first 3 command work but when I’m getting the status it says β€œActive: Inactive (dead)” and it seems to be right after the service was started. I’m not sure how to fix this. Please let me know if you have any idea of what’s happening. Thanks

@hooman64 welcome to nixCraft forum!

First, verify that all files created and path specified correctly as per tutorial. Second, Can you see the log for the service? It should give you some hint.

sudo systemctl status cloudflared
sudo journalctl -u cloudflared

@nixcraft, Thank you I was able to verify that I did all the steps based on the tutorial so far. I’m also able to enable and start cloudflared but when I get to the status point it seems like it’s killed within seconds.

here is the status:

● cloudflared.service - cloudflared DoH proxy
Loaded: loaded (/lib/systemd/system/cloudflared.service; enabled; vendor pres
Active: inactive (dead) since Tue 2019-04-16 21:33:26 PDT; 3 days ago
Main PID: 1590 (code=exited, status=0/SUCCESS)

Apr 16 21:33:26 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0

and the journal as you suggested:

– Logs begin at Sat 2018-03-24 22:00:11 PDT, end at Sat 2019-04-20 09:39:46 PDT
Apr 02 16:23:22 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 02 16:23:22 apollo-desktop cloudflared[16975]: time="2019-04-02T16:23:22-07:
Apr 02 16:23:22 apollo-desktop cloudflared[16975]: time="2019-04-02T16:23:22-07:
Apr 02 16:23:22 apollo-desktop cloudflared[16975]: time="2019-04-02T16:23:22-07:
Apr 02 16:23:22 apollo-desktop cloudflared[16975]: time="2019-04-02T16:23:22-07:
Apr 02 16:23:22 apollo-desktop cloudflared[16975]: time="2019-04-02T16:23:22-07:
Apr 02 16:25:55 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 02 16:25:55 apollo-desktop cloudflared[17023]: time="2019-04-02T16:25:55-07:
Apr 02 16:25:55 apollo-desktop cloudflared[17023]: time="2019-04-02T16:25:55-07:
Apr 02 16:25:55 apollo-desktop cloudflared[17023]: time="2019-04-02T16:25:55-07:
Apr 02 16:25:55 apollo-desktop cloudflared[17023]: time="2019-04-02T16:25:55-07:
Apr 02 16:25:55 apollo-desktop cloudflared[17023]: time="2019-04-02T16:25:55-07:
– Reboot –
Apr 02 17:49:34 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 02 17:49:34 apollo-desktop cloudflared[1532]: time="2019-04-02T17:49:34-07:0
Apr 02 17:49:34 apollo-desktop cloudflared[1532]: time="2019-04-02T17:49:34-07:0
Apr 02 17:49:34 apollo-desktop cloudflared[1532]: time="2019-04-02T17:49:34-07:0
Apr 02 17:49:34 apollo-desktop cloudflared[1532]: time="2019-04-02T17:49:34-07:0
Apr 02 17:49:34 apollo-desktop cloudflared[1532]: time="2019-04-02T17:49:34-07:0
– Reboot –
Apr 02 18:20:07 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 02 18:20:07 apollo-desktop cloudflared[1631]: time="2019-04-02T18:20:07-07:0
Apr 02 18:20:07 apollo-desktop cloudflared[1631]: time="2019-04-02T18:20:07-07:0
Apr 02 18:20:07 apollo-desktop cloudflared[1631]: time="2019-04-02T18:20:07-07:0
Apr 02 18:20:07 apollo-desktop cloudflared[1631]: time="2019-04-02T18:20:07-07:0
– Reboot –
Apr 03 16:01:31 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 03 16:01:31 apollo-desktop cloudflared[1557]: time="2019-04-03T16:01:31-07:0
Apr 03 16:01:31 apollo-desktop cloudflared[1557]: time="2019-04-03T16:01:31-07:0
Apr 03 16:01:31 apollo-desktop cloudflared[1557]: time="2019-04-03T16:01:31-07:0
Apr 03 16:01:31 apollo-desktop cloudflared[1557]: time="2019-04-03T16:01:31-07:0
– Reboot –
Apr 03 16:27:37 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 03 16:27:37 apollo-desktop cloudflared[1624]: time="2019-04-03T16:27:37-07:0
Apr 03 16:27:37 apollo-desktop cloudflared[1624]: time="2019-04-03T16:27:37-07:0
Apr 03 16:27:37 apollo-desktop cloudflared[1624]: time="2019-04-03T16:27:37-07:0
Apr 03 16:27:37 apollo-desktop cloudflared[1624]: time="2019-04-03T16:27:37-07:0
Apr 03 16:27:37 apollo-desktop cloudflared[1624]: time="2019-04-03T16:27:37-07:0
Apr 04 09:42:01 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 04 09:42:01 apollo-desktop cloudflared[14993]: time="2019-04-04T09:42:01-07:
Apr 04 09:42:01 apollo-desktop cloudflared[14993]: time="2019-04-04T09:42:01-07:
Apr 04 09:42:01 apollo-desktop cloudflared[14993]: time="2019-04-04T09:42:01-07:
Apr 04 09:42:01 apollo-desktop cloudflared[14993]: time="2019-04-04T09:42:01-07:
Apr 04 09:42:01 apollo-desktop cloudflared[14993]: time="2019-04-04T09:42:01-07:
Apr 04 09:53:50 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 04 09:53:50 apollo-desktop cloudflared[15609]: time="2019-04-04T09:53:50-07:
Apr 04 09:53:50 apollo-desktop cloudflared[15609]: time="2019-04-04T09:53:50-07:
Apr 04 09:53:50 apollo-desktop cloudflared[15609]: time="2019-04-04T09:53:50-07:
Apr 04 09:53:50 apollo-desktop cloudflared[15609]: time="2019-04-04T09:53:50-07:
Apr 04 09:53:50 apollo-desktop cloudflared[15609]: time="2019-04-04T09:53:50-07:
– Reboot –
Apr 05 07:45:16 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 05 07:45:16 apollo-desktop cloudflared[1651]: time="2019-04-05T07:45:16-07:0
Apr 05 07:45:16 apollo-desktop cloudflared[1651]: time="2019-04-05T07:45:16-07:0
Apr 05 07:45:16 apollo-desktop cloudflared[1651]: time="2019-04-05T07:45:16-07:0
Apr 05 07:45:16 apollo-desktop cloudflared[1651]: time="2019-04-05T07:45:16-07:0
Apr 05 07:45:16 apollo-desktop cloudflared[1651]: time="2019-04-05T07:45:16-07:0
– Reboot –
Apr 05 08:58:56 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 05 08:58:56 apollo-desktop cloudflared[1629]: time="2019-04-05T08:58:56-07:0
Apr 05 08:58:56 apollo-desktop cloudflared[1629]: time="2019-04-05T08:58:56-07:0
Apr 05 08:58:56 apollo-desktop cloudflared[1629]: time="2019-04-05T08:58:56-07:0
Apr 05 08:58:56 apollo-desktop cloudflared[1629]: time="2019-04-05T08:58:56-07:0
Apr 05 08:58:56 apollo-desktop cloudflared[1629]: time="2019-04-05T08:58:56-07:0
– Reboot –
Apr 05 10:01:11 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 05 10:01:11 apollo-desktop cloudflared[1663]: time="2019-04-05T10:01:11-07:0
Apr 05 10:01:11 apollo-desktop cloudflared[1663]: time="2019-04-05T10:01:11-07:0
Apr 05 10:01:11 apollo-desktop cloudflared[1663]: time="2019-04-05T10:01:11-07:0
Apr 05 10:01:11 apollo-desktop cloudflared[1663]: time="2019-04-05T10:01:11-07:0
Apr 05 10:01:11 apollo-desktop cloudflared[1663]: time="2019-04-05T10:01:11-07:0
– Reboot –
Apr 05 10:03:46 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 05 10:03:46 apollo-desktop cloudflared[1617]: time="2019-04-05T10:03:46-07:0
Apr 05 10:03:46 apollo-desktop cloudflared[1617]: time="2019-04-05T10:03:46-07:0
Apr 05 10:03:46 apollo-desktop cloudflared[1617]: time="2019-04-05T10:03:46-07:0
Apr 05 10:03:46 apollo-desktop cloudflared[1617]: time="2019-04-05T10:03:46-07:0
– Reboot –
Apr 16 21:33:26 apollo-desktop systemd[1]: Started cloudflared DoH proxy.
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0
Apr 16 21:33:26 apollo-desktop cloudflared[1590]: time="2019-04-16T21:33:26-07:0

not sure if this is helpful or not?

@nixcraft, any chance you got to check the previous comment?