DEV Community

Mehdi mFat
Mehdi mFat

Posted on

2

How to encrypt DNS requests using cloudflared

cloudflared has many functions. When it comes to DNS, it can work as an encrypted DNS proxy. By default it listens for DNS requests and forwards them to Cloudflare DNS server over HTTPS.

But cloudflared can work with any upstream DoH server, including your self-hosted servers.

Let's for example see how to forward DNS queries to Google's encrypted DNS server using cloudflared:

cloudflared proxy-dns --upstream https://dns.google/dns-query --port 53
Enter fullscreen mode Exit fullscreen mode

This command tells cloudflared to listen on local port 53 (127.0.0.1:53) for DNS queries. It then encrypts and forwards DNS requests to https://dns.google/dns-query.

To use this system-wide, you need to either set 127.0.0.1:53 as your default DNS resolver or make your system resolver forward DNS queries to 127.0.0.1:53.

Most modern linux distributions use systemd-resolved as their main resolver. In my other tutorial I have explained how you can make systemd-resolved forward DNS requests to any other resolver.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (2)

Collapse
 
emmysteven profile image
Emmy Steven •

Great post, there is a lot of room for improvement, try to make your post longer.

Collapse
 
mfat profile image
Mehdi mFat •

Thanks for your feedback, Emmy. I’ll try to make it longer and add more detail.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more