Skip to content

Instantly share code, notes, and snippets.

@asgrim
Created May 11, 2015 09:23
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 asgrim/42b0fe82c19b417a5b5c to your computer and use it in GitHub Desktop.
Save asgrim/42b0fe82c19b417a5b5c to your computer and use it in GitHub Desktop.
OpenVPN with nameserver - when you connect to a VPN that does not automatically set appropriate nameserver, this wraps it and makes it work.
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "You must be root..."
exit 1
fi
sed -i -e "s/search homerouter\.cpe/nameserver 192.168.2.2\nsearch homerouter.cpe/" /etc/resolv.conf
openvpn --config #path-to-ovpn-config#
sed -i '/nameserver 192.168.2.2/d' /etc/resolv.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment