Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script for enabling/disabling custom IP routes
#!/bin/bash
# Enables and disables static routes required to access COMPANY resources
# over the VPN. These routes are required because the resources are hosted
# on public IP addresses, but restricted to access coming from specific
# networks.
enableroutes() {
route -nv add -net 4.2.2.1 -interface ppp0
route -nv add -net 4.2.2.2 -interface ppp0
route -nv add -net 4.2.2.3 -interface ppp0
}
disableroutes() {
# remove routes
route -nv delete -net 4.2.2.1 -interface ppp0
route -nv delete -net 4.2.2.2 -interface ppp0
route -nv delete -net 4.2.2.3 -interface ppp0
}
# What action should we take?
case "$1" in
enable)
enableroutes
;;
disable)
disableroutes
;;
*)
echo $"Usage: vpnroutes {enable|disable}"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment