I am using openconnect to connect to vpn and vpn-slice for vpn splitting. openconnect modifies /etc/resolv.conf after start, but that doesn't help with vpn domain names resolving.
To work around that, I configured NetworkManager to use dnsmasq for domain name resolving.
/etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
dns=dnsmasq
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
And configured dnsmasq to use inner vpn dns to resolve custom domain names.
/etc/NetworkManager/dnsmasq.d/myvpn
server=/.vpn.domain/192.168.213.104
And that work perfectly on Ubuntu 18.04
I have tried to do the same with another laptop and failed. That other laptop has Ubuntu 20.04 installed.
There, domain names are not resolved even though configuration is the same (if I didn't completely miss something, I really hope I did). If I add domain names to /etc/hosts, everything starts working. But there's a lot of names, so, I'd prefer to use dnsmasq
Here's the difference between those two machines
With Ubuntu 18.04, where everything works, /etc/resolv.conf and /run/NetworkManager/resovl.conf are identical and contain the following lines only
/etc/resolv.conf
#Generated by NetworkManager
nameserver 127.0.1.1
which is dnsmasq
With Ubuntu 20.04 /run/Networkmanager/resolv.conf and /etc/resolv.conf are different. /etc/resolv.conf contains a lot of stuff and /run/NetworkManager/resolv.conf contains same lines as the on on Ubuntu 18.04
/etc/resolv.conf
This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0 trust-ad
which is systemd-resolved
/run/NetworkManager/resolv.conf
#Generated by NetworkManager
nameserver 127.0.1.1
which is dnsmasq
Also with Ubuntu 18.04 directory /etc/dnsmasq.d exists and contains two files
/etc/dnsmasq.d/network-manager
# Tell any system-wide dnsmasq instance to make sure to bind to interfaces
# instead of listening on 0.0.0.0
# WARNING: changes to this file will get lost if network-manager is removed.
bind-interfaces
/etc/dnsmasq.d/ubuntu-fan
# ensure that any system dnsmasq does not bind to fan-*
bind-interfaces
except-interface=fan-*
With Ubuntu 20.04 directory /etc/dnsmasq.d doesn't even exist
dnsmasq is running on both machines.
ps aux | grep dnsmasq
nobody 31355 0.0 0.0 14788 4280 ? S 09:47 0:00 /usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces --pid-file=/run/NetworkManager/dnsmasq.pid --listen-address=127.0.1.1 --cache-size=0 --clear-on-reload --conf-file=/dev/null --proxy-dnssec --enable-dbus=org.freedesktop.NetworkManager.dnsmasq --conf-dir=/etc/NetworkManager/dnsmasq.d
I seem to be missing some detail, but I have little experience with this kind of stuff and don't know how to diagnose it. Would appreciate any help with that.