In the previous lesson, Weight decided the path on a single router and Local Preference steered the exit point of an entire AS.
After Weight and Local Preference, the next decision point in the BGP best-path algorithm is:
Prefer locally originated routes.
This rule applies when a router both owns a prefix (it has injected it into BGP itself) and receives the same prefix from a BGP neighbor. The router must decide which version to install.
The Scenario
Look at the topology below.
ISP1 advertises209.165.200.224/27to R1.
R1 already has this same prefix in its own LAN, and originates it locally into BGP through anetworkstatement.
Figure 1 – ISP1 advertises the prefix
In this scenario, R1:
Learns
209.165.200.224/27from ISP1 (AS 200)Also originates the same prefix internally through its own configuration
Without any extra configuration, check the BGP table directly:
R1# show bgp ipv4 unicast BGP table version is 9, local router ID is 10.0.11.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 209.165.200.224/27 0.0.0.0 0 100 32768 i * 209.165.200.224/27 10.0.11.2 0 100 0 200 iTwo paths exist for the same prefix:
The locally originated route
Next Hop =
0.0.0.0(the router itself)Weight =
32768
The route learned from ISP1
Next Hop =
10.0.11.2Weight =
0
The best-path marker
*>is on the locally originated route.
Figure 2 – Locally originated preferred
Why Does This Happen?
Cisco IOS automatically assigns:
Weight = 32768 to locally originated routes.
Since Weight is the first attribute evaluated in the BGP decision process:
32768is much higher than0The local route wins immediately, before any other attribute is even considered
No additional configuration is needed to prefer the local route.
The behavior is built into how Cisco implements the best-path algorithm.Answer the question below
What weight does Cisco IOS automatically assign to locally originated routes?
After Weight, Local Preference, and locally originated routes, BGP evaluates:
Shortest AS-PATH wins.
The AS-PATH is the list of Autonomous Systems that a prefix has crossed before reaching you.
Equal AS-PATH Length
Look at the topology below.

Figure 3 – Equal AS path length
In this scenario, AS 300 is connected to AS 200 through two links:
Link 1 between R1 and R3 (subnet
10.0.23.0/30)Link 2 between R2 and R4 (subnet
10.0.24.0/30)
AS 300 advertises its internal subnet
10.0.34.0/30toward AS 200 through both links.
Each advertisement carries the same AS-PATH:300.From R1's perspective, two paths exist toward this prefix:
One eBGP path direct via R3 (Link 1)
One iBGP path via R2, who learned it from R4 (Link 2)
Answer the question below
What is the AS-PATH advertised by AS 300 on both Link 1 and Link 2?
Initial Best Path on R1
Verify the BGP table on R1:
R1# show bgp ipv4 unicast BGP table version is 3, local router ID is 10.0.23.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path * i 10.0.12.0/30 10.0.12.2 0 100 0 i *> 0.0.0.0 0 32768 i * i 10.0.34.0/30 10.0.24.2 0 100 0 300 i *> 10.0.34.0/30 10.0.23.2 0 0 300 iThe two paths share the same attributes:
Weight is equal (
0)Local Preference is equal (
100)AS-PATH is equal (
300, length = 1 hop)
Because every higher-priority attribute is equal, BGP reaches the eBGP vs iBGP rule.
At this stage the eBGP path is preferred over the iBGP path, so R1 selects10.0.23.2(the direct eBGP link to R3 through Link 1) as the best path.R1 forwards traffic for
10.0.34.0/30directly through Link 1.
Figure 4 – Initial traffic flow through Link 1
Answer the question below
Which path does R1 prefer when all higher attributes are equal?
Configuring AS-PATH Prepending
Now imagine you are the administrator of R3 in AS 300. You want to make Link 1 less attractive from R1's perspective and force traffic to use Link 2 instead.
You cannot change R1's configuration (it belongs to another AS), but you can influence what R1 sees by artificially increasing the AS-PATH length you advertise toward R1.
This technique is called:
AS-PATH Prepending.

Figure 5 – R3 wants to prepend the AS-PATH
You configure R3 to prepend its own ASN three additional times before sending the route to R1:
R3(config)# route-map PREPEND permit 10 R3(config-route-map)# set as-path prepend 300 300 300 R3(config-route-map)# exitThen apply the route-map outbound toward R1:
R3(config)# router bgp 300 R3(config-router)# neighbor 10.0.23.1 route-map PREPEND out R3(config-router)# endYou are telling R3:
When you advertise a route toward R1, make the AS-PATH longer.

Figure 6 – AS path prepend configuration
Verifying the New Best Path
Now return to R1 and check the BGP table again:
R1# show bgp ipv4 unicast BGP table version is 4, local router ID is 10.0.23.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, t secondary path, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path * i 10.0.12.0/30 10.0.12.2 0 100 0 i *> 0.0.0.0 0 32768 i *>i 10.0.34.0/30 10.0.24.2 0 100 0 300 i * 10.0.34.0/30 10.0.23.2 0 0 300 300 300 300 iTwo things changed:
The eBGP path via Link 1 now shows AS-PATH =
300 300 300 300(4 hops)The iBGP path via R2 still shows AS-PATH =
300(1 hop)
The best-path marker
*>imoved to the iBGP path through R2, even though R1 has a direct eBGP option.
Figure 7 – Shortest AS path wins
Why? Because BGP evaluates AS-PATH length before the eBGP vs iBGP rule.
With Weight, Local Preference, and Originate all equal, the shortest AS-PATH wins:Shortest AS-PATH wins.
The path with AS-PATH
300(length 1, via R2) beats the path with300 300 300 300(length 4, direct via R3).R1 now forwards traffic for
10.0.34.0/30to R2 through iBGP, and R2 exits AS 200 via Link 2, exactly as the R3 administrator intended.When AS-PATH lengths tie, BGP keeps going down the list. Next: Origin, MED, and the final tiebreakers.
Answer the question below
Which technique artificially increases the AS-PATH length to make a path less preferred?