BGP Regular Expression
BGP Regular Expression
com
Search...
Table of Contents
BGP
BGP Transit AS
Characters
https://networklessons.com/bgp/bgp-regular-expressions-examples 1/6
5/15/2019 BGP Regular Expressions Examples | NetworkLessons.com
[] is a range.
_ matches the space between AS numbers or the end of the AS PATH list.
Examples
^$ matches an empty AS PATH so it will match all pre xes from the local AS.
^51_ matches pre xes from AS 51 that is directly connected to our AS.
matches pre xes that originated in AS 51, the $ ensures that it’s the
_51$
beginning of the AS PATH.
^([0- matches pre xes from AS 51 where AS 51 is behind one of our directly
9]+)_51 connected AS’es.
^51_([0-
matches pre xes from the clients of directly connected AS 51.
9]+)
^(51_)+ matches pre xes from the clients of directly connected AS 51, where AS
([0-9]+) 51 might be doing AS PATH prepending.
^51_([0- matches pre xes from the clients of directly connected AS 51, where the
9]+_)+ clients might be doing AS PATH prepending.
If you need some practice for these, I would suggest to use a BGP looking glass server.
Got some more useful BGP regular expressions? Please let me know!
« Previous Lesson
BGP Community Local AS
Next Lesson
BGP Transit AS »
Tags: Filtering
Forum Replies
seafarmer11
Hey Rene,
I can’t get a meaning the last one’s " [)] "section ? You have an idea?
By the way ; these ip as-path access lists , bgp ltering commands just ltering the AS’s that advertising
from another BGP routers right?
Deniz
ReneMolenaar
Hi Deniz,
https://networklessons.com/bgp/bgp-regular-expressions-examples 3/6
5/15/2019 BGP Regular Expressions Examples | NetworkLessons.com
The rst entry will match on pre xes that originated in this AS. The second one will match on everything
that ends with 650XX). Anything in the 64512 – 65535 range are private AS numbers. The [)] is a bit
strange, normally you use the [] for a range (like 0-9). I’m guessing that they use it to match on sub-AS
numbers in a confederation? That’s the only time you will see a ) in the AS path:
https://networklessons.com/bgp/bgp-confederation-explained/
Rene
ReneMolenaar
Hi A,
Most of the looking glass servers support regular expressions so that would be the best option to get
some practice. If you want to practice this “locally” then I would con gure some BGP routers and use
route-maps for things like AS path prepending, this can be used as a nice simulation of the Internet.
Rene
wilder7bc
Don’t get me wrong I see the examples and as I went through lessons later on I see some of the examples
come up that can be useful.
^$ which can be useful for applying to everything (you use this one when dealing with Transit issues when
multi-homing and need to lter) or ^63100$ apply to an AS speci cally.
//cdn-
forum.networklessons.com/uploads/default/original/1X/ba8410b24c63f01693bd194e49f4b85b377d378c.PNG
ReneMolenaar
https://networklessons.com/bgp/bgp-regular-expressions-examples 4/6
5/15/2019 BGP Regular Expressions Examples | NetworkLessons.com
Hi Brian,
It’s normal I think…as network engineers, we don’t use regular expressions much. If you are into
programming, you’ll use them quite a lot to match strings/numbers/etc… If you want to practice these, try
a site like:
https://regexr.com/
Paste in the output of a BGP table there and test it…it’s easier and quicker than testing regex on your
router.
I wouldn’t worry about this too much though…when you need to use them for BGP, you can always look
them up…test it, then apply it to your router. No need to memorize all the di erent options. When you
need it
1 more reply! Ask a question or join the discussion by visiting our Community Forum
Hello There!
I am René Molenaar (CCIE #41726), Your main Instructor. My goal is to teach
you everything about Cisco, Wireless and Security. I am here to Help You
Master Networking!
Read my story
New Lessons
Device Programmability
Data Models and Structures
Network Automation and Orchestration
Cloud Connectivity
Virtualization Functions (NFVI, VNF)
https://networklessons.com/bgp/bgp-regular-expressions-examples 5/6
5/15/2019 BGP Regular Expressions Examples | NetworkLessons.com
Disclaimer
Privacy Policy
Support
https://networklessons.com/bgp/bgp-regular-expressions-examples 6/6