Just another Cisco blog
BGP Multi-Exit Discriminator (MED)
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).
Related Posts:
| Print article | This entry was posted by Colby on February 8, 2010 at 6:17 am, and is filed under Tutorials. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |








about 1 year ago
Wow!! I never see /31…..
about 1 year ago
A friend of mine introduced me to /31s. Pretty cool stuff.
about 1 year ago
RFC3021 – Using 31-Bit Prefixes on IPv4 Point-to-Point Links: http://www.faqs.org/rfcs/rfc3021.html
about 1 year ago
alright! you know you are a uber-geek when first thing Monday morning you get all sorts of excited about reading an RFC on /31 subnets and learning a new tool
Also, i have heard rumors of the CCIP being changed in June/July. Anyone hear anything on this?
about 1 year ago
Hahaha, I know what you mean.
I haven’t heard anything about the CCIP changes, but it wouldn’t be surprising at all.
about 1 year ago
Yeah im still digging around to see if i can get more info. In about a month or so i will start in on the BGP and MPLS exam. If possible ill try to take the composite. I wish i could start now but i have other stuff i must focus on.
about 1 year ago
Have you done QoS yet? If not, I’d knock that one out first.
about 1 year ago
Nice clear cut example. Really love reading your write outs =)
about 1 year ago
Thanks!
about 1 year ago
Colby, are you preparing for R&S or SP?
about 1 year ago
R&S was the plan, but the changes have me rethinking a lot of things.
about 1 year ago
Yeah, Im also looking @ R&S and it dont seems fun at all. What are you planning to clear?
about 1 year ago
Hi,
are there any known problems when using a /31 address?
The RFC is from year 2000 and I have never seen a /31 address.
I am wondering why!
And one offtopic question.
Can I distrubte a network that I dont have in my routing table (OSPF)? I made a NAT pool and on the other routers I have to make a static route and I want to avoid that.
about 1 year ago
It is a Cisco ASA 5510
about 1 year ago
Smail, Redistribute Connected?
about 1 year ago
hmm, dont know if a NAT pool is “connected”
I gonna try it now.
about 1 year ago
I tried it and it is not working.
about 1 year ago
I don’t know if this works on an ASA, but for something like that you would create a loopback in your NAT pool, then redistribute it.
about 1 year ago
Yeah, the problem is that the ASA has really poor routing features.
about 1 year ago
@ colby
Yeah i first thought of taking my QoS exam right after passing my ONT since QoS overlapped so much but i wanted to wait until the new CCNP announcements and to see if they changed anything with the CCIP. Plus it was Christmas time and my wife was already getting upset that i spent so much time studying.
Looks like even if they change CCIP my BSCI will count for a while.
about 1 year ago
Knock out QoS, it’s one of the easiest Cisco exams I’ve taken. Get the CBTNuggets and Odom’s book, study for a couple weeks and it should be cake.
about 1 year ago
I somehow dont really like CBT’s training materials. Studied QoS with KNet & Student Guide thats all passed with 985/1000.
But i believe the eaisiest exam i took was BGP+MPLS. But exam is easy but doing in real life implementation is really tough. Reading alot of materials to understand more on the technology.