Skip to content

Instantly share code, notes, and snippets.

@intrd
Last active March 3, 2017 06:04
Show Gist options
  • Save intrd/55576b75a9945ae6e611fba49f1a4b0d to your computer and use it in GitHub Desktop.
Save intrd/55576b75a9945ae6e611fba49f1a4b0d to your computer and use it in GitHub Desktop.
OpenVPN - Script to extract/set gateway of tun0
#!/bin/sh
## OpenVPN - Script to extract/set gateway of tun0
# @author intrd - http://dann.com.br/
# @license Creative Commons Attribution-ShareAlike 4.0 International License - http://creativecommons.org/licenses/by-sa/4.0/
# to autorun, put this on your ovpn file
# script-security 2
# up '/home/intrd/openvpn/xvpn/routescript.sh'
#sleep 5
#add vpn gatewy
#sudo route add default gw 10.30.0.1 tun0 #vpnout
#clear resolv.conf and add vpn dns
sudo echo "nameserver 10.1.0.1" > /etc/resolv.conf
RIPE="$(sudo ip addr show tun0 | grep inet | awk ' { print $4 } ' | sed 's/\/32//' | cut -f1 -d'2')""0.1"
echo "*** connected, gw:"
echo $RIPE
sudo route add default gw $RIPE tun0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment