Page 1 of 1

Search routing table by subnet mask

Posted: Tue Dec 22, 2015 7:27 pm
by wildbill442
So I recently ran into an issue where one of my BGP peers was sending me very specific routes smaller than /24 causing some routing loops within our internal network.

Is there a way to search the routing table for routes based on subnet mask or prefix length?

I have three BGP peers and over 1.5million routes so running a "ip route print where 'string' in dst-address" would take forever to complete even on a CCR and I don't think it would accomplish the goal...

I've adjusted my filters to remove routes smaller than /24, the routing count went down for the peer but I wanted to confirm visually.

Re: Search routing table by subnet mask

Posted: Wed Dec 23, 2015 9:08 pm
by wildbill442
OK well.. it wasn't as straight forward as:
sh ip bgp | i /25
in ROS its gotta be a regex..
ip route pr where dst-address~"^[0-9 \\.]*/25" 
rinse and repeat for other prefixes... and wait for the CCR to go through all 1.6Million routes.

This seems too resource intensive -- can we get grep already?!

Re: Search routing table by subnet mask

Posted: Wed Dec 23, 2015 11:35 pm
by dada
IMHO you should have filters which will not allow to accept longer prefixes (than /24) from BGP peers (among with other things which is not safe to receive from a peer)...