Hands-On Lab: Influencing BGP Path Selection with Weight and Local Preference

This hands-on lab configures BGP weight and local preference to manually influence outbound and inbound path selection respectively, demonstrating how each attribute overrides the default best-path decision at a different point in the network.

BGP Weight AttributeLocal Preference AttributeOutbound Path Manipulation

~4 دقیقه مطالعه · آخرین به‌روزرسانی ۳ مهر ۱۴۰۵

Lab Objective

Configure BGP weight on one router to prefer a specific outbound path locally, then configure local preference to influence path selection across an entire AS, verifying the scope and precedence differences between the two attributes.

Lab Purpose

BGP's default best-path algorithm, discussed conceptually earlier in this series, considers several attributes in a strict priority order. Weight and local preference are the two highest-priority attributes an administrator commonly manipulates, but they differ fundamentally in scope: weight is Cisco-proprietary and purely local to one router, while local preference is shared across an entire AS via iBGP.

Lab Topology

R1 (AS 65020) has two paths to reach
192.168.230.0/24 in a remote AS:

Path via R2 (eBGP neighbor)
Path via R3 (eBGP neighbor, different link)

Both paths currently appear equally
viable by default BGP attributes

Task 1: Verify the Default Best Path

Confirm which path R1 currently selects by default before any manipulation.

Task 2: Configure Weight to Prefer the R2 Path

On R1, configure a higher weight for routes learned from R2 specifically.

Task 3: Verify Weight Changed the Best Path

Confirm R1 now prefers the path via R2, and that this decision is purely local to R1.

Task 4: Configure Local Preference Instead

Remove the weight configuration, and instead configure a route-map setting local preference on routes learned from R3, applied where it can propagate via iBGP.

Task 5: Verify Local Preference Propagates Further Than Weight

Confirm an iBGP neighbor of R1 also inherits the local preference-based preference, something weight alone could never achieve.

Solution and Verification

R1# show ip bgp 192.168.230.0

BGP routing table entry for 192.168.230.0/24
  65030
    10.10.10.2 from 10.10.10.2 (2.2.2.2)
      Origin IGP, metric 0, weight 0, valid, external, best
  65030
    10.20.20.2 from 10.20.20.2 (3.3.3.3)
      Origin IGP, metric 0, weight 0, valid, external
-- Both paths show weight 0 (the default),
-- and BGP's tie-breaking rules happened
-- to select the R2 path as best here

R1(config)# router bgp 65020
R1(config-router)# neighbor 10.10.10.2 weight 200

-- Weight is set directly on the neighbor
-- statement -- no route-map required for
-- this simple per-neighbor case

R1# show ip bgp 192.168.230.0

BGP routing table entry for 192.168.230.0/24
  65030
    10.10.10.2 from 10.10.10.2 (2.2.2.2)
      Origin IGP, metric 0, weight 200, valid, external, best
  65030
    10.20.20.2 from 10.20.20.2 (3.3.3.3)
      Origin IGP, metric 0, weight 0, valid, external
-- R2's path now has weight 200 and remains
-- best -- but this preference exists ONLY
-- on R1; any other router in AS 65020 has
-- no visibility into this weight value at all,
-- since weight is never carried in BGP
-- updates between routers

R1(config)# router bgp 65020
R1(config-router)# no neighbor 10.10.10.2 weight 200
R1(config-router)# neighbor 10.20.20.2 route-map SET-LOCALPREF in

R1(config)# route-map SET-LOCALPREF permit 10
R1(config-route-map)# set local-preference 200

R1# clear ip bgp 10.20.20.2 soft in

R1# show ip bgp 192.168.230.0

BGP routing table entry for 192.168.230.0/24
  65030
    10.20.20.2 from 10.20.20.2 (3.3.3.3)
      Origin IGP, metric 0, localpref 200, valid, external, best
-- The R3 path is now preferred instead,
-- driven by local preference this time

R4# show ip bgp 192.168.230.0
-- (R4, an iBGP neighbor of R1 within the
--  same AS 65020)

BGP routing table entry for 192.168.230.0/24
  65030
    10.20.20.2 from 10.10.10.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 200, valid, internal, best
-- R4 sees the SAME localpref value (200)
-- that R1 set, since local preference is
-- explicitly carried within iBGP updates --
-- something weight, confined to R1 alone,
-- could never accomplish

Key Takeaway

Weight and local preference solve conceptually similar problems at different scopes: weight is the fastest, simplest way to influence one router's own path choice but stops entirely at that router's boundary, while local preference is the correct tool whenever every router within the AS needs to make a consistent, coordinated path decision — reaching for weight when the actual goal is AS-wide consistency is a common mistake that produces inconsistent path selection across different routers in the same AS.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Hands-On Lab: Final Comprehensive CCNP Troubleshooting Challenge (BGP, DMVPN, and QoS Integration)

This hands-on lab presents a complex multi-layer failure across an integrated BGP-over-DMVPN topology combined with QoS marking, requiring systematic diagnosis of a route reflector misconfiguration, an NHRP registration failure, and an incorrectly applied QoS policy simultaneously affecting the same network.

ادامه

Hands-On Lab: Configuring BGP over DMVPN

This hands-on lab runs iBGP as the routing protocol across the same DMVPN hub-and-spoke topology used in the two previous labs, configuring the hub as a route reflector so spokes learn each other's routes without a full iBGP mesh, combining two previously separate concepts into one integrated design.

ادامه

Hands-On Lab: Configuring OSPF over DMVPN

This hands-on lab runs OSPF as the dynamic routing protocol across the same DMVPN hub-and-spoke topology, configuring the tunnel interface as an OSPF point-to-multipoint network type to correctly handle the hub-and-spoke adjacency pattern without requiring the broadcast network type's DR/BDR election.

ادامه

Hands-On Lab: Configuring EIGRP over DMVPN

This hands-on lab runs EIGRP as the dynamic routing protocol across the DMVPN hub-and-spoke topology built in earlier labs, verifying neighbor relationships form correctly across the multipoint tunnel and routes propagate without requiring per-spoke static configuration on the hub.

ادامه

Hands-On Lab: Configuring HSRP MD5 Authentication

This hands-on lab configures MD5 authentication on an HSRP group, verifying two routers with matching authentication strings form a normal active/standby relationship while a router with a mismatched string is excluded from the group entirely.

ادامه

Hands-On Lab: Configuring Cisco Umbrella-Style DNS Security via DNS Forwarding Redirection

This hands-on lab configures a router to redirect all client DNS queries toward a security-focused DNS resolver using DNS forwarding interception, approximating cloud-delivered DNS security enforcement without requiring per-client configuration changes.

ادامه