Skip to content

resolved: add new "DNS Delegate" concepts - #34368

Merged
poettering merged 6 commits into
systemd:mainfrom
poettering:resolved-static-scopes
May 20, 2025
Merged

poettering merged 6 commits into
systemd:mainfrom
poettering:resolved-static-scopes

Conversation

@poettering

@poettering poettering commented Sep 11, 2024 •

Copy link
Copy Markdown
Member

Various long standing issues (at least: #5573 #14159 #20485 #21260 #24532 #32022 #18056) have been asking for a way to delegate DNS resolution of specific domains to very specific DNS servers.

This PR goes a major step towards that goal by adding a new concept "DNS Delegate" which allows to configure just that. Basically, this adds a third kind of DNS scope to resolved's logic: besides the per-link and global DNS scopes there are now also "delegate" scopes, which can be created by dropping in a new file /etc/systemd/dns-delegate/*.conf. They carry DNS= and Domains= lines just like the global setting or what the per-link configuration can carry.

And they are consulted the same way as link DNS scopes are considered, following the same routing rules.

This allows to configure these DNS delegates statically via drop-in files as mentioned, and only adds the most basic functionality. Later on we might want to extend this:

  1. Allow dynamic creation of DNS delegates via IPC with lifecycle bound to IPC client (usecase: installing a DNS delegate that routes traffic to some DNS-over-TLS server once basic setup is complete).
  2. Allow configuration of protocol details per delegate the same way this is currently allowed per-link.
  3. Instead of strictly using DNS as delegation protocol, support an alternative varlink based protocol (without retransmission problems and so on) that systemd-machined and similar can implement.

This PR is not complete yet. Lacks docs and tests. Seems to work fine in my local tests however.

Fixes: #5573
Fixes: #18056
Fixes: #20485

@poettering

Copy link
Copy Markdown
Member Author

This is complete now, now contains a simple integration test

@poettering poettering added this to the v258 milestone May 9, 2025
@poettering
poettering force-pushed the resolved-static-scopes branch 2 times, most recently from 4a1fd82 to dc74b43 Compare May 13, 2025 12:56
Comment thread src/resolve/resolved-dns-delegate-bus.h Resolved
Comment thread src/resolve/resolved-dns-delegate.h Resolved
@poettering
poettering force-pushed the resolved-static-scopes branch from dc74b43 to 1c1dfda Compare May 13, 2025 20:15
rsmarples added a commit to NetworkConfiguration/openresolv that referenced this pull request May 13, 2025
Set the defaults dirs directly as they are pretty much
hard-coded in systemd itself.

Write out DNS delegates so that when
systemd/systemd#34368
is merged into a release we support it out of the box.
Comment thread man/systemd.dns-delegate.xml Resolved
@poettering
poettering force-pushed the resolved-static-scopes branch from 1c1dfda to 20e9a3a Compare May 16, 2025 10:31

@daandemeyer daandemeyer left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, just minor nits

Can you add more information to the commit message introducing delegates though? Just links to github issues isn't great.

Comment thread src/resolve/resolved-dns-scope.c Resolved
Comment thread src/resolve/resolved-dns-scope.c Resolved
Comment thread man/org.freedesktop.resolve1.xml Resolved
Comment thread src/resolve/resolved-bus.c Resolved
Comment thread src/resolve/meson.build Resolved
Comment thread src/resolve/resolved-dns-delegate.c Resolved
Comment thread src/resolve/resolved-dns-scope.c Resolved
Comment thread src/resolve/resolved-dns-server.c Resolved
Comment thread src/resolve/resolved-dns-server.c Resolved
Comment thread src/resolve/resolvectl.c Resolved
@daandemeyer daandemeyer added good-to-merge/with-minor-suggestions ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR and removed please-review PR is ready for (re-)review by a maintainer labels May 20, 2025
@poettering

Copy link
Copy Markdown
Member Author

@daandemeyer any reason you set the "ci-fails" label? can't find any ci that failed related to any resolved issue?

@daandemeyer

Copy link
Copy Markdown
Collaborator

@daandemeyer any reason you set the "ci-fails" label? can't find any ci that failed related to any resolved issue?

I saw a lot of red so I figured it wasn't flakyness, ignore the label

… DnsScope explicitly

This new enum field is supposed to indicate why a DnsScope came to be.
For now it distinguishes two origins: the "global" one (which is what is
configured in resolved.conf) and "link" ones (which are synthesized for
each link).

The field as is is pretty redundant, the same information can be
determined from whether the .link field is set or not.

This is pretty much just preparation for later commits that add
statically configured additional DnsScopes whose origin shall be encoded
with this.
…specific DNS servers

This permits configuration of additional "delegates" which ensure that
lookups for certain DNS zones are routed to specific sets of DNS
servers, in addition to the routes we create for each network interface.

For now, this allows only static configuration, but eventually we should
open this up to IPC.

Fixes: systemd#5573 systemd#14159 systemd#20485 systemd#21260 systemd#24532 systemd#32022

(Fixes systemd#32022, because now redundant)
Let's handle the per-link and the global dns server/search domain
property parsing the same. Let's use a flags field for three separate
booleans, and unify more code.
@poettering
poettering force-pushed the resolved-static-scopes branch from 20e9a3a to 88d2cb3 Compare May 20, 2025 21:12
@github-actions github-actions Bot removed the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label May 20, 2025
@poettering poettering added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/with-minor-suggestions labels May 20, 2025
@poettering
poettering merged commit 81a1f8e into systemd:main May 20, 2025
@github-actions github-actions Bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label May 20, 2025
bluca added a commit to bluca/systemd-suse that referenced this pull request May 21, 2025
g7 pushed a commit to droidian/systemd that referenced this pull request Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants