Wednesday, 8 May 2013

BGP WEIGHT




Weight is a cisco proprietary bgp metric. Default metric is 0 for external routes and 32768 for locally generated routes. Higher value is preferred. 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-self
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 ISP2 prefers R3 to get out of its AS
Presently, ISP2’s routing table is
   Network                        Next Hop            Metric        LocPrf      Weight         Path
*  77.77.77.0/24             40.40.40.1                                                     0                      100 i
*>                                      10.10.10.1                                                     0                      100 i
*  99.99.99.0/24             10.10.10.1                                                     0                      100 i
*>                                       40.40.40.1           0                                       0                      100 i
*> 100.100.100.0/24      0.0.0.0                  0                                  32768            i
*> 100.100.101.0/24      0.0.0.0                  0                                         32768                      i
*> 100.100.102.0/24      0.0.0.0                  0                                        32768                       i
*> 100.100.103.0/24      0.0.0.0                  0                                         32768                    i
*  150.150.150.0/24        40.40.40.1                                                     0                      100 i
*>                                       10.10.10.1           0                                         0                 100 i
*  200.200.200.0              10.10.10.1                                                      0                     100 111 i
*>                                       40.40.40.1                                                       0                     100 111 i

We see that default weight is 0 for external routes and 32678 for local routes
Recall that there is no bgp default weight command, so we wld need a little tweaking
Isp2(conf)#         ip as-path access-list 1 permit  .*
                                route-map A permit 10
                                match as-path 1
                                set weight 20
                                exit
                                router bgp 222
                                nei 40.40.40.1 route-map A in
                                do clear ip bgp * in
                                do clear ip bgp * out
                                do sh ip bgp
   Network                        Next Hop            Metric        LocPrf      Weight         Path

*> 150.150.150.0/24        40.40.40.1                                                            20           100 i
*                                             10.10.10.1               0                                          0              100 i
*  200.200.200.0                10.10.10.1                                                             0             100 111 i
*>                                           40.40.40.1                                                            20           100 111 i
                               

2)  remov d cfg and ensure isp2 prefers r3 to reach 99.99.99.1 and r1 to reach 150.150.150.1

Assuming the prefix-lists, route-maps have been removed
ISP2(conf)#        ip prefix-list o seq 5 permit 150.150.150.0/24
ip prefix-list p seq 5 permit 99.99.99.0/24
route-map o permit 10
                                match ip address prefix-list o
 set weight 30
route-map o permit 20
exit
route-map p permit 10
 match ip address prefix-list p
 set weight 20
route-map p permit 20
exit
router bgp 222
neighbor 10.10.10.1 route-map o in
neighbor 40.40.40.1 route-map p in
do clear ip bgp * in
do clear ip bgp * out
do sh ip bgp

                                Network                        Next Hop            Metric        LocPrf      Weight         Path

*  150.150.150.0/24         40.40.40.1                                                             0             100 i
*>                                           10.10.10.1               0                                          30           100 i
*  99.99.99.0/24                10.10.10.1                                                             0             100 i
*>                                           40.40.40.1               0                                          20           100 i       

No comments:

Post a Comment