Wednesday, 8 May 2013

BGP MED



This is used to influence return traffic from our neighbouring AS. Lower value is better. Default is 0

RULES OF MED

1) MED is not propagated outside the receiving AS
2) MED attribute would never be used if the ASes being compared are from different AS except we configure bgp always compare med
3) BGP best-path med missing –med-worst command is used to represent a missing med
4) BGP best path med confederation allows us to use MED within a confederation
5) BGP determistic med command would compare med before it compares origin code in route-selection
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


Task 1) Ensure that ISP2 receives the traffic towards 100.100.101.0/24 from R1, and the traffic towards 100.100.100.0/24 from R3. Use MED to accomplish the goal.
On R1, bgp table is

  Network                            Next Hop            Metric                   LocPrf                   Weight                 Path
* i100.100.100.0/24         30.30.30.1               0                          100                         0                              222 i
*>                                           10.10.10.2               0                                                          0                              222 i
* i100.100.101.0/24         30.30.30.1               0                          100                         0                              222 i
*>                                           10.10.10.2               0                                                          0                              222 i
* i100.100.102.0/24         30.30.30.1               0                          100                         0                              222 i
*>                                           10.10.10.2               0                                                          0                              222 i
* i100.100.103.0/24         30.30.30.1               0                          100                         0                              222 i
*>                                           10.10.10.2               0                                                          0                              222 i

On R3, bgp table is
  Network                            Next Hop            Metric                   LocPrf                   Weight                                 Path
* i100.100.100.0/24         20.20.20.1               0                          100                         0                              222 i
*>                                            40.40.40.2               0                                                         0                              222 i
* i100.100.101.0/24         20.20.20.1               0                          100                         0                              222 i
*>                                           40.40.40.2               0                                                          0                              222 i
* i100.100.102.0/24         20.20.20.1               0                          100                         0                              222 i
*>                                           40.40.40.2               0                                                          0                              222 i
* i100.100.103.0/24         20.20.20.1               0                          100                         0                              222 i
*>                                           40.40.40.2               0                                                          0                              222 i

Now, to influence AS 100 to take 10.10.10.2 for 100.100.100.0 and to 40.40.40.2 for  100.100.101.0
ISP2(conf)           ip prefix-list o seq 5 permit 100.100.101.0/24
ip prefix-list p seq 5 permit 100.100.100.0/24
                                route-map o permit 10
                                match ip address prefix-list o
                                set metric 300
                                exit
route-map o permit 20
exit
route-map p permit 10
 match ip address prefix-list p
 set metric 200
exit
route-map p permit 20
exit
router bgp 222
neighbor 10.10.10.1 route-map o out
neighbor 40.40.40.1 route-map p out

Now lets check R1 bgp table
  Network                            Next Hop            Metric                  LocPrf                   Weight                                 Path
*> 100.100.100.0/24        10.10.10.2               0                                                          0                              222 i
*>i100.100.101.0/24        30.30.30.1               0                          100                         0                              222 i
*                                             10.10.10.2             300                                                        0                              222 i

and r3’s bgp table

  Network                            Next Hop            Metric                  LocPrf                   Weight                                 Path
*>i100.100.100.0/24        20.20.20.1               0                          100                         0                              222 i
*                                             40.40.40.2             200                                                        0                              222 i
*> 100.100.101.0/24        40.40.40.2               0                                                          0                              222 i
Hence we see that AS 100 chooses R1 to get to 100.100.100.0 ntwk and R2 to get to 100.100.101.0 ntwk

Task 2) cfg R1 such that routes without MED configured are set to zero

R1(conf)#            router bgp 100
                                bgp  bestpath med missing-as-worst

No comments:

Post a Comment