Page 1 of 1

show ip bgp summary

Posted: Thu Dec 12, 2013 7:27 pm
by MarcB
Hi Guys,
I have written a script that can be used and stored on the MiktoTik Routers that will allow you to do the same as the following Cisco commands:-
show ip bgp summary
show ip bgp ipv4 unicast summary
show ip bgp ipv6 unicast summary
show ip bgp summary | include 64500
show ip bgp ipv4 unicast summary | include 64500
show ip bgp ipv6 unicast summary | include 64500

You will need to paste the following into the router from a terminal window
/system script
add name="show bgp summary include" policy=ftp,winbox,api source=":if ( \$as = nil ) do={\r\
    \n\t/routing bgp peer\r\
    \n\t:do {\r\
    \n\t:put \"Neighbor \\t\\t  ASN \\t Prefix Limit \\t Passive \\t PfxRcd \\t   State \\t Up/Down\" \r\
    \n\t:foreach i in=[find instance=default] do={  :put \"\$[get \$i remote-address]   \\t \$[get \$i remote-as] \\t \$[get \$i max-prefix-limit] \\t\\t \$[get \$i passive] \\t\\t \$[get \$i prefix-count] \\t\\t \$[get \$i state] \\t \$[get \$i upti\
    me]\" } \r\
    \n\t}\r\
    \n} else={\r\
    \n\t/routing bgp peer\r\
    \n\t:do {\r\
    \n\t:put \"Neighbor \\t\\t  ASN \\t Prefix Limit \\t Passive \\t PfxRcd \\t   State \\t Up/Down\" \r\
    \n\t:foreach i in=[find remote-as=\$as] do={  :put \"\$[get \$i remote-address]   \\t \$[get \$i remote-as] \\t \$[get \$i max-prefix-limit] \\t\\t \$[get \$i passive] \\t\\t \$[get \$i prefix-count] \\t\\t \$[get \$i state] \\t \$[get \$i uptime\
    ]\" } \r\
    \n\t}\r\
    \n}\r\
    \n"
/system scheduler
add name="Show BGP Summary Schedule" on-event=":global shbgpsum [:parse [/system script get \"show bgp summary include\" source]]\r\
    \n" policy=reboot,read,write,policy,test,winbox start-time=startup
The to use the above you will either need to reboot you router or go to System > Scheduler and change the time on the interval setting so that the job will run once. Wait for it to run and then change it back to the default value of 00:00:00

Once the above has been done you will be able to use the following global command fro anywhere in a terminal window to print the information to the screen in the same way as Cisco devices do
$shbgpsum as=64500
$shbgpsum
Hope this helps someone.

Kind regards,
Marc

Re: show ip bgp summary

Posted: Fri Feb 28, 2014 11:12 am
by robertpenz
Big Thx for this script!

Re: show ip bgp summary

Posted: Fri Feb 28, 2014 7:55 pm
by IPANetEngineer
Excellent! I use that show command a bunch in the Cisco world...nice to have an equivalent for RouterOS. Well done!

Re: show ip bgp summary

Posted: Sun May 04, 2014 1:36 pm
by plisken
Can you shown more comands that you can do with this script?

Ore is the 2 commands all what you can do?