Created
November 6, 2012 20:07
-
-
Save mattpascoe/4027169 to your computer and use it in GitHub Desktop.
Generate DCM.PL commands from the output of a 'show ip route' to load into ONA
This file contains hidden or 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/bash | |
# | |
# Author: Matt Pascoe - [email protected] | |
# | |
# usage: ./parseshowroute.sh <filename> | |
# | |
# Takes the output of a "show ip route" command from an IOS device | |
# and processes it. Simply get the output and save it to a file | |
# and then run this script against that file. | |
# | |
# It will output dcm.pl command syntax to create a new subnet based | |
# on the route. The default subnet type will simply be 'LAN', please | |
# change that to an appropriate value if needed. Also the default | |
# subnet name will be 'SHOWROUTE-<IP>' to indicate it was created by | |
# this script. In all cases a new name should be determined. | |
# | |
# Another major point, not all routes equate to actual subnets. Some | |
# routes are summarized so that one route will include multiple | |
# subnets. Be sure to examine these as it will cause overlaps while | |
# loading the data. I would suggest anything with a larger mask than | |
# /24 should be investigated. | |
# | |
# The major goal of this is to initially populate ONA with subnets | |
# that you can then load hosts and interfaces into. It is step one | |
# in the process of adding data to ONA. | |
cat $1 | \ | |
sed -e "s/EX//"| \ | |
awk '{print $2}'| \ | |
grep /| \ | |
sed -e "s/\(.*\)\/\(.*\)/dcm.pl -r subnet_add ip=\1 netmask=\/\2 name='SHOWROUTE-\1' type='LAN'/"| \ | |
egrep -v "\/0|\/32"| \ | |
sort -t, -n -r --key=4| \ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment