Skip to content

Add omarchy-setup-cloudflare-dns script - #752

Merged
dhh merged 11 commits into
omacom:devfrom
jardahrazdera:add-dns-setup-script
Aug 24, 2025
Merged

dhh merged 11 commits into
omacom:devfrom
jardahrazdera:add-dns-setup-script

Conversation

@jardahrazdera

@jardahrazdera jardahrazdera commented Aug 13, 2025 •

Copy link
Copy Markdown
Contributor

Addresses issue #745 by providing user choice for DNS configuration.

Features:

  • Makes Cloudflare DNS opt-in instead of forced default
  • Preserves local development environments with DHCP option
  • Includes custom DNS configuration support
  • DNS over TLS support for enhanced security
  • Simplified implementation (58 lines) per review feedback
  • Follows Omarchy naming conventions

Fixes #745

Addresses issue omacom#745 by providing user choice for DNS configuration.

Features:
- Makes Cloudflare DNS opt-in instead of forced default
- Preserves local development environments with DHCP option
- Includes custom DNS configuration support
- Provides backup/restore functionality
- Follows Omarchy naming conventions

Fixes omacom#745
Comment thread install/config/config.sh Resolved
Comment thread migrations/1755100736.sh Resolved
Comment thread bin/omarchy-setup-cloudflare-dns Resolved
Comment thread bin/omarchy-setup-cloudflare-dns Resolved
Changes based on maintainer review:
- Rename script to omarchy-setup-dns (more generic name)
- Remove /usr/local/bin installation (use PATH instead)
- Add migration to reset automatic Cloudflare DNS to DHCP
- Force DNS on physical interfaces only using systemd-networkd
- Exclude docker/virtual interfaces from forced DNS

Fixes local development environment issues while making Cloudflare DNS opt-in.
Comment thread migrations/1755109182.sh Resolved
Follow Omarchy backup standards by using timestamped backup files
instead of fixed names. Remove restore function since backups now
have unpredictable names - users can manually restore if needed.

This matches the pattern used in omarchy-refresh-config.
@jdambron

Copy link
Copy Markdown

We could consider using DNS over TLS for the Cloudflare configuration as I suggested in #696 (my PR will become obsolete with this one).
It adds security and privacy and is natively supported by systemd-resolved.
With the DNSOverTLS=opportunistic configuration, it will rollback to unencrypted DNS if the server does not support it.
https://wiki.archlinux.org/title/Systemd-resolved#DNS_over_TLS: security by default without blocking anything.

Enable opportunistic DNS over TLS when using Cloudflare DNS. This
encrypts DNS queries when possible while falling back to regular DNS
if TLS isn't available, providing security without breaking compatibility.

Thanks to the suggestion in omacom#696 for highlighting this improvement.
@jardahrazdera

Copy link
Copy Markdown
Contributor Author

We could consider using DNS over TLS for the Cloudflare configuration as I suggested in #696 (my PR will become obsolete with this one). It adds security and privacy and is natively supported by systemd-resolved. With the DNSOverTLS=opportunistic configuration, it will rollback to unencrypted DNS if the server does not support it. https://wiki.archlinux.org/title/Systemd-resolved#DNS_over_TLS: security by default without blocking anything.

Great suggestion! I've just added DNS over TLS support to the script.

The implementation:

  • Uses DNSOverTLS=opportunistic for Cloudflare configuration
  • Encrypts DNS queries when possible, falls back to regular DNS if needed
  • No breaking changes - everything remains compatible
  • DHCP mode explicitly disables it to ensure local development DNS works properly

Your PR #696 helped inform this implementation. The new omarchy-setup-dns script now provides both the flexibility to choose DNS providers AND the security
benefits of DNS over TLS when using Cloudflare.

Thanks for the excellent suggestion. This makes the solution more complete and secure by default!

The DNS servers now include their proper hostnames for certificate
validation (cloudflare-dns.com and dns.google). This ensures we're
actually talking to the real DNS servers when using encrypted DNS,
not some imposter.

Completes the implementation suggested in omacom#696.
@jardahrazdera

jardahrazdera commented Aug 15, 2025 •

Copy link
Copy Markdown
Contributor Author

@jdambron I've incorporated DNS over TLS with certificate validation into this PR.

The implementation now includes:

  • DNSOverTLS=opportunistic - encrypts when possible, falls back gracefully
  • Certificate validation using proper hostnames (cloudflare-dns.com, dns.google)
  • Secondary resolvers for both providers

Your PR #696 can indeed be closed as this implementation covers the same security improvements. The new omarchy-setup-dns script makes it easy for users to choose between secure Cloudflare DNS or local DHCP for development.

It's good to see you are pushing for better security by default! I like this aproach personaly.

We'll see what @dhh has to say about it :)

Clean up old backup files before creating new ones to prevent the
accumulation of .bak.* files over time. Keeps only the most recent
backup while maintaining the timestamped naming pattern.

This ensures the system doesn't get cluttered with countless backup
files from repeated script runs.
Comment thread bin/omarchy-setup-dns

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhh I decided to modify the script so that backup files don't accumulate unnecessarily. Which I think is reasonable. If you have any other comments, let me know. Thanks.

dhh added a commit that referenced this pull request Aug 22, 2025
@dhh

dhh commented Aug 22, 2025

Copy link
Copy Markdown
Contributor

I like where this is going, but I need to review it more closely. It's a big implementation. I think we can get away with something significantly smaller. But I've removed forcing DNS changes on everyone for new installs for now.

dhh added a commit to ryanrhughes/omarchy that referenced this pull request Aug 22, 2025
Reduced script complexity from 227 to 58 lines while maintaining core functionality.
Removed unnecessary backup system and systemd-networkd configuration.
Kept essential features: Cloudflare DNS with TLS, DHCP mode, and custom DNS option.
Script now follows established Omarchy conventions for simplicity and size.
@jardahrazdera

Copy link
Copy Markdown
Contributor Author

I like where this is going, but I need to review it more closely. It's a big implementation. I think we can get away with something significantly smaller. But I've removed forcing DNS changes on everyone for new installs for now.

@dhh You were right about the size - got it down to 58 lines from 227.
Stripped out all the backup machinery and systemd-networkd complexity. It's now just a straightforward switch between cloudflare, dhcp, and custom DNS. Still kept DNS over TLS since that security comes essentially for free with systemd-resolved. Should be much cleaner to review now.

@dhh

dhh commented Aug 24, 2025

Copy link
Copy Markdown
Contributor

Ohhh, much nicer! Thanks for this. Big improvement.

@dhh
dhh changed the base branch from master to dev August 24, 2025 11:01
@dhh
dhh merged commit c4b32c0 into omacom:dev Aug 24, 2025
@dhh

dhh commented Aug 24, 2025

Copy link
Copy Markdown
Contributor

Next step with this is to ensure that all the primary interfaces actually use this setup! Need to ensure that wlan0 and whatever is the non-docker, non-loop ethernet interfaces all respect this. Want to tackle that next?

@jardahrazdera

Copy link
Copy Markdown
Contributor Author

Next step with this is to ensure that all the primary interfaces actually use this setup! Need to ensure that wlan0 and whatever is the non-docker, non-loop ethernet interfaces all respect this. Want to tackle that next?

Yeah, I'll work on that.

@euandeas

Copy link
Copy Markdown

Is there a reason we define the FallbackDNS over using systemd-resolved defaults? (Cloudflare -> Quad9 -> Google) The defaults seem very sensible anyway, and may simplify things a small bit.

@jardahrazdera

Copy link
Copy Markdown
Contributor Author

@euandeas Good question! I chose to include explicit FallbackDNS for two reasons:

  1. Consistency - When users choose Cloudflare, they get a fully Cloudflare-based solution with Google as fallback. This makes the behavior predictable and aligned with their choice.

  2. Transparency - Users can see exactly what DNS servers will be used by looking at the script, without needing to know systemd-resolved defaults (which could change between versions).

I think keeping explicit control over fallback servers fits with Omarchy's philosophy of being intentional about system configuration rather than relying on implicit defaults.

@euandeas

Copy link
Copy Markdown

Makes sense, especially transparency wise. My only thought is that if you are choosing Cloudflare as your DNS of choice, this is likely for the privacy benefits over Google (this may just be my perspective though!), I would then much rather have Quad9 as the default fallback than Google.

@jardahrazdera

Copy link
Copy Markdown
Contributor Author

@euandeas That's an excellent point about privacy! You're absolutely right. Users choosing Cloudflare over Google likely value privacy, so falling back to Google defeats that purpose.

Using Quad9 (9.9.9.9) as fallback would indeed be more consistent with the privacy focused choice. Let me see what @dhh thinks about this. If he agrees, I can update the fallback to use Quad9 instead of Google.

@jardahrazdera

Copy link
Copy Markdown
Contributor Author

@dhh Done! Network interfaces now properly respect the DNS configuration as you requested. The script configures wlan0 and ethernet interfaces while leaving docker/loop interfaces untouched.

jardahrazdera added a commit to jardahrazdera/omarchy that referenced this pull request Aug 24, 2025
Replace Google DNS fallback with Quad9 (9.9.9.9, 149.112.112.112)
for better privacy consistency. Users choosing Cloudflare likely
value privacy, so Quad9 is a more appropriate fallback than Google.

As discussed in omacom#752 and approved by @dhh in omacom#1043.
dhh pushed a commit that referenced this pull request Aug 24, 2025
Replace Google DNS fallback with Quad9 (9.9.9.9, 149.112.112.112)
for better privacy consistency. Users choosing Cloudflare likely
value privacy, so Quad9 is a more appropriate fallback than Google.

As discussed in #752 and approved by @dhh in #1043.
OmarSkalli pushed a commit to OmarSkalli/omarchy that referenced this pull request Aug 26, 2025
OmarSkalli pushed a commit to OmarSkalli/omarchy that referenced this pull request Aug 26, 2025
* Add omarchy-setup-cloudflare-dns script

Addresses issue omacom#745 by providing user choice for DNS configuration.

Features:
- Makes Cloudflare DNS opt-in instead of forced default
- Preserves local development environments with DHCP option
- Includes custom DNS configuration support
- Provides backup/restore functionality
- Follows Omarchy naming conventions

Fixes omacom#745

* Address DHH feedback on DNS configuration script

Changes based on maintainer review:
- Rename script to omarchy-setup-dns (more generic name)
- Remove /usr/local/bin installation (use PATH instead)
- Add migration to reset automatic Cloudflare DNS to DHCP
- Force DNS on physical interfaces only using systemd-networkd
- Exclude docker/virtual interfaces from forced DNS

Fixes local development environment issues while making Cloudflare DNS opt-in.

* Use timestamped backups and remove restore function

Follow Omarchy backup standards by using timestamped backup files
instead of fixed names. Remove restore function since backups now
have unpredictable names - users can manually restore if needed.

This matches the pattern used in omarchy-refresh-config.

* Add DNS over TLS support for enhanced security

Enable opportunistic DNS over TLS when using Cloudflare DNS. This
encrypts DNS queries when possible while falling back to regular DNS
if TLS isn't available, providing security without breaking compatibility.

Thanks to the suggestion in omacom#696 for highlighting this improvement.

* Add certificate validation for DNS over TLS

The DNS servers now include their proper hostnames for certificate
validation (cloudflare-dns.com and dns.google). This ensures we're
actually talking to the real DNS servers when using encrypted DNS,
not some imposter.

Completes the implementation suggested in omacom#696.

* Prevent backup file accumulation

Clean up old backup files before creating new ones to prevent the
accumulation of .bak.* files over time. Keeps only the most recent
backup while maintaining the timestamped naming pattern.

This ensures the system doesn't get cluttered with countless backup
files from repeated script runs.

* Simplify DNS setup script per review feedback

Reduced script complexity from 227 to 58 lines while maintaining core functionality.
Removed unnecessary backup system and systemd-networkd configuration.
Kept essential features: Cloudflare DNS with TLS, DHCP mode, and custom DNS option.
Script now follows established Omarchy conventions for simplicity and size.

* Allow setup from omarchy-menu

* Integrate into Omarchy Menu

* Align parameter

---------

Co-authored-by: David Heinemeier Hansson <[email protected]>
OmarSkalli pushed a commit to OmarSkalli/omarchy that referenced this pull request Aug 26, 2025
Replace Google DNS fallback with Quad9 (9.9.9.9, 149.112.112.112)
for better privacy consistency. Users choosing Cloudflare likely
value privacy, so Quad9 is a more appropriate fallback than Google.

As discussed in omacom#752 and approved by @dhh in omacom#1043.
jakeprime pushed a commit to jakeprime/omarchy that referenced this pull request Aug 26, 2025
jakeprime pushed a commit to jakeprime/omarchy that referenced this pull request Aug 26, 2025
* Add omarchy-setup-cloudflare-dns script

Addresses issue omacom#745 by providing user choice for DNS configuration.

Features:
- Makes Cloudflare DNS opt-in instead of forced default
- Preserves local development environments with DHCP option
- Includes custom DNS configuration support
- Provides backup/restore functionality
- Follows Omarchy naming conventions

Fixes omacom#745

* Address DHH feedback on DNS configuration script

Changes based on maintainer review:
- Rename script to omarchy-setup-dns (more generic name)
- Remove /usr/local/bin installation (use PATH instead)
- Add migration to reset automatic Cloudflare DNS to DHCP
- Force DNS on physical interfaces only using systemd-networkd
- Exclude docker/virtual interfaces from forced DNS

Fixes local development environment issues while making Cloudflare DNS opt-in.

* Use timestamped backups and remove restore function

Follow Omarchy backup standards by using timestamped backup files
instead of fixed names. Remove restore function since backups now
have unpredictable names - users can manually restore if needed.

This matches the pattern used in omarchy-refresh-config.

* Add DNS over TLS support for enhanced security

Enable opportunistic DNS over TLS when using Cloudflare DNS. This
encrypts DNS queries when possible while falling back to regular DNS
if TLS isn't available, providing security without breaking compatibility.

Thanks to the suggestion in omacom#696 for highlighting this improvement.

* Add certificate validation for DNS over TLS

The DNS servers now include their proper hostnames for certificate
validation (cloudflare-dns.com and dns.google). This ensures we're
actually talking to the real DNS servers when using encrypted DNS,
not some imposter.

Completes the implementation suggested in omacom#696.

* Prevent backup file accumulation

Clean up old backup files before creating new ones to prevent the
accumulation of .bak.* files over time. Keeps only the most recent
backup while maintaining the timestamped naming pattern.

This ensures the system doesn't get cluttered with countless backup
files from repeated script runs.

* Simplify DNS setup script per review feedback

Reduced script complexity from 227 to 58 lines while maintaining core functionality.
Removed unnecessary backup system and systemd-networkd configuration.
Kept essential features: Cloudflare DNS with TLS, DHCP mode, and custom DNS option.
Script now follows established Omarchy conventions for simplicity and size.

* Allow setup from omarchy-menu

* Integrate into Omarchy Menu

* Align parameter

---------

Co-authored-by: David Heinemeier Hansson <[email protected]>
jakeprime pushed a commit to jakeprime/omarchy that referenced this pull request Aug 26, 2025
Replace Google DNS fallback with Quad9 (9.9.9.9, 149.112.112.112)
for better privacy consistency. Users choosing Cloudflare likely
value privacy, so Quad9 is a more appropriate fallback than Google.

As discussed in omacom#752 and approved by @dhh in omacom#1043.
gocs pushed a commit to gocs/omarchy that referenced this pull request Aug 28, 2025
gocs pushed a commit to gocs/omarchy that referenced this pull request Aug 28, 2025
* Add omarchy-setup-cloudflare-dns script

Addresses issue omacom#745 by providing user choice for DNS configuration.

Features:
- Makes Cloudflare DNS opt-in instead of forced default
- Preserves local development environments with DHCP option
- Includes custom DNS configuration support
- Provides backup/restore functionality
- Follows Omarchy naming conventions

Fixes omacom#745

* Address DHH feedback on DNS configuration script

Changes based on maintainer review:
- Rename script to omarchy-setup-dns (more generic name)
- Remove /usr/local/bin installation (use PATH instead)
- Add migration to reset automatic Cloudflare DNS to DHCP
- Force DNS on physical interfaces only using systemd-networkd
- Exclude docker/virtual interfaces from forced DNS

Fixes local development environment issues while making Cloudflare DNS opt-in.

* Use timestamped backups and remove restore function

Follow Omarchy backup standards by using timestamped backup files
instead of fixed names. Remove restore function since backups now
have unpredictable names - users can manually restore if needed.

This matches the pattern used in omarchy-refresh-config.

* Add DNS over TLS support for enhanced security

Enable opportunistic DNS over TLS when using Cloudflare DNS. This
encrypts DNS queries when possible while falling back to regular DNS
if TLS isn't available, providing security without breaking compatibility.

Thanks to the suggestion in omacom#696 for highlighting this improvement.

* Add certificate validation for DNS over TLS

The DNS servers now include their proper hostnames for certificate
validation (cloudflare-dns.com and dns.google). This ensures we're
actually talking to the real DNS servers when using encrypted DNS,
not some imposter.

Completes the implementation suggested in omacom#696.

* Prevent backup file accumulation

Clean up old backup files before creating new ones to prevent the
accumulation of .bak.* files over time. Keeps only the most recent
backup while maintaining the timestamped naming pattern.

This ensures the system doesn't get cluttered with countless backup
files from repeated script runs.

* Simplify DNS setup script per review feedback

Reduced script complexity from 227 to 58 lines while maintaining core functionality.
Removed unnecessary backup system and systemd-networkd configuration.
Kept essential features: Cloudflare DNS with TLS, DHCP mode, and custom DNS option.
Script now follows established Omarchy conventions for simplicity and size.

* Allow setup from omarchy-menu

* Integrate into Omarchy Menu

* Align parameter

---------

Co-authored-by: David Heinemeier Hansson <[email protected]>
gocs pushed a commit to gocs/omarchy that referenced this pull request Aug 28, 2025
Replace Google DNS fallback with Quad9 (9.9.9.9, 149.112.112.112)
for better privacy consistency. Users choosing Cloudflare likely
value privacy, so Quad9 is a more appropriate fallback than Google.

As discussed in omacom#752 and approved by @dhh in omacom#1043.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DNS Configuration Issue

4 participants