Skip to content

Instantly share code, notes, and snippets.

@kghost
Last active October 17, 2015 20:14
Show Gist options
  • Save kghost/26416e830c56c9f21837 to your computer and use it in GitHub Desktop.
Save kghost/26416e830c56c9f21837 to your computer and use it in GitHub Desktop.
route.sh
#! /bin/sh
MAX=10000
case "$script_type" in
route-up)
op=add
;;
route-pre-down)
op=delete
;;
*)
echo Unknown script_type $script_type
exit 1
esac
for i in `seq $MAX`
do
eval "network=\$route_network_$i"
eval "netmask=\$route_netmask_$i"
eval "gateway=\$route_gateway_$i"
if [ -n "${network}" ]
then
echo route $op ${network}/${netmask} via ${gateway}
fi
done | ip -force -batch -
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment