Created
July 17, 2016 13:18
-
-
Save pldubouilh/f8d4a282cd2b5127d6baa904634ccaa6 to your computer and use it in GitHub Desktop.
Bind openvpn to one local IP
This file contains hidden or 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 | |
| # From https://snikt.net/blog/2013/10/10/how-to-force-program-to-use-vpn-tunnel/ | |
| # Execute first : | |
| # echo "10 custom_table" >> /etc/iproute2/rt_tables | |
| # Put this in opvpn config : | |
| # route-noexec | |
| # route-up /home/p/route_up.sh | |
| # Test with : | |
| # wget --bind-address=$ifconfig_local http://ipecho.net/plain -O - -q; echo | |
| echo "$dev : $ifconfig_local -> $ifconfig_remote gw: $route_vpn_gateway" | |
| ip route add default via $route_vpn_gateway dev $dev table custom_table | |
| ip rule add from $ifconfig_local/32 table custom_table | |
| ip rule add to $route_vpn_gateway/32 table custom_table | |
| ip route flush cache | |
| echo "Test : wget --bind-address=$ifconfig_local http://ipecho.net/plain -O - -q; echo " | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment