Created
May 8, 2013 19:41
-
-
Save atoa/5543069 to your computer and use it in GitHub Desktop.
shell pipeline to convert a Linux routing table to a prefix based network address CSV. depends on having ipcalc installed.
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
netstat -rn | grep UG | awk '{print $1 " " $3 " " $2 " " $8}' | \ | |
xargs -n4 sh -c 'ipcalc -p -n $0 $1 ; echo $2 $3' | xargs -n4 | \ | |
sed -e 's/PREFIX=\([0-9]\{1,\}\) NETWORK=\([0-9\.]\{1,\}\)/\2\/\1/; s/ /, /g ' | \ | |
sort -V |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment