I’m using bird on my routers for a few years now, and every time I setup a new router I add these shell functions to help me monitor and debug network issues:

function bgp_states {
    for i in $(birdc show protocols|sed 's/\s\+/|/g'|grep BGP); do
        a=(${i//|/ })
        echo ${a[*]}|awk '{printf "%-16s\t%s\t%s\t%s\t%s\t%s\n", $1, $2, $3, $4, $5, $6;}'
        birdc show protocol all ${a[0]}|grep Routes
    done
}

function show_route {
    range=$1
    all=''
    if [[ $1 == for ]]; then range=$2; fi
    if [[ $1 == all ]]; then all='all'; range=$2; fi
    if [[ $range =~ [a-z] ]]; then
        range=$(host -t A $range|head -n1|cut -d ' ' -f 4)
    fi
    birdc show route $all for $range table main
}

function bgp_info {
    birdc "show protocols all $1"
}

Comments are closed.

Posted by HackMan
Dated: 5th April 2017
Filled Under: Uncategorized