clforeach.sh
If you want to run the same command on a number of routers (let’s say you want to check whether a particular prefix is visible on a number of different looking glass/route server hosts) then calling RANCID’s clogin from a loop can save a lot of typing.
This probably already exists, but I felt like doing it myself. If this is useful to you, let me know :-)
#!/bin/bash # Simeon Miteff <simeon@localloop.co.za> clogin=/usr/lib/rancid/bin/clogin if [ $# -le 1 ]; then echo "Usage: $0 [cloginrc file] [command]" 1>&2; exit 1; fi awk '{print $3}' < $1 | sort -u | while read host; do $clogin -autoenable -f $1 -c "$2" $host; done
Now if you’re interested in South African BGP, here is a sample cloginrc file:
add user tpr-route-server.saix.net {saix}
add password tpr-route-server.saix.net {saix}
add user lg1.za.mtnbusiness.net {lg}
add password lg1.za.mtnbusiness.net {l0ok1ng-G145s}
add user lg2.za.mtnbusiness.net {lg}
add password lg2.za.mtnbusiness.net {l0ok1ng-G145s}
add user local-route-server.is.co.za {rviews}
add password local-route-server.is.co.za {rviews}
add password route-server.tenet.ac.za {rviews}
add password route-views.jinx.routeviews.org {}

