Prepending
You control which path your traffic takes out of your network (local preference, as in earlier lessons). Traffic coming in is decided by everyone else's routers. The main tool you have to influence them is AS-path prepending: adding your own AS number to the path a few extra times when you announce to one neighbor, so that path looks longer and less attractive.
Before: the internet AS has two equal-length paths to 198.51.100.0/24 (64497 64500 and 64496 64500) and picks one by tie-break (Older Path). Its traffic comes in through upstream2. That's arbitrary, and it can change whenever a session resets.
Prepend twice towards transit B (64500 64500), and the internet sees 64497 64500 64500 64500 against 64496 64500. Now the choice is decided by AS path length, and traffic comes in through upstream1. Traceroute confirms it.
Look at upstream2's own view, though: it still uses the direct path to its customer, with local preference 200, despite the longer AS path. Providers give customer routes a higher local preference than anything learnt from peers or other providers. That's the business rule underneath the internet ("prefer paths you're paid for"), and it's checked before AS-path length. Prepending only influences networks that have to choose between your providers. Your providers themselves, and their other customers, still come straight to you.
What if your provider doesn't prefer its customers?
Earlier in this lab, before the upstreams had that local-preference rule, prepending towards transit A made upstream1 prefer a path to us through the internet AS and upstream2. It was no longer than our prepended announcement, and it was older. upstream1 then stopped advertising our direct path at all. Real providers don't behave like this, but it shows why the customer preference matters, and why prepending results should always be checked from outside (looking glasses, RIPE Atlas) rather than assumed.
set policy route-map TRANSIT-B-OUT rule 10 action 'permit'
set policy route-map TRANSIT-B-OUT rule 10 match ip address prefix-list 'OUR-PREFIXES'
set policy route-map TRANSIT-B-OUT rule 10 set as-path prepend '64500 64500'
set policy route-map TRANSIT-B-OUT rule 100 action 'deny'
set protocols bgp neighbor 203.0.113.0 address-family ipv4-unicast route-map export 'TRANSIT-OUT'
set protocols bgp neighbor 203.0.113.2 address-family ipv4-unicast route-map export 'TRANSIT-B-OUT'
delete policy route-map TRANSIT-A-OUT- Lines 1–4: Our /24, with two extra copies of our AS.
- Line 5: Transit A keeps the plain export.
- Line 6: Transit B gets the prepended one.
internet# show ip bgp 198.51.100.0/24
BGP routing table entry for 198.51.100.0/24, version 6
Paths: (2 available, best #1, table default)
Advertised to non peer-group peers:
203.0.113.4 203.0.113.6
64497 64500
203.0.113.6 from 203.0.113.6 (203.0.113.2)
Origin IGP, valid, external, best (Older Path)
Last update: Sat Oct 17 13:36:01 2026
64496 64500
203.0.113.4 from 203.0.113.4 (203.0.113.0)
Origin IGP, valid, external
Last update: Sat Oct 17 13:36:18 2026
internet:/# traceroute -n -q 1 -s 203.0.113.130 198.51.100.10
traceroute to 198.51.100.10 (198.51.100.10) from 203.0.113.130, 30 hops max, 46 byte packets
1 203.0.113.6 0.002 ms
2 203.0.113.3 4.439 ms
3 198.51.100.10 0.515 ms- Lines 6–10: Two paths of equal length…
- Line 8: …decided by which is older.
- Lines 16–17: Traffic enters via upstream2.
internet# show ip bgp 198.51.100.0/24
BGP routing table entry for 198.51.100.0/24, version 7
Paths: (2 available, best #1, table default)
Advertised to non peer-group peers:
203.0.113.4 203.0.113.6
64496 64500
203.0.113.4 from 203.0.113.4 (203.0.113.0)
Origin IGP, valid, external, best (AS Path)
Last update: Sat Oct 17 13:37:37 2026
64497 64500 64500 64500
203.0.113.6 from 203.0.113.6 (203.0.113.2)
Origin IGP, valid, external
Last update: Sat Oct 17 13:37:42 2026
internet:/# traceroute -n -q 1 -s 203.0.113.130 198.51.100.10
traceroute to 198.51.100.10 (198.51.100.10) from 203.0.113.130, 30 hops max, 46 byte packets
1 203.0.113.4 0.002 ms
2 203.0.113.1 3.288 ms
3 198.51.100.10 0.709 ms
upstream2# show ip bgp 198.51.100.0/24
BGP routing table entry for 198.51.100.0/24, version 5
Paths: (2 available, best #1, table default)
Advertised to non peer-group peers:
203.0.113.3 203.0.113.7
64500 64500 64500
203.0.113.3 from 203.0.113.3 (198.51.100.1)
Origin IGP, metric 0, localpref 200, valid, external, best (Local Pref)
Last update: Sat Oct 17 13:37:42 2026
64511 64496 64500
203.0.113.7 from 203.0.113.7 (203.0.113.130)
Origin IGP, valid, external
Last update: Sat Oct 17 13:37:37 2026- Line 8: Now decided by AS path length.
- Line 10: The prepended path.
- Lines 16–17: Traffic enters via upstream1.
- Line 26: upstream2 still goes straight to its customer: local preference 200 beats AS path.
upstream1# show ip bgp 198.51.100.0/24
BGP routing table entry for 198.51.100.0/24, version 4
Paths: (2 available, best #1, table default)
Advertised to non peer-group peers:
203.0.113.1 203.0.113.5
64511 64497 64500
203.0.113.5 from 203.0.113.5 (203.0.113.130)
Origin IGP, valid, external, best (Older Path)
Last update: Sat Oct 17 13:35:26 2026
64500 64500 64500
203.0.113.1 from 203.0.113.1 (198.51.100.1)
Origin IGP, metric 0, valid, external
Last update: Sat Oct 17 13:35:31 2026- Lines 6–8: upstream1 reaching its own customer through a peer and another provider…
- Lines 10–12: …instead of via the direct, prepended path.
Check your understanding
You prepend towards transit B. Which traffic still arrives over transit B?
- Traffic from transit B itself and its other customers, because they prefer customer routes by local preference
- None at all
- All of it; prepending only affects outbound traffic
- Only traffic to the prepended /32