Home Routing BGP BGP Regular Expression


1. Atom An atom is a single character, such as the following

.

Matches any single character

^

Matches the beginning of the input string

$

Matches the end of the input string

\

Matches the character

-

Matches a comma (,), left brace ({), right brace (}), the beginning of the input string, the end of the input string, or a space.


2. Piece A piece is an atom followed by one of the following symbols

*

Matches 0 or more sequences of the atom

+

Matches 1 or more sequences of the atom

?

Matches the atom or the null string


3. Branch A branch is a 0 or more concatenated pieces

a*

Any occurrence of the letter "a", including none

a+

At least one occurrence of the letter "a" should be present)

ab?a

This matches "aa" or "aba"

_100_

Via AS100

^100$

Origin AS100

^100 .*

Coming from AS100

^$

Originated from this AS



Examples

3-1-1, Filtering bgp output with route only origin from AS7018

Cisco Router#sh ip bgp regexp ^7018$
BGP table version is 199154652, local router ID is x.x.x.x
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
*>i3.51.92.0/23     12.122.126.39           10    100      0 7018 ?
* i                 12.122.126.39           10    100      0 7018 ?
*>i12.0.0.0/9       12.122.126.39           10    100      0 7018 i
* i                 12.122.126.39           10    100      0 7018 i
*>i12.0.0.0         12.122.126.39           10    100      0 7018 i
:
:

3-1-2, Filtering bgp output with route origin from AS46164

Cisco Router#sh ip bgp regexp _46164$
BGP table version is 199155849, local router ID is x.x.x.x
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
* i4.23.88.0/24     12.122.126.39           10    100      0 7018 46164 i
*>i                 12.122.126.39           10    100      0 7018 46164 i
*>i4.23.88.0/23     12.122.126.39           10    100      0 7018 46164 i
:
:

3-2, Filtering bgp output with route pass thru AS46164

Cisco Router#sh ip bgp regexp _6762_
BGP table version is 199165809, local router ID is x.x.x.x
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
*>i2.0.0.0/16       144.228.243.250         10    100      0 1239 6762 12654 i
* i                 144.228.243.250         10    100      0 1239 6762 12654 i
*>i2.1.0.0/21       144.228.243.250         10    100      0 1239 6762 12654 i
* i                 144.228.243.250         10    100      0 1239 6762 12654 i

:
:

3-4, Filtering bgp output with route only origin from AS1239 and directly attached with AS1239

Cisco Router#sh ip bgp regexp ^1239_[0-9]*$
BGP table version is 199175215, local router ID is x.x.x.x
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
*>i8.3.213.0/24     144.228.243.250         10    100      0 1239 4739 i
* i                 144.228.243.250         10    100      0 1239 4739 i
*>i8.10.245.0/24    144.228.243.250         10    100      0 1239 17151 i
* i                 144.228.243.250         10    100      0 1239 17151 i

 

 

3-5, Filtering bgp output with route origin from AS46164

Cisco Router#sh ip bgp regexp ^1239$       
BGP table version is 199175920, local router ID is x.x.x.x
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
*>i12.70.138.0/24   144.228.243.250         10    100      0 1239 i
* i                 144.228.243.250         10    100      0 1239 i
*>i12.195.4.0/24    144.228.243.250         10    100      0 1239 i

 

3-6, Filtering bgp output with route learning from AS1239

Cisco Router#sh ip bgp regexp ^1239_
BGP table version is 199177194, local router ID is x.x.x.x
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
*>i2.0.0.0/16       144.228.243.250         10    100      0 1239 6762 12654 i
* i                 144.228.243.250         10    100      0 1239 6762 12654 i
*>i2.1.0.0/21       144.228.243.250         10    100      0 1239 6762 12654 i

 

3-7, Filtering bgp output with route only direct connected ASs

Cisco Router#sh ip bgp regexp ^[0-9]+$
BGP table version is 199177786, local router ID is x.x.x.x
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
*>i3.51.92.0/23     12.122.126.39           10    100      0 7018 ?
* i                 12.122.126.39           10    100      0 7018 ?
*>i4.0.0.0/9        4.68.185.60             10    100      0 3356 i
 

3-8, Filtering bgp output with route only direct connected ASN with letter 1, 7 and 4

Cisco Router#sh ip bgp regexp ^[174]+$
BGP table version is 199179097, local router ID is x.x.x.x
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
*>i24.238.0.0/24    154.54.13.137           10    100      0 174 i
* i                 154.54.13.137           10    100      0 174 i
*>i24.238.2.0/24    154.54.13.137           10    100      0 714 i
* i                 154.54.13.137           10    100      0 714 i
 

3-9, Filtering bgp output with route origin from AS46164 and thru AS7018

Cisco Router#sh ip bgp reg ^7018_46164$
BGP table version is 199190289, local router ID is x.x.x.x
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
* i4.23.88.0/24     12.122.126.39           10    100      0 7018 46164 i
*>i                 12.122.126.39           10    100      0 7018 46164 i
*>i4.23.88.0/23     12.122.126.39           10    100      0 7018 46164 i
* i                 12.122.126.39           10    100      0 7018 46164 i

 

3-10, Filtering bgp output with route locally origin

Cisco Router#sh ip bgp reg ^$          
BGP table version is 199192287, local router ID is x.x.x.x
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
*>i4.68.62.96/30    140.222.130.48                100      0 i
* i                 140.222.130.48                100      0 i
*>i4.68.63.140/30   140.222.130.48                100      0 i
* i                 140.222.130.48                100      0 i

Last Updated (Thursday, 25 March 2010 17:48)

 
Smart Link
Search
Statistics
Content View Hits : 2088283
Polls
Highly recommended firewall vendor?
 
Google Translation
English Arabic Chinese (Simplified) Czech Dutch French German Italian Korean Portuguese Russian Spanish Filipino Vietnamese Thai Turkish
BGP routing issue?
Banner
World Route Servers
Banner
Who's Online
We have 7 guests online