ccie blog

BGP MED

MED is a non-transitive attribute that can be used to influence a neighboring AS’s path decision towards our internal networks.   The term non-transitive means that we can only advertise MED to routers that are one AS away.  In the diagram below, this means we can send MED values from AS30 to AS20. However, AS 20 will not advertise this MED to any other AS’s he might be attached to.  In this scenario, I’m going to make R3 our primary path towards the ISP, and R2 the backup.

Making networks inside AS 30 use the primary link for outgoing routes is relatively simple. There’s a few ways to do it: I’m going to use a bit of interface tracking a floating static route.

R4(config)#track 1 interface fa0/1 ip routing
R4(config-track)#exit
R4(config)#ip route 0.0.0.0 0.0.0.0 fa0/1 10.0.40.1 10 track 1
R4(config)#ip route 0.0.0.0 0.0.0.0 fa0/0 10.0.30.1 11

So as long as the fa0/1 link to R3 is up, we will use our primary path to reach the ISP.    If it fails, our default route whipped out of our routing table, and the backup default route will ensure we send traffic via the backup line instead. We now need to influence AS 20’s best path towards our 100.100.100.0/24 network. To do this, we are going to use MED. First off, let’s have a look at the best path to this network from AS 20’s point of view.

R2#sh ip bgp 100.100.100.0
BGP routing table entry for 100.100.100.0/24, version 26
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
     1
  30
    10.0.40.2 from 10.0.50.2 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, internal
  30
    10.0.30.2 from 10.0.30.2 (4.4.4.4)
      Origin IGP, metric 0, localpref 100, valid, external, best
R3#sh ip bgp 100.100.100.0
BGP routing table entry for 100.100.100.0/24, version 23
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
     1
  30
    10.0.30.2 from 10.0.50.1 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
  30
    10.0.40.2 from 10.0.40.2 (4.4.4.4)
      Origin IGP, metric 0, localpref 100, valid, external, best

So both R2 & R3 are preferring their external paths, which they should, according to the best path selection algorithm.  However, this doesn’t meet are design requirements.  We are going to configure R4 to send a lower MED to R3 than he does to R2.  Because a lower MED means the path is more preferred, it should then make R2 use R3′ as the primary path to reach our 100.100.100.0/30 network.  Let’s do that now.

R4(config)#ip prefix-list 100_network seq 5 permit 100.100.100.0/24
R4(config)#route-map Low_Med permit 10
R4(config-route-map)#match ip address prefix-list 100_network
R4(config-route-map)#set metric 10
R4(config)#route-map Low_Med permit 20
R4(config-route-map)#exit
R4(config)#
R4(config)#route-map Higher_Med permit 10
R4(config-route-map)#match ip address prefix-list 100_network
R4(config-route-map)#set metric 20
R4(config)#route-map Higher_Med permit 20
R4(config-route-map)#exit
R4(config)#
R4(config)#router bgp 30
R4(config-router)#neighbor 10.0.40.1 route-map Low_Med out
R4(config-router)#neighbor 10.0.30.1 route-map Higher_Med out
R4(config-router)#end
R4#clear ip bgp * soft out
R2#sh ip bgp 100.100.100.0
BGP routing table entry for 100.100.100.0/24, version 24
Paths: (2 available, best #1, table Default-IP-Routing-Table)
Flag: 0x4840
  Advertised to update-groups:
     2
  30
    10.0.40.2 from 10.0.50.2 (3.3.3.3)
      Origin IGP, metric 10, localpref 100, valid, internal, best
  30
    10.0.30.2 from 10.0.30.2 (4.4.4.4)
      Origin IGP, metric 20, localpref 100, valid, external

So there we have it.  We have now made our ISP use R3 as the pimary path to reach our 100.100.100.0/24 network.

 

BGP always-compare-med & BGP deterministic-med may also be of interest to you.

Leave a comment

Your comment