#./cisco.pl INPUT.txt OUTPUT.txt #### 4.21.103.0/24 | 4525:197 4525:1790 4525:1111 | 7323 3549 46133 10.10.10.0/24 | % Network not in table 212.54.129.0/24 | 4525:197 4525:1790 | Local #### router>sh ip bgp 4.21.103.0/24 BGP routing table entry for 4.21.103.0/24, version 336364302 Paths: (7 available, best #4) 7423 3549 703 192.168.248.5 (metric 29) from 192.168.103.28 (192.168.103.28) Origin IGP, metric 0, localpref 50, valid, internal Community: 4525:197 4525:1790 4525:9111 Originator: 209.64.228.126, Cluster list: 102.108.201.228 7323 3549 46133 192.168.238.5 (metric 29) from 192.168.103.27 (192.168.103.28) Origin IGP, metric 0, localpref 50, valid, internal,best Community: 4525:197 4525:1790 4525:1111 Originator: 209.64.228.126, Cluster list: 102.108.201.228 router>sh ip bgp 10.10.10.0/24 % Network not in table router>sh ip bgp 212.54.129.0/24 BGP routing table entry for 212.54.129.0/24, version 332786588 Paths: (3 available, best #3) Local, (Received from a RR-client) 212.54.45.235 from 212.54.45.235 (212.54.33.154) Origin IGP, metric 2, localpref 100, valid, internal Community: 4525:197 4525:1790 4525:9111 Local 212.54.33.153 from 0.0.0.0 (212.54.33.153) Origin IGP, metric 11, localpref 100, valid, local, best Community: 4525:197 4525:1790 #### #!/bin/perl use Net::Telnet::Cisco; $router = "10.10.10.4"; $port = 23; my $cs = Net::Telnet::Cisco->new( Host => $router, Input_log => "Input22.log", Port => $port,); $cs->login( 'cisco', 'cisco' ); $password="cisco123"; $cs->enable( $password ); open(OUTPUT, "> $ARGV[1]") or die "ERROR opening $ARGV[1]: $!n"; open(PREFIXES, "< $ARGV[0]") or die "ERROR opening $ARGV[0]: $!n"; open(ASFILE, "< asnames.txt") or warn "Can not open asnames.txt: $!n"; while () { /AS(d+?) (.*)/; $as{$1} = "$2"; } close(ASFILE); $path_num = 0; @cmd_output = $cs->cmd( 'term len 0' ); while () { chomp; if (!/^#/) { $prefix = $_; @cmd_output = $cs->cmd( "sh ip bgp $prefix" ); foreach (@cmd_output) { chomp;