In this post we will be focusing on an very important BGP Attribute -Local Preference.
- Local Preference is an Well-Known Discretionary BGP Attribeute.
- It is not local to the router but local to an AS .
- It is exchanged with iBGP neighbor.
- Local Preference set on an router in an AS is propagated to all the internal routers of that AS.
- It is not exchanged with eBGP neighbor
- Used to manipulate the outbound traffic decision of an AS.
- Higher Local Preference is preferred .
- Default value is 100.
R1#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0 unassigned YES unset administratively down down
Serial0 12.0.0.1 YES manual up up
Serial1 13.0.0.1 YES manual up up
Serial2 unassigned YES unset administratively down down
Serial3 unassigned YES unset administratively down down
R1#sh int des
Interface Status Protocol Description
Fa0 admin down down
Se0 up up connection to R2
Se1 up up connection to R3
Se2 admin down down
Se3 admin down down
R1#sh ip bgp sum
BGP router identifier 13.0.0.1, local AS number 100
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.0.0.2 4 200 13 13 1 0 0 00:10:43 0
13.0.0.3 4 200 11 11 1 0 0 00:07:46 0
R2#sh int des
Interface Status Protocol Description
Fa0 admin down down
Se0 up up connection to R1
Se1 up up connection to R4
Se2 admin down down
Se3 admin down down
R2#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0 unassigned YES unset administratively down down
Serial0 12.0.0.2 YES manual up up
Serial1 24.0.0.2 YES manual up up
Serial2 unassigned YES unset administratively down down
Serial3 unassigned YES unset administratively down down
R2#sh ip bgp sum
BGP router identifier 24.0.0.2, local AS number 200
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.0.0.1 4 100 14 14 1 0 0 00:11:26 0
24.0.0.4 4 200 13 14 1 0 0 00:10:35 0
R3#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0 unassigned YES unset administratively down down
Serial0 34.0.0.3 YES manual up up
Serial1 13.0.0.3 YES manual up up
Serial2 unassigned YES unset administratively down down
Serial3 unassigned YES unset administratively down down
R3#sh int des
Interface Status Protocol Description
Fa0 admin down down
Se0 up up connection to R4
Se1 up up connection to R1
Se2 admin down down
Se3 admin down down
R3#sh ip bgp sum
BGP router identifier 34.0.0.3, local AS number 200
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
13.0.0.1 4 100 13 13 1 0 0 00:09:14 0
34.0.0.4 4 200 12 12 1 0 0 00:08:41 0
R4#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0 unassigned YES unset administratively down down
Serial0 34.0.0.4 YES manual up up
Serial1 24.0.0.4 YES manual up up
Serial2 unassigned YES unset administratively down down
Serial3 unassigned YES unset administratively down down
R4#sh int des
Interface Status Protocol Description
Fa0 admin down down
Se0 up up connection to R3
Se1 up up connection to R2
Se2 admin down down
Se3 admin down down
R4#sh ip bgp sum
BGP router identifier 34.0.0.4, local AS number 200
BGP table version is 1, main routing table version 1
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
24.0.0.2 4 200 15 14 1 0 0 00:11:51 0
34.0.0.3 4 200 13 13 1 0 0 00:09:12 0
!!! Lets configure an LOOPBACK INTERFACE ON R1 AND ADVERTISE SAME IN BGP
R1(config)#int loopback 0
R1(config-if)#ip address 100.0.0.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#^Z
R1(config)#router bgp 100
R1(config-router)#network 100.0.0.0 mask 255.255.255.0
R1(config-router)#network 12.0.0.0 mask 255.255.255.0
R1(config-router)#network 13.0.0.0 mask 255.255.255.0
R1(config-router)#^Z
R2(config)#router bgp 200
R2(config-router)#network 12.0.0.0 mask 255.255.255.0
R2(config-router)#network 24.0.0.0 mask 255.255.255.0
R2(config-router)#^Z
R3(config)#router bgp 200
R3(config-router)#network 34.0.0.0 mask 255.255.255.0
R3(config-router)#network 13.0.0.0 mask 255.255.255.0
R3(config-router)#^Z
R4(config)#router bgp 200
R4(config-router)#network 34.0.0.0 mask 255.255.255.0
R4(config-router)#network 24.0.0.0 mask 255.255.255.0
R4(config-router)#^Z
Lets check on R4 what is path to reach 100.0.0.0/24 network .
R4#sh ip bgp
BGP table version is 11, local router ID is 34.0.0.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i12.0.0.0/24 34.0.0.3 0 100 0 100 i
*>i 24.0.0.2 0 100 0 100 i
*>i13.0.0.0/24 24.0.0.2 0 100 0 100 i
* i 34.0.0.3 0 100 0 100 i
*> 24.0.0.0/24 0.0.0.0 0 32768 i
*> 34.0.0.0/24 0.0.0.0 0 32768 i
* i100.0.0.0/24 34.0.0.3 0 100 0 100 i
*>i 24.0.0.2 0 100 0 100 i
On R4 we can see that to reach 100.0.0.0/24 network there are 2 path
having next hop 24.0.0.2 and 34.0.0.3 and both are reachable .
Path 1 - via 24.0.0.2 i.e via R2
Path 2 - via 34.0.0.2 i.e via R3
Path 1 is preferred here
R4#traceroute 100.0.0.1
Type escape sequence to abort.
Tracing the route to 100.0.0.1
1 24.0.0.2 20 msec 40 msec 8 msec
2 12.0.0.1 [AS 100] 64 msec 36 msec 44 msec
R4#traceroute 100.0.0.1
Type escape sequence to abort.
Tracing the route to 100.0.0.1
1 24.0.0.2 20 msec 40 msec 8 msec
2 12.0.0.1 [AS 100] 64 msec 36 msec 44 msec
Now we will use LOCAL PREFERENCE and make Path 2 preferred path.
i.e we will be changing the outbound path for AS 200 to reach 100.0.0.0/24 which belongs to some different AS.
Here we can check the local preference both paths is 100
R3(config)#route-map TECHSTUFF
R3(config-route-map)#set local-preference 200
R3(config-route-map)#^Z
R3#sh route-map TECHSTUFF
route-map TECHSTUFF, permit, sequence 10
Match clauses:
Set clauses:
local-preference 200
Policy routing matches: 0 packets, 0 bytes
R3(config)#router bgp 200
R3(config-router)#neighbor 13.0.0.1 route-map TECHSTUFF in
R3(config-router)#^Z
R3#
R3#clear ip bgp * soft in
R3#clear ip bgp * soft out
R4#sh ip bgp
BGP table version is 8, local router ID is 34.0.0.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i12.0.0.0/24 34.0.0.3 0 200 0 100 i
* i 24.0.0.2 0 100 0 100 i
* i13.0.0.0/24 24.0.0.2 0 100 0 100 i
*>i 34.0.0.3 0 200 0 100 i
*> 24.0.0.0/24 0.0.0.0 0 32768 i
*> 34.0.0.0/24 0.0.0.0 0 32768 i
*>i100.0.0.0/24 34.0.0.3 0 200 0 100 i
* i 24.0.0.2 0 100 0 100 i
R4#traceroute 100.0.0.1
Type escape sequence to abort.
Tracing the route to 100.0.0.1
1 34.0.0.3 36 msec 36 msec 20 msec
2 13.0.0.1 64 msec 60 msec 68 msec
Now we can check that the Path 2 is selected .
This is how we can use Local Preference for manipulating outbounding traffic of an AS .
Hope you all find the post useful !!!!!!
Thanks for reading
No comments:
Post a Comment