The LOCAL_PREF Attribute
Commands References
admin@XorPlus# set protocols bgp local-preference <0- 4294967295>
Note: This command is to set the value of local-preference. It also affects the BGP decision process. If multiple paths for the same prefix are available, the path with the larger local preference value is preferred. LOCAL_PREF is an AS-wide attribute at the highest level of the BGP decision process. It is considered before the AS path length. A longer path with a larger local preference is preferred over a shorter path with a smaller local preference.
Figure 1-17
Step 1: Configure BGP as TOPO displayed
Switch A:
admin@XorPlus# set protocols bgp bgp-id 6.6.6.6 admin@XorPlus# set protocols bgp local-as 9 admin@XorPlus# set protocols bgp peer 1001::2 local-ip "1001::1" admin@XorPlus# set protocols bgp peer 1001::2 as "9" admin@XorPlus# set protocols bgp peer 1001::2 ipv6-unicast true admin@XorPlus# set protocols bgp peer 3003::2 local-ip "3003::1" admin@XorPlus# set protocols bgp peer 3003::2 as "9" admin@XorPlus# set protocols bgp peer 3003::2 ipv6-unicast true
Switch B:
admin@XorPlus# set protocols bgp bgp-id 26.26.26.26 admin@XorPlus# set protocols bgp local-as "9" admin@XorPlus# set protocols bgp peer 1001::1 local-ip "1001::2" admin@XorPlus# set protocols bgp peer 1001::1 as 9 admin@XorPlus# set protocols bgp peer 1001::1 next-hop-self true admin@XorPlus# set protocols bgp peer 1001::1 ipv6-unicast true admin@XorPlus# set protocols bgp peer 2002::2 local-ip "2002::1" admin@XorPlus# set protocols bgp peer 2002::2 as "12" admin@XorPlus# set protocols bgp peer 2002::2 ipv6-unicast true
Switch C:
admin@XorPlus# set protocols bgp bgp-id 9.9.9.9 admin@XorPlus# set protocols bgp local-as "9" admin@XorPlus# set protocols bgp peer 3003::1 local-ip "3003::2" admin@XorPlus# set protocols bgp peer 3003::1 as 9 admin@XorPlus# set protocols bgp peer 3003::1 next-hop-self true admin@XorPlus# set protocols bgp peer 3003::1 ipv6-unicast true admin@XorPlus# set protocols bgp peer 5005::2 local-ip "5005::1" admin@XorPlus# set protocols bgp peer 5005::2 as "10" admin@XorPlus# set protocols bgp peer 5005::2 ipv6-unicast true
Switch D:
admin@XorPlus# set protocols bgp bgp-id 44.44.44.44 admin@XorPlus# set protocols bgp local-as 12 admin@XorPlus# set protocols bgp peer 2002::1 local-ip "2002::2" admin@XorPlus# set protocols bgp peer 2002::1 as 9 admin@XorPlus# set protocols bgp peer 2002::1 ipv6-unicast true
Switch E:
admin@XorPlus# set protocols bgp bgp-id 33.33.33.33 admin@XorPlus# set protocols bgp local-as 10 admin@XorPlus# set protocols bgp peer 5005::1 local-ip "5005::2" admin@XorPlus# set protocols bgp peer 5005::1 as 9 admin@XorPlus# set protocols bgp peer 5005::1 ipv6-unicast true
Step 2: Switch D and Switch E propagate BGP route entry 9999::/64 to Switch B and Switch C
Note: check the BGP route table on Switch A.
Switch B:
admin@XorPlus# run show bgp routes ipv6 Status Codes: * valid route, > best route Origin Codes: i IGP, e EGP, ? incomplete Prefix Nexthop Peer AS Path ---------------------------- ------------------------ --------------- ------------ *> 9999::/64 2002::2 44.44.44.44 12 i
Switch C:
admin@XorPlus# run show bgp routes ipv6 Status Codes: * valid route, > best route Origin Codes: i IGP, e EGP, ? incomplete Prefix Nexthop Peer AS Path ---------------------------- ------------------------ --------------- ------------ *> 9999::/64 5005::2 33.33.33.33 10 i
Switch A:
admin@XorPlus# run show bgp routes ipv6 Status Codes: * valid route, > best route Origin Codes: i IGP, e EGP, ? incomplete Prefix Nexthop Peer AS Path ---------------------------- ------------------------ --------------- ------------ * 9999::/64 1001::2 26.26.26.26 12 i *> 9999::/64 3003::2 9.9.9.9 10 i admin@XorPlus# run show bgp routes ipv6 detail 9999::/64 From peer: 9.9.9.9 Route: Winner Origin: IGP AS Path: 10 Nexthop: 3003::2 Local Preference: 100 9999::/64 From peer: 26.26.26.26 Route: Not Used Origin: IGP AS Path: 12 Nexthop: 1001::2 Local Preference: 100 admin@XorPlus#
Note: The Local-Preference all is 100 the two BGP route entry.
Step 3: Modify the Local-Preference value on Switch B
Switch B:
admin@XorPlus# set protocols bgp local-preference 200
Switch A:
admin@XorPlus# run show bgp routes ipv6 Status Codes: * valid route, > best route Origin Codes: i IGP, e EGP, ? incomplete Prefix Nexthop Peer AS Path ---------------------------- ------------------------ --------------- ------------ * 9999::/64 3003::2 9.9.9.9 10 i *> 9999::/64 1001::2 26.26.26.26 12 i admin@XorPlus# run show bgp routes ipv6 detail 9999::/64 From peer: 9.9.9.9 Route: Not Used Origin: IGP AS Path: 10 Nexthop: 3003::2 Local Preference: 100 9999::/64 From peer: 26.26.26.26 Route: Winner Origin: IGP AS Path: 12 Nexthop: 1001::2 Local Preference: 200 admin@XorPlus#
Note: The best route is coming from Switch B, as the BGP route entry from Switch B has a larger Local-Preference value. It will select the BGP route entry with smaller Local-Preference value if other attributes all have the same priority.
Step 4: Modify the Local-Preference larger than Switch B on Switch C
Switch C:
admin@XorPlus# set protocols bgp local-preference 300
Switch A:
admin@XorPlus# run show bgp routes ipv6 Status Codes: * valid route, > best route Origin Codes: i IGP, e EGP, ? incomplete Prefix Nexthop Peer AS Path ---------------------------- ------------------------ --------------- ------------ * 9999::/64 1001::2 26.26.26.26 12 i *> 9999::/64 3003::2 9.9.9.9 10 i admin@XorPlus# run show bgp routes ipv6 detail 9999::/64 From peer: 9.9.9.9 Route: Winner Origin: IGP AS Path: 10 Nexthop: 3003::2 Local Preference: 300 9999::/64 From peer: 26.26.26.26 Route: Not Used Origin: IGP AS Path: 12 Nexthop: 1001::2 Local Preference: 200 admin@XorPlus#
Note: The BGP speaker selects the BGP route entry with larger Local-Preference.
Copyright © 2025 Pica8 Inc. All Rights Reserved.