North American Network Operators Group

Date Prev | Date Next | Date Index | Thread Index | Author Index | Historical

something of interest to gated users

  • From: Paul A Vixie
  • Date: Thu Oct 23 15:40:47 1997

i know that programming is passe, and i apologize for not being able to
think of any good political statements to make here, but if you're running
bgp via gated and you'd like to know which of your peers are misconfigured,
the following perl script may be of help.  change $us as appropriate.  note
that you need "traceoptions state detail send open recv open" in your bgp
declaration, and the script below wants your gated.log file as input.

#!/usr/bin/perl

$us = "204.152.184.134";

while (<>) {
        chop;
        next unless /^\w\w\w \d\d (\d\d\:\d\d\:\d\d)\s+/o;
        ($ts, $_) = ($1, $');
        if (/^BGP RECV /o) {
                $_ = $';
                if (/^((\d+\.){3}\d+)\+\d+ \-\> ((\d+\.){3}\d+)\+\d+$/) {
                        ($outer_ts, $their_ip, $our_ip) = ($ts, $1, $3);
                }elsif (/^version 4 as (\d+) holdtime \d+ id ((\d+\.){3}\d+)/){
                        if ($ts eq $outer_ts) {
                                ($as, $id) = ($1, $2);
                        }
                }
        } elsif (/bgp_pp_recv\: no group for ((\d+\.){3}\d+)\+\d+/) {
                if ($ts eq $outer_ts && $our_ip eq $us) {
                        $_ = sprintf("as %5d ip %15s id %15s",
                                     $as, $their_ip, $id);
                        $result{$_} = $ts;
                }
        }
}

while (($key,$val) = each %result) {
        print "$val: $key\n";
}

exit 0;