Skip to content

Instantly share code, notes, and snippets.

@bradland
Created January 17, 2011 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradland/782529 to your computer and use it in GitHub Desktop.
Save bradland/782529 to your computer and use it in GitHub Desktop.
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