CCIE Enterprise Infrastructure · BGP

BGP — CCIE Enterprise Infrastructure

The complete BGP learning path for CCIE Enterprise Infrastructure: how sessions form, how prefixes are chosen and shaped, how the protocol scales with route reflection and confederations, and how it is designed, secured and repaired in production.

  • 24 complete lessons
  • 5 hr 20 min
  • Foundation

AS-Path Manipulation and Regular Expressions · Lesson 01 of 01

Shaping and matching the AS path

AS-path prepending steers inbound traffic; AS-path regex matches routes by the path they travelled. Both are everyday edge tools.

  • 14 min lesson
  • 00:00 video
  • Foundation

Written lesson

Prepend to be less attractive

You cannot command how other networks send traffic to you, but you can make one of your paths look worse. Prepending your own AS several times lengthens the AS_PATH, and since shorter paths win best-path, the prepended path loses to the shorter one. It is the standard tool for making a backup ISP link genuinely a backup for inbound traffic. Prepend outbound, toward the neighbour whose view you want to change.

Configuration

Prepend on the backup exit

IOS / IOS XE
route-map PREPEND permit 10
 set as-path prepend 65001 65001 65001
!
router bgp 65001
 address-family ipv4 unicast
  neighbor 203.0.113.9 route-map PREPEND out

Written lesson

Matching with regex

AS-path access-lists match paths with regular expressions. ^$ matches the empty path — routes originated in your own AS (nothing traversed). _65002_ matches any path that passed through AS 65002. ^65002_ matches paths where 65002 is the first (nearest) AS. _65002$ matches paths that originated in 65002. These four patterns cover most real filtering: 'only my own routes', 'anything through this transit', 'directly from this peer', 'originated by this AS'.

The underscore

In AS-path regex the underscore matches any delimiter — start, end, space, comma, or brace. _100_ reliably matches AS 100 anywhere without also matching 1001 or 4100. Use it around every ASN you mean literally.