Setting up DNS over HTTPS using cloudflared

I thought this would be a simple task, and it was now that I'm looking back on it. However the cloudflare documentation isn't clear when deploying to a dedicated server/container. So here's how I did it.

Install

This section is going to walk you through installing the cloudflared client as a service. The documentation is a bit vague and shows you how to spin up the client but leaves out some important info regarding running it as a service.
  • Install the package, as root, for your OS here.
  • Create /etc/cloudflared/config.yml (see below for contents)
  • Run the client to generate the .pem certs.
    • `cloudflared proxy-dns`
    • The certs won't be put in `/etc/cloudflared` by default. Instead they can be found in roots home dir `/root/.cloudflared`.
    • Move the `cert.pem` to `/etc/cloudflared`.
  •  Now you can install the service
    • `cloudflared service install`
  • Ensure that the service enabled and running via systemctl.
    • `systemctl status cloudflared.service`

config.yml:

Yes this is a '.yml' file. The docs show a config.yaml when running the app, but the service has have a config.yml file. Also all configs need to be in `/etc/cloudflared/` not in `/usr/local/etc/..`. That is another dependency they don't really point out.

proxy-dns: true
proxy-dns-address: 0.0.0.0
proxy-dns-port: 53
proxy-dns-upstream:
  - https://1.1.1.1/dns-query
  - https://1.0.0.1/dns-query
loglevel: debug
logfile: /var/log/cloudflared/cloudflared.log
pidfile: /run/cloudflared.pid

Saltstack sls and configs necessary to automate everything above:

Download Here

References:

https://developers.cloudflare.com/1.1.1.1/dns-over-https/

Comments

Popular posts from this blog

pfSense DHCP: Dynamic DNS Updates to a Windows DNS server over a Site-to-Site VPN.

Python Flask: Web apps in seconds