BGP Configuration - LOCAL PREFERENCE Attribute

In this session, we are going to see about how to configure Local Preference (BGP-Attribute).
The Topology that we are going to see is shown below:

Interface configuration for R1:
R1#configure terminal
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface fastEthernet 0/1
R1(config-if)#ip address 192.168.13.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#exi
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#end
R1#
Interface configuration for R2:
R2(config)#int
R2(config)#interface fastEthernet 0/0
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#
R2(config-if)#exit
R2(config)#interface fastEthernet 0/1
R2(config-if)#ip address 192.168.24.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#exi
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.255
R2(config-if)#end
R2#
Interface configuration for R3:
R3(config)#interface fastEthernet 0/0
R3(config-if)#ip address 192.168.13.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#interface fastEthernet 0/1
R3(config-if)#ip addre
R3(config-if)#ip address 192.168.35.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#
R3(config-if)#exi
R3(config)#
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#
R3(config-if)#end
R3#
Interface configuration for R4:
R4#configure terminal
R4(config)#interface fastEthernet 0/0
R4(config-if)#ip addre
R4(config-if)#ip address 192.168.24.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exi
R4(config)#interface fastEthernet 0/1
R4(config-if)#ip address 192.168.45.4 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#exi
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.255
R4(config-if)#exit
R4(config)#
Interface configuration for R5:
R5#configure terminal
R5(config)#interface fastEthernet 0/0
R5(config-if)#ip address 192.168.35.5 255.255.255.0
R5(config-if)#no shutdown
R5(config-if)#exit
R5(config)#int fastEthernet 0/1
R5(config-if)#ip address 192.168.45.5 255.255.255.0
R5(config-if)#no shutdown
R5(config-if)#exit
R5(config)#interface loopback 0
R5(config-if)#ip address 5.5.5.5 255.255.255.255
R5(config-if)#exit
R5(config)#interface loopback 1
R5(config-if)#ip address 55.55.55.55 255.255.255.255
R5(config-if)#end
R5#
BGP Configuration of R1:
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#router bgp 1
R1(config-router)#neighbor 3.3.3.3 remote-as 3
R1(config-router)#neighbor 3.3.3.3 update-source loopback 0
R1(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R1(config-router)#
R1(config-router)#neighbor 2.2.2.2 remote-as 1
R1(config-router)#neighbor 2.2.2.2 update-source loopback 0
R1(config-router)#neighbor 2.2.2.2 next-hop-self
R1(config-router)#
R1(config-router)#end
R1#
BGP Configuration of R2:
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2(config)#router bgp 1
R2(config-router)#
R2(config-router)#neighbor 1.1.1.1 remote-as 1
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0
R2(config-router)#neighbor 1.1.1.1 next-hop-self
R2(config-router)#neighbor 4.4.4.4 remote-as 4
R2(config-router)#neighbor 4.4.4.4 update-source loopback 0
R2(config-router)#neighbor 4.4.4.4 ebgp-multihop 2
R2(config-router)#end
R2#
BGP Configuration of R3:
R3#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#router bgp 3
R3(config-router)#
R3(config-router)#neighbor 1.1.1.1 remote-as 1
R3(config-router)#neighbor 1.1.1.1 update-source loopback 0
R3(config-router)#neighbor 1.1.1.1 ebgp-multihop 2
R3(config-router)#
R3(config-router)#neighbor 5.5.5.5 remote-as 5
R3(config-router)#neighbor 5.5.5.5 update-source loopback 0
R3(config-router)#neighbor 5.5.5.5 ebgp-multihop 2
R3(config-router)#end
R3#
BGP Configuration of R4:
R4#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#router bgp 4
R4(config-router)#
R4(config-router)#neighbor 2.2.2.2 remote-as 1
R4(config-router)#neighbor 2.2.2.2 update-source loopback 0
R4(config-router)#neighbor 2.2.2.2 ebgp-multihop 2
R4(config-router)#
R4(config-router)#neighbor 5.5.5.5 remote-as 5
R4(config-router)#neighbor 5.5.5.5 update-source loopback 0
R4(config-router)#neighbor 5.5.5.5 ebgp-multihop 5
R4(config-router)#end
R4#
BGP Configuration of R5:
R5#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#
R5(config)#router bgp 5
R5(config-router)#
R5(config-router)#neighbor 3.3.3.3 remote-as 3
R5(config-router)#neighbor 3.3.3.3 update-source loopback 0
R5(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R5(config-router)#
R5(config-router)#neighbor 4.4.4.4 remote-as 4
R5(config-router)#neighbor 4.4.4.4 update-source loopback 0
R5(config-router)#neighbor 4.4.4.4 ebgp-multihop 2
R5(config-router)#end
R5#
Configuring Static routes for reachability of Loopback IP for making BGP neighbors Up, Because we are making BGP neighbors with the help of Loopback Ip.
Static Routes in R1:
R1(config)#ip route 3.3.3.3 255.255.255.255 fastEthernet 0/1
R1(config)#
R1(config)#ip route 2.2.2.2 255.255.255.255 fastEthernet 0/0
R1(config)#*Mar 1 01:03:46.671: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up
R1(config)#*Mar 1 01:04:21.423: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Up
Static Routes in R2:
R2(config)#ip route 4.4.4.4 255.255.255.255 fastEthernet 0/1
R2(config)#
R2(config)#ip route 1.1.1.1 255.255.255.255 fastEthernet 0/0
R2(config)#*Mar 1 01:03:46.895: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up
R2(config)#*Mar 1 01:04:34.423: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 Up
R2(config)#
Static Routes in R3:
R3(config)#ip route 1.1.1.1 255.255.255.255 fastEthernet 0/0
R3(config)#
R3(config)#ip route 5.5.5.5 255.255.255.255 fastEthernet 0/1
R3(config)#*Mar 1 01:05:01.511: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up
R3(config)#
R3(config)#*Mar 1 01:05:50.019: %BGP-5-ADJCHANGE: neighbor 5.5.5.5 Up
Static Routes in R4:
R4(config)#ip route 2.2.2.2 255.255.255.255 fastEthernet 0/0
R4(config)#
R4(config)#ip route 5.5.5.5 255.255.255.255 fastEthernet 0/1
R4#*Mar 1 01:05:14.279: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up 
R4#*Mar 1 01:05:50.339: %BGP-5-ADJCHANGE: neighbor 5.5.5.5 Up
R4#
Static Routes in R5:
R5(config)#ip route 4.4.4.4 255.255.255.255 fastEthernet 0/1
R5(config)#
R5(config)#ip route 3.3.3.3 255.255.255.255 fastEthernet 0/0
R5#
*Mar 1 00:52:49.575: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Up
*Mar 1 00:52:49.915: %BGP-5-ADJCHANGE: neighbor 4.4.4.4 Up
R5#
All BGP routers form their Neighborship.
R1#show ip bgp summary | begin Neighbor
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2 4 1 24 24 1 0 0 00:20:13 0
3.3.3.3 4 3 23 23 1 0 0 00:19:38 0
We are redistributing Connected interfaces into BGP in all routes.
R1#configure terminal
R1(config)#router bgp 1
R1(config-router)#redistribute co
R1(config-router)#redistribute connected
R2(config)#router bgp 1
R2(config-router)#redistribute connected
R3(config)#router bgp 3
R3(config-router)#redistribute connected
R3(config-router)#
R4(config)#router bgp 4
R4(config-router)#redistribute connected
R5(config)#router bgp 5
R5(config-router)#redistribute connected
R5(config-router)#end
After redistributing Connected routes.
R1#show ip bgp summary | begin Neighbor
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.2.2.2  4   1  237    240    243   0   0   01:06:02     7
3.3.3.3  4   3   75      84     241   0   0  01:05:27     7
You can see that we can able to receive 7 prefixes via BGP through the 2.2.2.2 and 3.3.3.3 Neighbors.
R1#show ip bgp 5.5.5.5
BGP routing table entry for 5.5.5.5/32, version 3
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
2
4 5
2.2.2.2 from 2.2.2.2 (2.2.2.2)
Origin incomplete, metric 0, localpref 100, valid, internal
3 5
3.3.3.3 from 3.3.3.3 (3.3.3.3)
Origin incomplete, localpref 100, valid, external, best
R1#
R1#show ip bgp 55.55.55.55
BGP routing table entry for 55.55.55.55/32, version 5
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
2
4 5
2.2.2.2 from 2.2.2.2 (2.2.2.2)
Origin incomplete, metric 0, localpref 100, valid, internal
3 5
3.3.3.3 from 3.3.3.3 (3.3.3.3)
Origin incomplete, localpref 100, valid, external, best
R1#
From the above output we can see that we can see that best-path is via 3.3.3.3(AS 3) to reach the destination 5.5.5.5 of  55.55.55.55.
By default we have a local preference of 100 for all the routes.
R2#show ip bgp 5.5.5.5
BGP routing table entry for 5.5.5.5/32, version 3
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1
3 5
1.1.1.1 from 1.1.1.1 (1.1.1.1)
Origin incomplete, metric 0, localpref 100, valid, internal
4 5
4.4.4.4 from 4.4.4.4 (4.4.4.4)
Origin incomplete, localpref 100, valid, external, best
R2#
R2#R2#show ip bgp 55.55.55.55
BGP routing table entry for 55.55.55.55/32, version 4
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1
3 5
1.1.1.1 from 1.1.1.1 (1.1.1.1)
Origin incomplete, metric 0, localpref 100, valid, internal
4 5
4.4.4.4 from 4.4.4.4 (4.4.4.4)
Origin incomplete, localpref 100, valid, external, best

From the above output of R2, we can see that we can see that best-path is via 4.4.4.4(AS 4) to reach the destination 5.5.5.5 and  55.55.55.55.
Configuring Local-Preference using Route-Map on R1.
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#
R1(config)#route-map LOCAL-PREFERENCE permit 10
R1(config-route-map)#
R1(config-route-map)#set local-preference 7500
R1(config-route-map)#match ip address 1
R1(config-route-map)#exit
R1(config)#
Now we have created route-map with the name LOCAL-PREFERENCE, we have match it with the access-list 1 (Match ip address is nothing but matching the Access-list), and if it matches that Access-list 1 , it will set the weight to 7500.
R1(config)#access-list 1 permit 5.5.5.5 0.0.0.0

BGP Configuration to apply route-map to neighbor:
R1(config)#router bgp 1
R1(config-router)#neighbor 3.3.3.3 route-map LOCAL-PREFERENCE in
R1(config-router)#end
R1#
R1#clear ip bgp * soft
Just clear the BGP sessions by using the above command. Don’t forget to use the soft command, or else it will the BGP TCP sessions and BGP will be re-established.
You can now see the below output after clearing the BGP Sessions:
R1#show ip bgp 5.5.5.5
BGP routing table entry for 5.5.5.5/32, version 470
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x800
Advertised to update-groups:
2
3 5
3.3.3.3 from 3.3.3.3 (3.3.3.3)
Origin incomplete, localpref 7500, valid, external, best
R1#
R1#show ip bgp 55.55.55.55
BGP routing table entry for 55.55.55.55/32, version 471
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
Advertised to update-groups:
1
4 5
2.2.2.2 from 2.2.2.2 (2.2.2.2)
Origin incomplete, metric 0, localpref 100, valid, internal, best
We observe that local preference value is changed for the network 5.5.5.5, but the local preference is same (100) for the network 55.55.55.55
Also note that for the network 55.55.55.55 best-path changed to 2.2.2.2. Because the networks that matches the Access-list 1 will be forwarded to 3.3.3.3 (AS 3). Other routes will be moves on to the other path.
R2#show ip bgp 5.5.5.5
BGP routing table entry for 5.5.5.5/32, version 460
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Advertised to update-groups:
2
3 5
1.1.1.1 from 1.1.1.1 (1.1.1.1)
Origin incomplete, metric 0, localpref 7500, valid, internal, best
R2#show ip bgp 55.55.55.55
BGP routing table entry for 55.55.55.55/32, version 4
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Advertised to update-groups:
1
4 5
4.4.4.4 from 4.4.4.4 (4.4.4.4)
Origin incomplete, localpref 100, valid, external, best
R2#

We observe that local preference value is changed for the network 5.5.5.5, but the local preference is same (100) for the network 55.55.55.55
Note: I have not configured Route-map in R2.
Also note that for the network 5.5.5.5 best-path changed to 1.1.1.1. Because the networks that matches the Access-list 1 will be forwarded to 3.3.3.3 (AS 3). Other routes will be moves on to the other path.
Now you can see the for the prefix 5.5.5.5/32 the traffic moves via AS 3 with the Local Preference of 7500.
Note:  The routes that want to reach the network 5.5.5.5 via AS 1 will always moves through the AS 3, because of Local Preference.
Local Preference will synchronize with all the neighbors with in the same AS(IBGP).

That’s it about Weight in Local-Preference Configuration.

You can also look into my Video Tutorial :
 

Post a Comment