Friday, July 6, 2007

Regexp in BGP

A regular expression (regex or regexp for short) is a special text string for describing a search pattern. You can think of regular expressions as wildcards on steroids. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is .*\.txt

Regexp use in BGP to match pattern AS number

^$ = i local AS
_100_ = going through
^100$ = directly connected
_100$ = originated in AS
^100_ = networks behind AS
.* = matches everything

Now try this, regexp to match pattern AS number

telnet 12.0.1.28
Trying 12.0.1.28...
Connected to route-server.cbbtier3.att.net.
Escape character is '^]'.
CCCC
############## route-server.ip.att.net ###############
######### AT&T IP Services Route Monitor ###########
...
#################### route-server.ip.att.net ####################

route-server>Kerberos: No default realm defined for Kerberos!

route-server>sh ip bgp regexp ^15169$

route-server>sh ip bgp regexp ^15169

route-server>sh ip bgp regexp _15169_
BGP table version is 2822010, local router ID is 10.1.2.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 64.233.160.0/23 12.123.1.236 0 7018 209 15169 i
* 12.123.33.249 0 7018 209 15169 i
* 12.123.21.243 0 7018 209 15169 i
...

route-server>sh ip bgp regexp _15169$
BGP table version is 2822035, local router ID is 10.1.2.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 64.233.160.0/23 12.123.1.236 0 7018 209 15169 i
* 12.123.33.249 0 7018 209 15169 i
* 12.123.21.243 0 7018 209 15169 i
...

route-server>sh ip bgp regexp _209_
BGP table version is 2822037, local router ID is 10.1.2.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
* 8.5.192.0/22 12.123.145.124 0 7018 209 13989 13989 13989 13989 i
* 12.123.45.252 0 7018 209 13989 13989 13989 13989 i
* 12.123.137.124 0 7018 209 13989 13989 13989 13989 i
...

No comments: