Clone this repo
git clone https://github.com/Codesleuth/reroute
Copy routes.sample.txt
to routes.txt
and add in IP addresses and/or hosts you want to access through the VPN One per each line.
e.g.
nearform.com
github.com
1.2.3.4
5.6.7.8
- Connect to your VPN
- Run the
reroute
script and specify your preferred gateway and vpn interfacesudo -E bash -c 'LOCAL_GATEWAY=192.168.1.254 VPN_INTERFACE=utun1 ./reroute'
Set this environment variable to the gateway IP you want to use. You can easily get this before connecting to the VPN and checking the IP listed with netstat -nr | grep default
.
Get the interface name of the VPN in use. This is likely to be utun1
(the default). However, if this is not correct, connect to the VPN and look at the interface listed when running netstat -nr | grep default
and you will see the interface listed at the end (e.g. utun1
).
You can also easily update your routes list and and run again. The entries will be removed when you disconnect from the VPN so ensure you reconnect if you want to wipe out the list (or use route del <ip>
).
Some particular sets of VPN software will nuke your route table when they disconnect, so be aware that you may have to run this again when you move between WiFi access points, or resume from sleep etc.
MIT (see LICENSE
file)
Please do open PRs.