#! /bin/bash if [[ $# -eq 0 ]]; then cat < >(exec sort -u > $ipv) for r in $@; do echo "Retrieving $ipv from $r:" peers=($(/usr/bin/ssh admin@$r sh bgp $ipv unicast sum | sed '1,/Description/ d' \ | awk '$2 !~ "^2c0f:f720:" && $2 !~ "^(100|154)[.]" { print $2 }')) for p in "${peers[@]}"; do echo "Peer $p" /usr/bin/ssh admin@$r sh bgp neigh $p received-routes \ | sed -re '1,/Network/ d' \ -e 's,(.*[[:space:]])?[0-9a-f:.]+/[0-9]+([[:space:]]+[^[:space:]]+){5}[[:space:]]+(.*) [ie?]$,\3,' \ | uniq | grep -E '^([0-9]+ )*[0-9]+$' >&3 done done done