## Monday, August 27, 2007

### CCIE Regular Expression in BGP

I think one of the most scary configuration is when using Regular Expression (at least for me)
it took me a while and I am still straggling from time to time, although I am writing to you about this I am sorry to say there is no easy way to get it. you just need to put it in your head
I believe the each explanation has its own advantage as some people understand reading manual some need a trainer to lecture them.
Here I will give some of my own explanation to the common regular expression:
* all char, mean when you use this it can be any char
^ start here, for example ^5 mean any thing that start with 5 so it could be 5 or 500 or 54 or 5000000
$ end here, for example 5$ mean any string that end with 5 so it could be 455 or 45 or 5 or 3005
_ (underscore) start or end or space, this is a nice one as it mean you can either start a string or end a string or simple space. example _5_ can only mean 5 but _5 can mean 5 or 500 or 54 or 5000000 and 5_ can mean 455 or 45 or 5 or 3005
[] brackets, I do not know how to define it but it mean that any thing with in the brackets you use example 5[9834] mean it can be 59 or 58 or 53 or 54 basically it is like you put comma between char but you don't. you can also specify range 5[3-6] so it mean 53 or 54 or 55 or 56
? true or false, this is nice as it is like a game you either have it or you don't when you specify
5? it mean either 5 or nothing mean he will search both scenarios.
() group, here like you do arithmetic's you have logical grouping mean you can set up something like so ^50(_[1-9]43)?$ and it mean that it will bring you path that looks like that:
50
or
50 143
50 243
....
+ plus sign mean that at least one char should be present example 4+ mean it can match 4 or 44 or 444 or 44444
there are a lot of combinations to the regular expression but they all just like a formula, you need to understand exactly what you want to match to form it.
another useful regexp small and simple is ^$ yes this is useful and how you ask well as a client you would like to know most of the time that you are not being used, as you are paying the Service Provider and not the other way around.
when you are connected to 2 SP and you get advertisements from one provider the default behavior is to publish to the other EBGP neighbors mean the 2 SP and consider the option that some time your route will be shorter then the route of the 1 SP to the 2 SP you will become a SP to the SP (hope I didn't confuse you) but to make long story short, if you publish networks that are not yours from your network you can become and will become a transit area mean that unwanted traffic of one SP will pass trough you and utilize your bandwidth
and the simple way to stop it is not advertise network that are not your own!!!
and how you do it you ask?!
well by matching an as-path list to ^$ to permit only routes that do not have any other AS numbers on there path to be advertised meaning your own AS. simple no?!

Subscribe to:
Post Comments (Atom)