cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3952
Views
9
Helpful
7
Replies

Which BGP show command for internal prefix count?

jwbensley
Level 1
Level 1

I have two routers (R1 and R2); R1 has the full BGP table and some local connections to. They are all being advertise to it's iBGP neighour R2. I can't find a command that I can run on R2 that will show the number of prefixes learnt from R1 that are internal to the local AS only. It just says 425~k which is all the Internet routes and the local ones.

What command can I use for this?

1 Accepted Solution

Accepted Solutions

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello Jwbensley,

the local AS originated networks has AS path attribute empty.

So you could define an ip as-path acl matching an empty string

ip as-path access-list 1 permit ^$

then you can invoke the as-path access-list as a filter action on show ip bgp on R2 show ip bgp filter-list 1

see

BGP command reference

http://www.cisco.com/en/US/docs/ios-xml/ios/iproute_bgp/command/bgp-s1.html#GUID-2618748E-42ED-495A-875C-D398A02D79F9

At this point it is enough to count the lines in show ip bgp filter-list 1 output to count the routes that are originated in the local AS at R1 and received on R2 and installed on R2.

Hope to help

Giuseppe

View solution in original post

7 Replies 7

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello Jwbensley,

the local AS originated networks has AS path attribute empty.

So you could define an ip as-path acl matching an empty string

ip as-path access-list 1 permit ^$

then you can invoke the as-path access-list as a filter action on show ip bgp on R2 show ip bgp filter-list 1

see

BGP command reference

http://www.cisco.com/en/US/docs/ios-xml/ios/iproute_bgp/command/bgp-s1.html#GUID-2618748E-42ED-495A-875C-D398A02D79F9

At this point it is enough to count the lines in show ip bgp filter-list 1 output to count the routes that are originated in the local AS at R1 and received on R2 and installed on R2.

Hope to help

Giuseppe

Hi Giuseppe,

clever way of doing it  (  + 5, +4 because my fingers messed with the stars)  so a sh ip bgp regexp looking for empty AS_PATH would also do the trick, aint't it  ?

Regards.

Alain.

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

Hello Alain,

yes of course a show ip bgp regexp could be used instead

it would be

show ip bgp regexp ^$

http://www.cisco.com/en/US/docs/ios-xml/ios/iproute_bgp/command/bgp-s1.html#GUID-DC1E5812-83AF-4465-8F77-86CD5B7D043F

Best Regards

Giuseppe

Hi Giuseppe,

but this would show all the iBGP prefixes received from all neighbors, wouldn't that?

As the original request was "...command that I can run on R2 that will show the number of prefixes learnt from R1 that are internal to the local AS only", wouldn't

sh ip bgp nei R1_IP_address paths ^$

give a better result?

See http://www.cisco.com/en/US/docs/ios/iproute_bgp/command/reference/irg_bgp5.html#wp1160809

for details.

BR,

Milan

Hello Milan,

you are right I have assumed that R2 is a sort of stub with only an iBGP session to R1 from what the original poster has said.

Thanks for your note

Best Regards

Giuseppe

Hi Milan,

didn't know about this command, thanks a lot for mentioning it.

Regards.

Alain

Don't forget to rate helpful posts.

Don't forget to rate helpful posts.

Thank you for showing me this command.

That is pretty much what I wanted, and I like the shortened version! Although, I do have to dump this to a text file every time and run a small script against it to get a count of the actual routes, as this just prints out all the routing entries.

Thank you!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card