BGP Attributes - Local Preference
October 29th, 2008 in
BGP | tags:
BGP,
local preference
In the previous post I explained how MED (Multi-Exit Discriminator) works. In this post I will explain how Local Preference works.
MED is commonly used to manipulate how traffic enters your network, Local Preference is commonly used to manipulate how traffic exits your network.
Local Preference has a default value of 100 and a higher value is preferred.

For this article I used the same topology as in the previous article about MED but with only a small adjustement. I added router R14, you can grab the GNS3 configuration-file here. If you want to do this lab yourself you can start off with the configurations mentioned in the article MPLS Basic - Part 2, the only adjustments you need to make from there is the config below for R14 and remove the default-route on router R2.
R14 :
|
|
|
hostname R14
!
interface FastEthernet0/0
ip address 150.1.214.14 255.255.255.0
duplex auto
speed auto
!
ip route 0.0.0.0 0.0.0.0 150.1.214.2
|
R2 :
|
|
|
no ip route 0.0.0.0 0.0.0.0 150.1.61.1
|
Now that you are ready to rumble let’s start with implementing BGP on R2 :
R2 :
|
|
|
router bgp 65010
no synchronization
bgp log-neighbor-changes
network 10.10.2.0 mask 255.255.255.0
network 150.1.214.0 mask 255.255.255.0
neighbor 150.1.61.6 remote-as 65010
neighbor 150.1.61.13 remote-as 65010
no auto-summary
|
As you can see we are going to set up a BGP session with router R13 and router R6. For router R2 to reach the loopback-address of router R5 we need to issue the “neighbor 150.1.61.2 next-hop-self” command on router R6 and router R13. This we need to do since router R2 has no clue how to reach the 150.1.31.3 150.1.46.4 networks. See below before the “neighbor 150.1.61.2 next-hop-self” commands issued on router R13 and router R6. Notice that there isn’t a “greater than” sign next to the 10.10.5.0 route.
R2 :
|
|
|
R2#sh ip bgp
BGP table version is 12, local router ID is 150.1.2.2
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
*> 10.10.2.0/24 0.0.0.0 0 32768 i
* i10.10.5.0/24 150.1.31.3 0 210 0 1 65011 i
* i 150.1.46.4 0 200 0 1 65011 i
*>i10.10.6.0/24 150.1.61.6 0 100 0 i
*>i10.10.13.0/24 150.1.61.13 0 100 0 i
* i150.1.31.0/24 150.1.31.3 0 100 0 1 ?
* i 150.1.46.4 0 100 0 1 ?
* i150.1.45.0/24 150.1.31.3 0 100 0 1 ?
* i 150.1.46.4 0 100 0 1 ?
* i150.1.46.0/24 150.1.31.3 0 100 0 1 ?
* i 150.1.46.4 0 100 0 1 ?
*> 150.1.214.0/24 0.0.0.0 0 32768 i
|
Now let’s issue the “neighbor 150.1.61.2 next-hop-self” under the BGP process on router R6 and router R13. After that let’s do a “sh ip bgp” again on router R2 :
R2 :
|
|
|
R2#sh ip bgp
BGP table version is 12, local router ID is 150.1.2.2
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
*> 10.10.2.0/24 0.0.0.0 0 32768 i
*>i10.10.5.0/24 150.1.61.13 0 210 0 1 65011 i
*>i10.10.6.0/24 150.1.61.6 0 100 0 i
*>i10.10.13.0/24 150.1.61.13 0 100 0 i
r>i10.10.22.0/24 150.1.61.6 0 100 0 i
* i150.1.31.0/24 150.1.61.13 0 100 0 1 ?
*>i 150.1.61.6 0 100 0 1 ?
* i150.1.45.0/24 150.1.61.13 0 100 0 1 ?
*>i 150.1.61.6 0 100 0 1 ?
* i150.1.46.0/24 150.1.61.13 0 100 0 1 ?
*>i 150.1.61.6 0 100 0 1 ?
*> 150.1.214.0/24 0.0.0.0 0 32768 i
|
Notice the difference? Now router R2 does have a route to the 150.1.31.3 150.1.46.4 networks since router R6 and router R13 are the next-hop for those nextworks now.
R6 :
|
|
|
R6#sh run | b router bgp
router bgp 65010
no synchronization
bgp log-neighbor-changes
network 10.10.2.0 mask 255.255.255.0
network 10.10.6.0 mask 255.255.255.0
network 10.10.22.0 mask 255.255.255.0
neighbor 150.1.46.4 remote-as 1
neighbor 150.1.46.4 route-map LOCALPREF in
neighbor 150.1.61.2 remote-as 65010
neighbor 150.1.61.2 next-hop-self
neighbor 150.1.61.13 remote-as 65010
no auto-summary
!
ip prefix-list R5 seq 5 permit 10.10.5.0/24
!
route-map LOCALPREF permit 10
match ip address prefix-list R5
set local-preference 200
!
route-map LOCALPREF permit 20
|
R13 :
|
|
|
router bgp 65010
no synchronization
bgp log-neighbor-changes
network 10.10.2.0 mask 255.255.255.0
network 10.10.13.0 mask 255.255.255.0
network 10.10.22.0 mask 255.255.255.0
redistribute static route-map DS
neighbor 150.1.31.3 remote-as 1
neighbor 150.1.31.3 route-map LOCALPREF in
neighbor 150.1.61.2 remote-as 65010
neighbor 150.1.61.2 next-hop-self
neighbor 150.1.61.6 remote-as 65010
no auto-summary
!
ip prefix-list R5 seq 5 permit 10.10.5.0/24
!
route-map LOCALPREF permit 10
match ip address prefix-list R5
set local-preference 5
!
route-map LOCALPREF permit 20
|
R14 :
|
|
|
interface FastEthernet0/0
ip address 150.1.214.14 255.255.255.0
duplex auto
speed auto
!
ip route 0.0.0.0 0.0.0.0 150.1.214.2
|
Traceroute from R14 to R5 :
R14 :
|
|
|
R14#traceroute 10.10.5.5
Type escape sequence to abort.
Tracing the route to 10.10.5.5
1 150.1.214.2 28 msec 68 msec 76 msec
2 150.1.61.6 56 msec 84 msec 100 msec
3 150.1.46.4 52 msec 484 msec 280 msec
4 150.1.45.5 296 msec 220 msec *
|
You can now see that because the Local Preference is higher on router R6 traffic flows via router R6 to router R5. The make the traffic go via router R13 again let’s put the higher Local Preference on router R13. Let’s set it to 210.
After changing the local preference on R13 to 210 :
R2 :
|
|
|
R2#sh ip bgp
BGP table version is 16, local router ID is 150.1.2.2
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
*> 10.10.2.0/24 0.0.0.0 0 32768 i
*>i10.10.5.0/24 150.1.61.13 0 210 0 1 65011 i
*>i10.10.6.0/24 150.1.61.6 0 100 0 i
r>i10.10.22.0/24 150.1.61.6 0 100 0 i
* i150.1.31.0/24 150.1.61.13 0 100 0 1 ?
*>i 150.1.61.6 0 100 0 1 ?
* i150.1.45.0/24 150.1.61.13 0 100 0 1 ?
*>i 150.1.61.6 0 100 0 1 ?
* i150.1.46.0/24 150.1.61.13 0 100 0 1 ?
*>i 150.1.61.6 0 100 0 1 ?
*> 150.1.214.0/24 0.0.0.0 0 32768 i
|
As you see in router’s R2 bgp table traffic destined for 10.10.5.5 will now go via router R13. Now let’s do a traceroute from router R14 to router R5 :
R14 :
|
|
|
R14#traceroute 10.10.5.5
Type escape sequence to abort.
Tracing the route to 10.10.5.5
1 150.1.214.2 136 msec 108 msec 60 msec
2 150.1.61.13 40 msec 88 msec 96 msec
3 150.1.31.3 84 msec 96 msec 188 msec
4 150.1.13.1 204 msec 188 msec 124 msec
5 150.1.45.4 128 msec 164 msec 300 msec
6 150.1.45.5 352 msec 260 msec *
|
Buy:Cialis.Viagra.Levitra.VPXL.Cialis Professional.Cialis Super Active+.Maxaman.Super Active ED Pack.Viagra Soft Tabs.Cialis Soft Tabs.Zithromax.Soma.Viagra Professional.Viagra Super Active+.Viagra Super Force.Propecia.Tramadol….