BGP Local Preference Configuration [GNS3 Lab]

What is Local Preference

Local Preference: Local preference is a BGP attribute used to choose the outbound external BGP path. Local preference is sent to all internal BGP routers in the autonomous system, and the path with the highest local preference is preferred. The default Local Preference value is 100.

Topology


Before manipulating the outgoing path from the AS 65010 via Local Preference, let’s first check the routing table of R6 toward R3 loopback0 3.3.3.3/32:

R6#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [200/0] via 172.17.0.6, 00:30:04
      172.17.0.0/16 is variably subnetted, 4 subnets, 2 masks
C        172.17.0.0/30 is directly connected, FastEthernet0/1
L        172.17.0.1/32 is directly connected, FastEthernet0/1
C        172.17.0.4/30 is directly connected, FastEthernet0/0
L        172.17.0.5/32 is directly connected, FastEthernet0/0

R6#show ip bgp
BGP table version is 7, local router ID is 172.17.0.5
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,
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 3.3.3.3/32       172.17.0.2               0    100      0 65004 65003 i
 *>i                  172.17.0.6               0    100      0 65001 65003 i
R6#

We can see that currently, the route to 3.3.3.3/32 is via R2 router (172.17.0.6).


Local Preference Configuration

Let’s dive in Local Preference configuration:

On router R2:

R2:

router bgp 65010
 bgp log-neighbor-changes
 neighbor 172.16.20.1 remote-as 65001
 neighbor 172.16.20.1 route-map LOCAL-PREF-200 in
 neighbor 172.17.0.5 remote-as 65010
 neighbor 172.17.0.5 next-hop-self
!
!
route-map LOCAL-PREF-200 permit 10
 set local-preference 200


On router R5:


router bgp 65010
 bgp log-neighbor-changes
 neighbor 172.17.0.1 remote-as 65010
 neighbor 172.17.0.1 next-hop-self
 neighbor 172.17.20.2 remote-as 65004
 neighbor 172.17.20.2 route-map LOCAL-PREF-400 in
!
!
route-map LOCAL-PREF-400 permit 10
 set local-preference 400


Verifications

We first check the local preference on R2 and R5:

R5#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>  3.3.3.3/32       172.17.20.2                   400      0 65004 65003 i


R2#show ip bgp
     Network          Next Hop            Metric LocPrf Weight Path
 *>  3.3.3.3/32       172.16.20.1                   200      0 65001 65003 i


Now, Let’s recheck the routing table of R6:

R6#show ip bgp
BGP table version is 1, local router ID is 172.17.0.5
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,
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 3.3.3.3/32       172.17.0.2               0    400      0 65004 65003 i
R6#show ip ro
R6#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is not set

      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [200/0] via 172.17.0.2, 00:02:15
      172.17.0.0/16 is variably subnetted, 4 subnets, 2 masks
C        172.17.0.0/30 is directly connected, FastEthernet0/1
L        172.17.0.1/32 is directly connected, FastEthernet0/1
C        172.17.0.4/30 is directly connected, FastEthernet0/0
L        172.17.0.5/32 is directly connected, FastEthernet0/0
R6#

We can that LocPrf for route 3.3.3.3/32 is 400 in R6 (even though there is no Local preference configured on R6, the Local Preference attribute is propagated from R2 and R5 into the AS 65010, and therefore R6 will get BGP updates with the local preference set.

As a result, R6 will prefer the neighbor with the higher Local Preference for the 3.3.3.3/32 route.


BGP default local-preference

Note

We can use the BGP default local-preference command in BGP configuration mode to change the default value of the local preference. This command will only be applied to received routes that do not have the local-preference value specifically set (route-map override default local preference value, like it does basically with 100 value).

let’s try this on our example:

router bgp 65010
 bgp default local-preference 500

With this, all routes coming from the BGP process will have a local preference of 500, we can verify on R6:

R6#show ip bgp
BGP table version is 3, local router ID is 172.17.0.5
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,
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 3.3.3.3/32       172.17.0.6               0    500      0 65001 65003 i
 * i                  172.17.0.2               0    400      0 65004 65003 i


https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA10g000000ClszCAC

Bilel A

Bilel A

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Learn Duty
0
Would love your thoughts, please comment.x
()
x