Skip to content

Support Split DNS on Linux using systemd-resolved#163

Open
tolfsh wants to merge 2 commits into
dlenski:masterfrom
tolfsh:master
Open

Support Split DNS on Linux using systemd-resolved#163
tolfsh wants to merge 2 commits into
dlenski:masterfrom
tolfsh:master

Conversation

@tolfsh

@tolfsh tolfsh commented May 7, 2026

Copy link
Copy Markdown

Hi!
This PR aims to add split DNS support --domains-vpn-dns on Linux using systemd-resolved/resolvectl. I mimicked the way it is made on Mac by extending the SplitDnsProvider class. The program check if systemd-resolved is used and then add the nameservers and domain using resolvectl.

I needed the tun name, so I also edited the configure_domain_vpn_dns definition. This fixes #157 and follows the recommendations in #158.

Tested on Debian 13

@dc138

dc138 commented May 12, 2026

Copy link
Copy Markdown

I've been using the branch Linux_split_DNS_PR118_rework through this AUR package on Arch Linux for a while and it works great. However, it seems (as far as I can tell) that it has been abandoned without hope of being merged.

I'm not too familiar with the codebase, so I can't provide a very thorough review of this PR, but it seems to implement the same functionality a bit more robustly, and on an up-to-date master.

Looking forward for this to be merged.

@Knud3

Knud3 commented May 13, 2026

Copy link
Copy Markdown

Thanks for the PR!

Just sharing some thoughts:

  • Is it wanted that domains also work as search domains? If not, then ~ prefix for domains needs to be added. By default resolvectl configure both routing domain and search domain.
  • Checking systemd-resolved comment is not most safe thing to do. How about either:
    • Check if /run/systemd/resolve/stub-resolv.conf exist.
    • Or check if systemd-resolved.service is running.
      • systemctl is-active systemd-resolved.
      • Or resolvectl status.
  • Check If /etc/resolv.conf points to 127.0.0.1 as then there is e.g. dnscrypt-proxy, dnsmasq, stubby, or unbound installed.
  • Would cleanup need some fail safe? If VPN software crashes, or if interface gets stuck, DNS settings might remain attached.
    • Maybe running resolvectl revert <interface_name> before destroying interface?
  • Maybe something for future:
    • Also NetworkManager handles resolv.conf if dns=default in /etc/NetworkManager/NetworkManager.conf.
    • For fail safe/older systems use resolvconf/openresolv/nmcli to set routing domains.

@tolfsh

tolfsh commented May 18, 2026

Copy link
Copy Markdown
Author

Hello!

Thank you for this review! I'll modify this as soon as I can.

(I hope I'll be able to add a commit to this PR, this is like my second PR ever on any project XD)

@tolfsh

tolfsh commented May 18, 2026

Copy link
Copy Markdown
Author

Ok I added the following :

  • Prefixed domains with ~
  • Checking activeness of systemd-resolved service
  • Checking presence of 127.0.0.53 in /etc/resolv.conf, but printing a warning if it is not
  • Failsafe by reverting interface DNS configuration

For the rest, I think people with particular configuration know what they are doing, and I don't want the script to just do nothing if something is missing. I feel checking that systemd-resolved is running and that /etc/resolv.conf contains 127.0.0.53 is enough.

@dc138

dc138 commented Jun 6, 2026

Copy link
Copy Markdown

Works as expected for me running systemd 260.2 with systemd-resolved and systemd-networkd on kernel 7.0.10.

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.

--domains-vpn-dns does not work on Ubuntu 24.04 LTS, seems trivial to fix

3 participants