From 70fadf2391279e6daa6246f7e1e8c3784ce992c1 Mon Sep 17 00:00:00 2001 From: gatopeich <7722268+gatopeich@users.noreply.github.com> Date: Tue, 17 Jun 2025 10:00:01 +0100 Subject: [PATCH] Use resolvectl when no other DNS provider is available This allows use of --domains-vpn-dns in Ubuntu out of the box without additional software. --- vpn_slice/__main__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vpn_slice/__main__.py b/vpn_slice/__main__.py index 01c60b8..6b93276 100755 --- a/vpn_slice/__main__.py +++ b/vpn_slice/__main__.py @@ -2,6 +2,7 @@ import argparse import os +import subprocess from enum import Enum from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Interface, IPv6Network, ip_address, ip_network from itertools import chain, zip_longest @@ -250,7 +251,10 @@ def do_connect(env, args): # Use vpn dns for provided domains if args.vpn_domains is not None: if 'domain_vpn_dns' not in providers: - print("WARNING: no split dns provider available; can't split dns", file=stderr) + print("WARNING: no split dns provider available; trying resolvectl...", file=stderr) + print(subprocess.run(['resolvectl', 'dns', 'tun0', *map(str, env.dns)]), file=stderr) + for domain in args.vpn_domains: + print(subprocess.run(['resolvectl', 'domain', 'tun0', domain]), file=stderr) else: providers.domain_vpn_dns.configure_domain_vpn_dns(args.vpn_domains, env.dns)