Created
August 16, 2016 09:36
-
-
Save farrokhi/619e6fbd66f9761e2efb21022602b18d to your computer and use it in GitHub Desktop.
Split default route into multiple smaller routes (FreeBSD)
This file contains 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 | |
# | |
# Split default route into 8 smaller routes to avoid | |
# lock contention during route lookup | |
# | |
# If a default router is not specified, it will be | |
# taken from rc.conf. | |
# | |
ROUTECMD="/sbin/route -q " | |
ROUTES="0.0.0.0/3 32.0.0.0/3 64.0.0.0/3 96.0.0.0/3 128.0.0.0/3 160.0.0.0/3 192.0.0.0/3 224.0.0.0/3" | |
if [ $# -lt 1 ]; then | |
echo "syntax: $0 [start|stop]" | |
exit 1 | |
fi | |
case $1 in | |
start) | |
GW=`sysrc -n defaultrouter` | |
for R in ${ROUTES}; do | |
${ROUTECMD} add -net ${R} ${GW} | |
done | |
;; | |
stop) | |
for R in ${ROUTES}; do | |
${ROUTECMD} delete -net ${R} | |
done | |
;; | |
esac | |
# no need to remove default route since it will never be matched | |
#${ROUTECMD} delete default | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment