Last active
October 13, 2017 21:53
Revisions
-
devkid revised this gist
Oct 13, 2017 . No changes.There are no files selected for viewing
-
devkid created this gist
Oct 13, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ #!/bin/bash set -ex # ---------------------------------------------------------------------------- # Configuration: case "$CONNECTION_ID" in "Some VPN name") # enter name of VPN connection in NetworkManager here DOMAINS=( # enter domains that should be routed over the VPN here some-domain.com another-domain.net ) ;; # repeat for more VPN connections *) exit 0 ;; esac # ---------------------------------------------------------------------------- DBUS_PATH="/org/freedesktop/resolve1" DBUS_IF="org.freedesktop.resolve1" INTERFACE="$1" IF_INDEX="$(cat "/sys/class/net/$INTERFACE/ifindex")" if [[ $2 != "vpn-up" ]] then exit 0 fi DOMAIN_STR="" FIRST=true for DOMAIN in ${DOMAINS[@]} do if [[ $FIRST == true ]] then FIRST=false else DOMAIN_STR="${DOMAIN_STR}, " fi DOMAIN_STR="${DOMAIN_STR}('${DOMAIN}', true)" done gdbus call --system --dest $DBUS_IF --object-path $DBUS_PATH --method $DBUS_IF.Manager.SetLinkDomains $IF_INDEX "[$DOMAIN_STR]"