Skip to content

feat(apple): pass-through search domain to VPN resolver config - #8421

Merged
thomaseizinger merged 3 commits into
mainfrom
feat/apply-search-domain-network-settings
Mar 13, 2025
Merged

feat(apple): pass-through search domain to VPN resolver config#8421
thomaseizinger merged 3 commits into
mainfrom
feat/apply-search-domain-network-settings

Conversation

@thomaseizinger

Copy link
Copy Markdown
Member

In order to have the system expand search domains for us, we need to set a very peculiar combination of configuration options in the NEDNSSettings of the VPN configuration:

  • We need to include our search domains in the list of matchDomains
  • We need to set matchDomainsNoSearch = false
  • We need to set the searchDomains field

Technically, we don't even need to set searchDomains by itself. Reading the docs in more detail for the matchDomainsNoSearch flag explains why:

A Boolean that specifies if the domains in the matchDomains list should not be appended to the resolver’s list of search domains.

The double-negative here is confusing but essentially, what this says is:

If false, append the list of match domains to the resolver's search domains.

That is exactly what we want. We want a search domain of e.g. example.com to append to the list of search domains for the primary resolver of non-scoped DNS queries.

I tested without setting searchDomains and it does still work: The system will still expand the domain for us und send us a FQDN query of e.g. foo.example.com. However, I figured not setting searchDomains at all is quite confusing so I left it in there.

Related: #8410 (Fixes it for MacOS)

@thomaseizinger
thomaseizinger requested a review from jamilbk March 13, 2025 00:47
@vercel

vercel Bot commented Mar 13, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 13, 2025 3:11am

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jamilbk jamilbk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Whoops missed a couple semicolons

Comment thread swift/apple/FirezoneNetworkExtension/NetworkSettings.swift Outdated
Comment thread swift/apple/FirezoneNetworkExtension/NetworkSettings.swift Outdated
thomaseizinger and others added 2 commits March 13, 2025 14:03
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
Signed-off-by: Thomas Eizinger <thomas@eizinger.io>
@thomaseizinger
thomaseizinger added this pull request to the merge queue Mar 13, 2025
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 13, 2025
@thomaseizinger
thomaseizinger added this pull request to the merge queue Mar 13, 2025
Merged via the queue into main with commit 58d241f Mar 13, 2025
@thomaseizinger
thomaseizinger deleted the feat/apply-search-domain-network-settings branch March 13, 2025 06:25
github-merge-queue Bot pushed a commit that referenced this pull request Mar 14, 2025
On Android, we can use
[`addSearchDomain`](https://developer.android.com/reference/android/net/VpnService.Builder#addSearchDomain(java.lang.String))
to configure the search domain list for our VPN tunnel.

Thankfully, this gets applied to the system resolver without any other
hackery involved (unlike for Apple in #8421), and most apps use the
system resolver for queries. The one exception to this are some network
utilities like AndroDNS and Fing.

Tested to work fine in Termux using `github.io` as the search domain,
which responds to ICMP echoes to any subdomain:



<img width="420" alt="Screenshot 2025-03-13 at 10 19 41 PM"
src="https://github.com/user-attachments/assets/e156e644-08a8-4ab6-b49a-91ef92aabafd"
/>


Related #8410

---------

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
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.

2 participants