Wednesday, January 25, 2012

REGULAR EXPRESSIONS

Regular Expressions
-------------------
used for string matching in
 - show command output
 - TCL/EEM scripting
 -BGP AS-PATH Access-list
 - BGP expanded community-list
DOcumented in
 - cisco ios terminal services configuration guide
 - Appendices
 - Reg Expression
Common Expressions
_100$ - originated in 100
^100_ - learned from 100
_100_ any instance of 100 in aspath
.* anything
[0-9] any number
+1  1 or more
say we wanted to search the bgp table for prefixes with an as path of exactly 2 AS
sh ip bgp regexp ^[0-9]+[0-9]+$
LAB
----
I am going log on to one of the public route servers
route-server.belwue.de

route-server>sh ip bgp regexp _100$
BGP table version is 268370706, local router ID is 193.196.190.135
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network          Next Hop            Metric LocPrf Weight Path
r i63.150.46.0/24   80.81.194.26          8734    220      0 6461 22669 100 i
r i                 80.81.194.26          8734    220      0 6461 22669 100 i
r>i                 80.81.194.26          8734    220      0 6461 22669 100 i
r i65.160.57.0/24

we get the routes originating in AS 100


route-server>sh ip bgp regexp ^3549_

r i184.28.110.0/23  159.63.22.245        13398     80      0 3549 i
r>i                 159.63.22.245        13398     80      0 3549 i
r i                 159.63.22.245        13398     80      0 3549 i
r i184.28.112.0/23  159.63.22.245        13672     80      0 3549 i
r>i                 159.63.22.245        13672     80      0 3549 i
r i                 159.63.22.245        13672     80      0 3549 i
r i184.28.114.0/23  159.63.22.245        13569     80      0 3549 i
r>i                 159.63.22.245        13569     80      0 3549 i
r i                 159.63.22.245        13569     80      0 3549 i
r i184.28.116.0/23  159.63.22.245        13569     80      0 3549 i

No comments:

Post a Comment