BGP MED

Multi Exit Discriminator (MED) Attribute

L’attribut « MED » (ou metric) est transmis aux voisins BGP, il permet de suggérer aux AS voisin une préférence pour le trafic entrant.

 

  • Codé sur 32bits
  • la valeur la pus petite est préférée

 

Routage par défaut de R1:

R1#sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*  2.0.0.0          10.1.12.2                0             0 200 i
*>                  10.1.14.4                              0 200 i
*  3.0.0.0          10.1.12.2                              0 200 i
*>                  10.1.14.4                              0 200 i
*  4.0.0.0          10.1.12.2                              0 200 i
*>                  10.1.14.4                0             0 200 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*  22.0.0.0         10.1.12.2                0             0 200 i
*>                  10.1.14.4                              0 200 i
*  33.0.0.0         10.1.12.2                              0 200 i
*>                  10.1.14.4                              0 200 i

Configuration

L’AS 200 transmet à l’AS100 les metric de ses prefix :

R2#conf t
R2(config)#route-map TEST permit 10
R2(config-route-map)#set metric 100
R2(config)#router bgp 200
R2(config-router)#neighbor 10.1.12.1 route-map TEST out
  • 10.1.12.1 = R1
R4#conf t
R4(config)#route-map TEST permit 10
R4(config-route-map)#set metric 50
R4(config)#router bgp 200
R4(config-router)#neighbor 10.1.14.1 route-map TEST out
  • 10.1.14.1 = R1

Vérification :

R1#sh ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*  2.0.0.0          10.1.12.2              100             0 200 i
*>                  10.1.14.4               50             0 200 i
*  3.0.0.0          10.1.12.2              100             0 200 i
*>                  10.1.14.4               50             0 200 i
*  4.0.0.0          10.1.12.2              100             0 200 i
*>                  10.1.14.4               50             0 200 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*  22.0.0.0         10.1.12.2              100             0 200 i
*>                  10.1.14.4               50             0 200 i
*  33.0.0.0         10.1.12.2              100             0 200 i
*>                  10.1.14.4               50             0 200 i

Configuration par Prefix

R2
access-list 3 permit 3.0.0.0 0.255.255.255
access-list 33 permit 33.0.0.0 0.255.255.255
!
route-map TEST1 permit 10
 match ip address 3
 set metric 50
!
route-map TEST1 permit 20
 match ip address 33
 set metric 100
!
route-map TEST1 permit 30
!
router bgp 200
 neighbor 10.1.12.1 route-map TEST1 out
 .../...
R4
access-list 3 permit 3.0.0.0 0.255.255.255
access-list 33 permit 33.0.0.0 0.255.255.255
!
route-map TEST permit 10
 match ip address 3
 set metric 100
!
route-map TEST permit 20
 match ip address 33
 set metric 50
!
route-map TEST permit 30
!
router bgp 200
 neighbor 10.1.14.1 route-map TEST out
 .../...

Vérification :

R1#show ip bgp | b Net
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*> 2.0.0.0          10.1.12.2                0             0 200 i
*> 3.0.0.0          10.1.12.2               50             0 200 i
*                   10.1.14.4              100             0 200 i
*> 4.0.0.0          10.1.14.4                0             0 200 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*> 22.0.0.0         10.1.12.2                0             0 200 i
*  33.0.0.0         10.1.12.2              100             0 200 i
*>                  10.1.14.4               50             0 200 i

Autre exemple

Scénario à 4 AS :

 

Par défaut, sur R1 :

R1#show ip bgp | be Net
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*> 2.0.0.0          10.1.12.2                0             0 200 i
*                   10.1.14.4                              0 400 300 200 i
*  3.0.0.0          10.1.12.2                              0 200 300 i
*>                  10.1.14.4                              0 400 300 i
*  4.0.0.0          10.1.12.2                              0 200 300 400 i
*>                  10.1.14.4                0             0 400 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*> 22.0.0.0         10.1.12.2                0             0 200 i
*                   10.1.14.4                              0 400 300 200 i
*  33.0.0.0         10.1.12.2                              0 200 300 i
*>                  10.1.14.4                              0 400 300 i

 

Configurations

R2 annonce un metric de 120 à R1

route-map TEST permit 10
 set metric 120
!
route-map TEST permit 20
!
router bgp 200
 neighbor 10.1.12.1 route-map TEST out

R4 annonce un metric de 100 à R1

route-map TEST permit 10
 set metric 100
!
route-map TEST permit 20
!
router bgp 400
 neighbor 10.1.14.1 route-map TEST out

Vérification

Rappel

    • la valeur la pus petite de MED est préférée
    • la valeur « AS Path » est comparée avant le MED , l’AS Path le plus court est préféré
R1#show ip bgp  | be Net
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*  2.0.0.0          10.1.14.4              100             0 400 300 200 i
*>                  10.1.12.2              120             0 200 i
*> 3.0.0.0          10.1.14.4              100             0 400 300 i
*                   10.1.12.2              120             0 200 300 i
*> 4.0.0.0          10.1.14.4              100             0 400 i
*                   10.1.12.2              120             0 200 300 400 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*  22.0.0.0         10.1.14.4              100             0 400 300 200 i
*>                  10.1.12.2              120             0 200 i
*> 33.0.0.0         10.1.14.4              100             0 400 300 i
*                   10.1.12.2              120             0 200 300 i

Utilisé MED et ignorer AS Path

R1#conf t
R1(config)#router bgp 100
R1(config-router)#bgp always-compare-med
R1(config-router)#bgp bestpath as-path ignore

R1(config-router)#bgp bestpath ?
  compare-routerid  Compare router-id for identical EBGP paths
  cost-community    cost community
  med               MED attribute

Vérification

R1#show ip bgp | b Net
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.0.0          0.0.0.0                  0         32768 i
*  2.0.0.0          10.1.12.2              120             0 200 i
*>                  10.1.14.4              100             0 400 300 200 i
*  3.0.0.0          10.1.12.2              120             0 200 300 i
*>                  10.1.14.4              100             0 400 300 i
*  4.0.0.0          10.1.12.2              120             0 200 300 400 i
*>                  10.1.14.4              100             0 400 i
*> 11.0.0.0         0.0.0.0                  0         32768 i
*  22.0.0.0         10.1.12.2              120             0 200 i
*>                  10.1.14.4              100             0 400 300 200 i
*  33.0.0.0         10.1.12.2              120             0 200 300 i
*>                  10.1.14.4              100             0 400 300 i
This entry was posted in BGP. Bookmark the permalink.

Comments are closed.