Skip to content

Instantly share code, notes, and snippets.

@dimitrovs
Created October 5, 2016 01:48
Show Gist options
  • Save dimitrovs/8d21f6c70cbf4a4f1c24663e743d1916 to your computer and use it in GitHub Desktop.
Save dimitrovs/8d21f6c70cbf4a4f1c24663e743d1916 to your computer and use it in GitHub Desktop.
OpenVPN Client Up Script
#!/bin/bash
#Clear all routes on vpn routing table (this is to make sure there isn't any crap left over from a previous vpn connection
/sbin/ip route flush table 100
#Copy routing table from main routing table into vpn table
/sbin/ip route show table main | grep -Ev ^default | while read ROUTE ; do ip route add table vpn $ROUTE; done
#Add default gateway to vpn routing table
/sbin/ip route add default via ${route_vpn_gateway} dev ${dev} table 100
/sbin/ip rule add from ${ifconfig_local} table 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment