Today we’ll go over another important BGP topic: MED. From Cisco:

MED is an optional nontransitive attribute. MED is a hint to external neighbors about the preferred path into an autonomous system (AS) that has multiple entry points. The MED is also known as the external metric of a route. A lower MED value is preferred over a higher value.

So, to summarize, MED is used to influence incoming traffic from a multi-homed neighbor AS.

Here’s our diagram:

In this case we’ll say that the link between PE1 and CE1 is only a T1, while the link between PE2 and CE1 is a DS3. Obviously we will want traffic to use the faster link, the PE2-CE1 DS3.

First we’ll configure our interfaces and basic BGP:

PE1:
hostname PE1
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface Serial0/0
 description To PE2
 ip address 10.1.1.2 255.255.255.254
!
interface Serial0/1
 description To CE1
 bandwidth 1500
 ip address 172.16.1.2 255.255.255.254
!
router bgp 5300
 no synchronization
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 5300
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 2.2.2.2 next-hop-self
 neighbor 172.16.1.3 remote-as 1200
 no auto-summary
!
ip route 2.2.2.2 255.255.255.255 10.1.1.3
 
 
PE2:
hostname PE2
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface Serial0/0
 description To PE1
 ip address 10.1.1.3 255.255.255.254
!
interface Serial0/2
 description To CE1
 bandwidth 45000
 ip address 172.16.1.4 255.255.255.254
!
router bgp 5300
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 5300
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 1.1.1.1 next-hop-self
 neighbor 172.16.1.5 remote-as 1200
 no auto-summary
!
ip route 1.1.1.1 255.255.255.255 10.1.1.2
 
 
CE1:
hostname CE1
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Loopback1
 ip address 192.168.1.1 255.255.255.0
!
interface Loopback2
 ip address 192.168.2.1 255.255.255.0
!
interface Loopback3
 ip address 192.168.3.1 255.255.255.0
!
interface Loopback4
 ip address 192.168.4.1 255.255.255.0
!
interface Serial0/1
 description To PE1
 bandwidth 1500
 ip address 172.16.1.3 255.255.255.254
!
interface Serial0/2
 description To PE2
 bandwidth 45000
 ip address 172.16.1.5 255.255.255.254
!
router bgp 1200
 no synchronization
 bgp log-neighbor-changes
 network 192.168.1.0
 network 192.168.2.0
 network 192.168.3.0
 network 192.168.4.0
 neighbor 172.16.1.2 remote-as 5300
 neighbor 172.16.1.4 remote-as 5300
 no auto-summary

We’ve configured our serial interfaces and loopbacks. Notice that CE1 has several loopbacks configure to simulate AS1200′s LAN. PE1 and PE2 are iBGP peers using loopbacks, notice the static routes to the loopbacks, this is needed since we have no IGP running.PE1 and PE2 are also using the “next-hop-self” option. PE1 and PE2 are peered with CE1. We are advertising our “LAN” loopbacks in AS1200.

Let’s verify our config with some show commands:

PE1#sh ip bgp summ
BGP router identifier 1.1.1.1, local AS number 5300
...
Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.2.2.2         4  5300      18      18        5    0    0 00:12:50        4
172.16.1.3      4  1200      18      16        5    0    0 00:12:01        4
 
 
PE1#sh ip bgp
...
   Network          Next Hop            Metric LocPrf Weight Path
* i192.168.1.0      172.16.1.5               0    100      0 1200 i
*>                  172.16.1.3               0             0 1200 i
* i192.168.2.0      172.16.1.5               0    100      0 1200 i
*>                  172.16.1.3               0             0 1200 i
* i192.168.3.0      172.16.1.5               0    100      0 1200 i
*>                  172.16.1.3               0             0 1200 i
* i192.168.4.0      172.16.1.5               0    100      0 1200 i
*>                  172.16.1.3               0             0 1200 i

PE1 is showing both neighbors up and is receiving routes for AS1200 through PE2 and CE1.

Next we will configure MED on CE1:

ip access-list standard LAN
 permit 192.168.0.0 0.0.255.255
!
route-map PE1_MED_OUT permit 10
 match ip address LAN
 set metric 100
!
route-map PE2_MED_OUT permit 10
 match ip address LAN
 set metric 50
!
router bgp 1200
 neighbor 172.16.1.2 route-map PE1_MED_OUT out
 neighbor 172.16.1.4 route-map PE2_MED_OUT out

First we creat an ACL to cover our LAN loopbacks. I’ve done it the lazy way by using a /16 mask in the ACL, this matches more than our 4 loopbacks, but it works for this example. We then create a route-map matching our ACL, then we set the metric. We have our route-map to PE1 configured with the metric 100 and our route-map to PE2 using the metric 50. Remember lower is better with the metric. Something to note, we don’t need two route-maps here as the default metric is 0, we could have simply configured the route-map for PE1 with a metric of 100 and everything would work the same, but that’s no fun. After clearing our neighbors on CE1 the configuration should take effect.

Now we’ll verify everything from PE1:

PE1#sh ip bgp
...
   Network          Next Hop            Metric LocPrf Weight Path
*>i192.168.1.0      2.2.2.2                 50    100      0 1200 i
*                   172.16.1.3             100             0 1200 i
*>i192.168.2.0      2.2.2.2                 50    100      0 1200 i
*                   172.16.1.3             100             0 1200 i
*>i192.168.3.0      2.2.2.2                 50    100      0 1200 i
*                   172.16.1.3             100             0 1200 i
*>i192.168.4.0      2.2.2.2                 50    100      0 1200 i
*                   172.16.1.3             100             0 1200 i

We see that our config is working. MED is set at 100 for the direct connection (T1) between PE1 and CE1. PE1 is choosing the path through PE2 for all AS1200′s prefixes.

So that’s MED. It’s a very useful tool and knowledge of it is important for the CCIP (also CCNP and CCIE).

Colby

Colby Glass has been in IT since 2002. He is currently a Systems Engineer (presales) with a Cisco Gold partner and holds the CCNP R/S, CCNP DC, CCDP, CCIP, JNCIA-ER.

More Posts