Mastering Regular Expressions

Regular expressions are not inherently difficult.  They just require a lot of practice.  The difficulty is finding an easy way to practice.

That’s where looking glass servers come in.  The bottom of this website lists numerous BGP route servers that allow anonymous telnet access.

I’ll pick a random server for this example: tpr-route-server.saix.net

First, we need to telnet in:

[769][charlie] ~/.dynamips $ telnet tpr-route-server.saix.net

Trying 196.25.9.46...

Connected to tpr-route-server.saix.net.

<snip>

tpr-route-server>

This brings us to our trusty command prompt.  A quick “show ip bgp” shows the prefixes.

tpr-route-server>sh ip bgp | b Net
   Network          Next Hop            Metric LocPrf Weight Path
* i1.9.0.0/16       196.43.9.234             1    100      0 3491 4788 i
* i                 196.43.9.234             1    100      0 3491 4788 i
*>i                 196.25.9.45              1    100      0 3491 4788 i
* i                 196.25.9.45              1    100      0 3491 4788 i
* i1.12.0.0/24      196.25.9.45              1    100      0 3491 4134 4847 18245 i
* i                 196.43.9.234             1    100      0 3491 4134 4847 18245 i
* i                 196.43.9.234             1    100      0 3491 4134 4847 18245 i
*>i                 196.25.9.45              1    100      0 3491 4134 4847 18245 i
* i1.12.0.0/14      196.25.9.45              1    100      0 3491 4134 4847 18245 i
<snip>

Let’s see what routes our favorite evil megalocorporation is originating. 🙂

tpr-route-server>sh ip bgp regexp _714$
BGP table version is 138080411, local router ID is 196.25.246.90
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
* i17.0.0.0/9       196.25.9.45              2    100      0 3356 714 i
*>i                 196.25.9.45              2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
* i17.31.0.0/16     196.25.9.45              2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
*>i                 196.25.9.45              2    100      0 3356 714 i
* i17.34.0.0/16     196.25.9.45              2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
*>i                 196.25.9.45              2    100      0 3356 714 i
* i17.36.0.0/15     196.25.9.45              2    100      0 3356 714 i
* i                 196.43.9.240             2    100      0 3356 714 i
<snip>

That’s it. With a little practice you’ll soon master regular expressions.

Advertisements

About this entry