BGP Regular Expressions

I always find that when studying i get stuck with something. It does not sink in first time second time or maybe third and further study is always required. However, regular expressions have been a thorn in my side the past few weeks and i decided enough was enough. Action was needed! All around my house you will see these.

I have placed them in places i sit or have to go into a lot, like the fridge! (study make me hungry 🙂 )
Hopefully this will do the trick!
An example of RE is as follows.

* Anything
^$ Locally originated routes
^100_ Learned from AS 100
_100$ Originated in AS 100
_100_ Any instance of AS 100
^[0-9]+$ Directly connected AS’s

I will be trying to also use these in my upcoming lab time.
Top tip you can also use RE in show commands, this is very cool.
Take for example the Regular Expression ^

Use this to look for text at the beginning of a string.

For Example: ^123 matches 1234, but not 01234 or 91234

On a router we can demonstrate this as follows: (without any regular expressions)

Router#show run | include ip
ip cef
no ip dhcp use vrf connected
ip dhcp pool ITS
option 150 ip 10.1.1.1
no ip domain lookup
voice service voip
allow-connections h323 to sip
allow-connections sip to h323
allow-connections sip to sip
ip address 192.168.10.1 255.255.255.0
ip address 192.168.11.1 255.255.255.0
ip address 192.168.12.1 255.255.255.0
ip address 192.168.13.1 255.255.255.0
ip address 192.168.14.1 255.255.255.0

However, if we use the following:
Router#show run | include ^ip

The output is:
Router#show run | include ^ip
ip cef
ip dhcp pool ITS
ip http server

Every line begins with “ip”, string we matched on, sweet!!
Big thanks to muppet master at work 😉 for all his help with BGP, it is great to talk BGP and bouce ideas around with someone who is just a much of a BGP freak as me.

BE

Advertisements

~ by bigevil on May 29, 2010.

 
%d bloggers like this: