Last active
December 13, 2015 14:35
-
-
Save manno/ef9c076c2000b111332d to your computer and use it in GitHub Desktop.
OpenVPN commandline with NetworkManager and internal DNS
This file contains 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 characters
#!/bin/sh | |
nameserver=$(env | perl -anE 'print $F[-1] if /foreign_option.*DNS/') | |
if [ "$nameserver" ]; then | |
#echo "nameserver $nameserver" | resolvconf -a $dev | |
nmcli con modify $dev +ipv4.dns $nameserver | |
fi | |
domain=$(env | perl -anE 'print $F[-1] if /foreign_option.*DOMAIN/') | |
if [ "$nameserver" ] && [ "$domain" ]; then | |
org_dns=$(nmcli -t -f uuid c show --active | while read uuid; do | |
nmcli -t -f IP4.DNS c show $uuid | cut -f2 -d: | |
done | tail -1 | |
) | |
nmcli con modify $dev +ipv4.dns-search $domain | |
qdbus --system org.freedesktop.NetworkManager.dnsmasq /uk/org/thekelleys/dnsmasq SetDomainServers "(" "$org_dns" "/$domain/$nameserver" ")" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment