Use resolvectl when no other DNS provider is available#158
Use resolvectl when no other DNS provider is available#158gatopeich wants to merge 1 commit intodlenski:masterfrom
Conversation
This allows use of --domains-vpn-dns in Ubuntu out of the box without additional software.
|
Instead of doing this, you should add (I'd actually name the provider Come to think of it, I thought someone had already done this, though. It looks like the code is on the branch Linux_split_DNS_PR118_rework. |
|
Also it's good to explicitly mention that:
|
| 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) |
There was a problem hiding this comment.
Don't hardcode tun0. Use env.tundev
| 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) |
There was a problem hiding this comment.
resolvectl only exists and works on Linux systems running systemd-resolved.
It should not be used as a catch-all/fallback. Instead, please create a SplitDnsProvider subclass, and plug in that provider on systems where it makes sense. The availability check might consist of running resolvectl status and parsing its output.
| for domain in args.vpn_domains: | ||
| print(subprocess.run(['resolvectl', 'domain', 'tun0', domain]), file=stderr) |
There was a problem hiding this comment.
this also does the wrong thing when you provide multiple domains. by calling the command repeatedly, you overwrite the previous domain rather than appending more domains to the list. instead of looping, just set all the domains at once in a single step.
This allows use of --domains-vpn-dns in Ubuntu out of the box without additional software.
Addresses issue #157