My corporate Ubuntu laptop is set up with barracudavpn that doesn't understand systemd-resolve.
In its default configuration it simply overwrites /etc/resolv.conf, completely screwing up DNS on
my local LAN (and non-work DNS).
I'd like to have completely flexible DNS configuration that is cleanly segmented by interface.
In order to do that, I'm willing to:
- Configure barracudavpn client to never touch /etc/resolv.conf
- Maintain my own config file with corporate DNS settings
- Connect barracudavpn with a script (the one in this gist) instead of by directly running it (this way I can pass cmd-line args)
- Have the script run
systemd-resolve -i tun0 --set-dns=X --set-domain=Y
type command after connecting. - Periodically check that the above is still in effect (if the network connection dies, it is cleared).
-
Disable resolve.conf overwriting in barracudavpn options (Configure DNS=NO)
-
Also remove any hardcoded DNS your IT department may have placed into your
/etc/systemd/resolved.conf
-
Ensure that your
/etc/nsswitch.conf
has resolve early in the hosts entry, eg:hosts: files resolve mdns4_minimal dns [NOTFOUND=return] myhostname
-
Ensure that you can run
sudo systemd-resolve -i tun0 --set-dns=XXXX
and similar. Passwordless or not is up to you. -
Place
vpn
script anywhere in your $PATH, eg/usr/local/bin
, make executable. -
Create aliasing symlinks as mentioned in the top of the script.
-
Copy vpn.properties to /etc/default/vpn and edit to your needs
-
Test by running (as your user, not root)
vpn-up
,vpn-down
andvpn-status
. You should have correct per-interface DNS settings after it runs. -
Add a cronjob to run
vpn-status --fix
periodically so that it can fix DNS settings after your network disconnects. Personally, I use XFCE's Generic Monitor applet to run this and display the output, so I get two for the price of one.
Done.
Run any of the scripts with tracing, eg:
bash -x /usr/local/bin/vpn-up