Wednesday, 8 May 2013

BGP LOCAL PREFERENCE



BGP Local Preference has a default of 100 and higher value is preferred. A BGP router would not display its configured local preference in the sh ip bgp command.
We can say that local preference should be applied at the edge routers  i.e. I would apply the local preference as it is coming into my network so I can tell all routers connected to me that I have this local preference.
Default configs are
R1.....................
int s0/1
ip add 20.20.20.1 255.255.255.0
no shut
int  s0/0
ip add 10.10.10.1 255.255.255.0
no shut
int lo 1         
ip add 150.150.150.1 255.255.255.0
no shut
int lo 2
ip add 150.150.151.1 255.255.255.0
no shut
exit
router eigrp 1
network 20.20.20.0 0.0.0.255
network 10.10.10.0 0.0.0.255
no auto-summary
exit
router bgp 100
nei 10.10.10.2 remote-as 222
nei 20.20.20.2 remote-as 100
nei 20.20.20.2 next-hop-selfib
nei 30.30.30.1 remote-as 100
nei 30.30.30.1 next-hop-self
bgp router-id 150.150.150.1
no synchronization
network 150.150.150.0 mask 255.255.255.0
network 150.150.151.0 mask 255.255.255.0


R2..................
int s0/0
ip add 30.30.30.2 255.255.255.0
no shut
int  s0/1
ip add 20.20.20.2 255.255.255.0
no shut
int s0/2
ip add 50.50.50.2 255.255.255.0
no shut
int lo 1
ip add 77.77.77.1 255.255.255.0
no shut
exit
router eigrp 1
network 20.20.20.0 0.0.0.255
network 30.30.30.0 0.0.0.255
network 50.50.50.0 0.0.0.255
no auto-summary
exit
router bgp 100
nei 30.30.30.1 remote-as 100
nei 30.30.30.1 next-hop-self
nei 20.20.20.1 remote-as 100
nei 20.20.20.1 next-hop-self
nei 50.50.50.1 remote-as 111
bgp router-id 77.77.77.1
no synchronization
network 77.77.77.0 mask 255.255.255.0


R3..........................
int s0/0
ip add 40.40.40.1 255.255.255.0
no shut
int s0/1
ip add 30.30.30.1 255.255.255.0
no shut
int lo 1
ip add 99.99.99.1 255.255.255.0
no shut
exit
router eigrp 1
network 30.30.30.0 0.0.0.255
network 40.40.40.0 0.0.0.255
no auto-summary
router bgp 100
nei 40.40.40.2 remote-as 222
nei 30.30.30.2 remote-as 100
nei 30.30.30.2 next-hop-self
nei 20.20.20.1 remote-as 100
nei 20.20.20.1 next-hop-self
bgp router-id 99.99.99.1
no synchronization
network 99.99.99.0 mask 255.255.255.0

ISP1..................................
int s0/0
ip add 50.50.50.1 255.255.255.0
no shut
int lo 1
ip add 200.200.200.1 255.255.255.0
no shut
exit
router bgp 111
nei 50.50.50.2 remote-as 100
bgp router-id 200.200.200.1
no synchronization
network 200.200.200.0 mask 255.255.255.0

ISP2..................
int s0/1
ip add 40.40.40.2 255.255.255.0
no shut
int  s0/0
ip add 10.10.10.2 255.255.255.0
no shut
int lo 1
ip add 100.100.100.1 255.255.255.0
no shut
int lo 2
ip add 100.100.101.1 255.255.255.0
no shut
int lo 3
ip add 100.100.102.1 255.255.255.0
no shut
int lo 4
ip add 100.100.103.1 255.255.255.0
no shut
exit
router bgp 222
nei 10.10.10.1 remote-as 100
nei 40.40.40.1 remote-as 100
bgp router-id 100.100.100.1
no synchronization
network 100.100.100.0 mask 255.255.255.0
network 100.100.101.0 mask 255.255.255.0
network 100.100.102.0 mask 255.255.255.0
network 100.100.103.0 mask 255.255.255.0


1) Ensure r2 uses r1 as to get to 100.100.100.0

Currently checking out the bgp table on R2, we have

  Network                            Next Hop            Metric                   LocPrf                   Weight                                 Path
*>i100.100.100.0/24        30.30.30.1               0                          100                         0                              222 i
* i                                           20.20.20.1               0                          100                         0                              222 i
*>i100.100.101.0/24        30.30.30.1               0                          100                         0                              222 i
* i                                           20.20.20.1               0                          100                         0                              222 i
We can see that R2 prefers to go through R3 (30.30.30.1) bcos of its lower router-id
To use local preference, we apply the config at the edge routers. We can decide to increase the local preference on R1 or decrease the local preference at R3

R1(conf)#            router bgp 100
                                bgp default local-preference 200
                                do clear ip bgp * in
                                do clear ip bgp * out
                                exit

R2#                        sh ip bgp

  Network                            Next Hop            Metric                   LocPrf                   Weight                                 Path
*>i100.100.100.0/24        20.20.20.1               0                          200                         0                              222 i
*>i100.100.101.0/24        20.20.20.1               0                          200                         0                              222 i

We observe that R2 sees only one route to the 100.100.0.0 network. This is so because R3 selected  path R1 to reach 100.100.0.0 ntwk

R3#        sh ip bgp

  Network                            Next Hop            Metric                   LocPrf                   Weight                                 Path
*>i100.100.100.0/24        20.20.20.1               0                          200                         0                              222 i
*                                             40.40.40.2               0                                                          0                              222 i
*>i100.100.101.0/24        20.20.20.1               0                          200                         0                              222 i
*                                             40.40.40.2               0                                                          0                              222 i
R3 also prefers to take R1 to get to 100.100.0.0 network. This might not be ideal for our network design and we might need to tweak this.
Guess what!! Assigning weight would fix this

No comments:

Post a Comment