Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Community Member

Which BGP show command for internal prefix count?

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
Hall of Fame Super Silver

Re: Which BGP show command for internal prefix count?

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

7 REPLIES
Hall of Fame Super Silver

Re: Which BGP show command for internal prefix count?

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

Purple

Re: Which BGP show command for internal prefix count?

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.
Hall of Fame Super Silver

Which BGP show command for internal prefix count?

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

Which BGP show command for internal prefix count?

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

Hall of Fame Super Silver

Which BGP show command for internal prefix count?

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

Purple

Which BGP show command for internal prefix count?

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.
Community Member

Which BGP show command for internal prefix count?

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!

2258
Views
9
Helpful
7
Replies
CreatePlease to create content