14 AS-PATH & Prepend
AS-PATH is a well-known mandatory attribute that lists the Autonomous Systems a route has crossed. It has two roles (best-path selection and loop prevention), and it can be manipulated with prepending to influence inbound traffic. Loop prevention is covered in note 08; this note focuses on AS-PATH as a best-path attribute and on prepending.
AS-PATH in best-path
In best-path selection, the route with the shorter AS-PATH is preferred (step 4 of the algorithm). “Shorter” means fewer AS to cross, counting AS traversed rather than router hops, and independent of the numeric value of the ASN. A single AS may contain many internal routers but still counts as one entry.
AS-PATH is passed between AS
Unlike Weight (local) and Local Preference (AS-internal only), AS-PATH is propagated across AS boundaries. Each time a route crosses an eBGP boundary, the advertising router prepends its own ASN. This is why AS-PATH can influence distant AS, not just directly connected ones.
AS-PATH Prepend
Prepending artificially lengthens the AS-PATH by adding your own ASN multiple times. Because a shorter AS-PATH is preferred, making a path longer makes it less preferred.
The apparent paradox: influences inbound, configured outbound
Prepend influences the inbound path into your AS, but it is configured outbound. The reason is that you cannot directly control a neighboring AS’s decision. What you can do is advertise outward (out) a path that looks worse over one of your links, so that neighbors choose to enter through the other link instead. You modify what you send in order to influence how traffic comes in. That is why it is applied out.
Always prepend with your own ASN
The correct and standard practice is to prepend using your own ASN, repeated as many times as needed. Prepending with a foreign ASN is a serious bad practice: it can cause other AS to discard the route via loop prevention (if that ASN matches theirs), or inject false routing information. The safe rule is to always prepend with your own ASN.
Typical use case
With two links to a neighboring AS, you can prepend the AS-PATH for a given prefix on one link so it looks longer, while leaving another prefix untouched on the other link. This steers inbound traffic per prefix across the available entry points.
How it is applied
A route-map matches the target prefixes and sets the prepend (repeating your own ASN), applied outbound toward the eBGP neighbor.
Self-check
Q1 — In best-path, which AS-PATH is preferred?
A) The one with the highest numeric ASN values
B) The shorter one — fewer AS to cross
C) The one with the most router hops
D) The one with the lowest Router ID
Respuesta
B is correct. A shorter AS-PATH (fewer AS traversed) is preferred; it counts AS crossed, not router hops or ASN numeric size.
- A) False — the numeric value of the ASN is irrelevant.
- C) False — router hops inside an AS do not count.
- D) False — Router ID is a later tiebreaker, not AS-PATH length.
Q2 — How does AS-PATH prepend change path preference?
A) It shortens the path to make it preferred
B) It lengthens the path with repeated ASNs to make it less preferred
C) It raises the Local Preference
D) It changes the next-hop
Respuesta
B is correct. Prepending adds your own ASN multiple times, lengthening the AS-PATH so that path becomes less preferred.
- A) False — it lengthens, not shortens.
- C) False — it does not touch Local Preference.
- D) False — it does not modify the next-hop.
Q3 — Prepend influences inbound traffic but is configured outbound. Why?
A) Because Local Preference only works inbound
B) Because you cannot control a neighbor’s decision directly, so you advertise a worse-looking path outward to steer how they enter
C) Because AS-PATH is stripped inbound
D) Because prepend only works on iBGP
Respuesta
B is correct. You cannot directly set a neighbor’s choice; by advertising a longer path out over one link, you make neighbors prefer entering via the other, steering inbound traffic.
- A) False — this is about AS-PATH prepend, not Local Preference behavior.
- C) False — AS-PATH is not stripped inbound.
- D) False — prepend is applied toward eBGP neighbors, not iBGP.
Q4 — Which ASN should you use when prepending?
A) The neighbor’s ASN
B) Your own ASN, repeated as needed
C) Any private ASN
D) The origin AS of the prefix
Respuesta
B is correct. Always prepend with your own ASN. Using a foreign ASN can trigger loop-prevention drops or inject false routing information.
- A) False — using the neighbor’s ASN is dangerous and can cause loop-based discards.
- C) False — inserting an unrelated private ASN is bad practice.
- D) False — you prepend your own ASN, not another AS’s.