Skip to content

Instantly share code, notes, and snippets.

@m0n5t3r
Created June 27, 2017 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m0n5t3r/59c9a1c3012df933c5788597c56165ed to your computer and use it in GitHub Desktop.
Save m0n5t3r/59c9a1c3012df933c5788597c56165ed to your computer and use it in GitHub Desktop.
(Ubuntu specific-ish) Openvpn up script to configure local dnsmasq so only internal domains are resolved via the pushed DNS; needs root, unfortunately
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/local/bin
case $script_type in
up)
(for optionname in ${!foreign_option_*}; do
echo ${!optionname}
done) | awk '$2 == "DNS" { dns_server = $3 }; $2 == "DOMAIN" { domains = domains "/" $3 }; END { print "server=" domains "/" dns_server }' > /etc/NetworkManager/dnsmasq.d/$remote_1
;;
down)
rm /etc/NetworkManager/dnsmasq.d/$remote_1
;;
esac
/etc/init.d/network-manager reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment