BGP MED

BGP MED is an optional non-transitive attribute meaning its not propagated throughout the whole internet but just to adjacent AS. The word "optional" means that this is not necessarily by default sent with the BGP updates. The purpose of MED is to influence how other autonomous systems enter your AS to reach a certain prefix. If the other attributes are set to default, MED will be the attribute used for path selection however, if Weight or Local preference is configured on the adjacent AS router, then MED will not be selected. The lower the MED the more preferred the path will be.



Acronym for Multi Exit Discriminator and otherwise known as "Metric" in the BGP table.
The lower the MED the more preferred.
It is an optional non-transitive attribute.
Can dictate how other AS enter your AS.
Configure R4 so that it will advertise a MED value of 30 to R3 and 20 to R2. Afterwards,
tweak the route map to set a MED of 10 for network 144.144.144.144/32 in R4 towards R3. The end
result should have traffic from AS123 to 4.4.4.4/32 and 44.44.44.44/32 take R2 but traffic for
144.144.144.144/32 should take R3. At the start BGP has been established on all routers.


To start lets configure 2 route maps and set the MED as required.


R4(config)#access-list 20 permit any

R4(config)#access-list 30 permit any
R4(config)#route-map R2SETMED20 permit 10
R4(config-route-map)#match ip address 20
R4(config-route-map)#set metric 20
R4(config-route-map)#route-map R3SETMED30 permit 10
R4(config-route-map)#match ip address 30
R4(config-route-map)#set metric 30


Access-list matches all routes. Now, lets apply the route map to the neighbors.


R4(config-router)#neighbor 24.24.24.2 route-map R2SETMED20 out
R4(config-router)#neighbor 34.34.34.3 route-map R3SETMED30 out

Its in the "out" direction because R4 is the one advertising the routes. Let's check what R2 and R3 see in their BGP table.



R2#sh ip bgp

BGP table version is 31, local router ID is 24.24.24.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 24.24.24.4 20 0 4 i
*> 44.44.44.44/32 24.24.24.4 20 0 4 i
*> 144.144.144.144/32
24.24.24.4 20 0 4 i

R3#sh ip bgp
BGP table version is 10, local router ID is 34.34.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 34.34.34.4 30 0 4 i
*> 44.44.44.44/32 34.34.34.4 30 0 4 i
*> 144.144.144.144/32
34.34.34.4 30 0 4 i

Ok, its clear that the Metric now is changed to 20 and 30 for R2 and R3 respectively. Let's see how R1 sees the routes.



R1#sh ip bgp
BGP table version is 34, local router ID is 13.13.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
*>i4.4.4.4/32 24.24.24.4 20 100 0 4 i
* i 34.34.34.4 30 100 0 4 i
*>i44.44.44.44/32 24.24.24.4 20 100 0 4 i
* i 34.34.34.4 30 100 0 4 i
*>i144.144.144.144/32
24.24.24.4 20 100 0 4 i
* i 34.34.34.4 30 100 0 4 i

R1 sees two paths, but notice that the paths with ">" are with those with lower MED. Therefore it is going to take those paths. Now, lets configure R4 so that the path R1 will take to 144.144.144.144/32 in R4 will be through R3 then clear the BGP session after.



R4(config)#access-list 33 permit 144.144.144.144 0.0.0.0
R4(config)#route-map R3SETMED30 permit 10
R4(config-route-map)#match ip address 33
R4(config-route-map)#set metric 10
R4(config-route-map)#route-map R3SETMED30 permit 20
R4(config-route-map)#match ip address 30
R4(config-route-map)#set metric 30
R4#clear ip bgp *

Now, lets see the outputs.



R2#sh ip bgp | beg Network

Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 24.24.24.4 20 0 4 i
*> 44.44.44.44/32 24.24.24.4 20 0 4 i
*> 144.144.144.144/32
24.24.24.4 20 0 4 i

R3#sh ip bgp | beg Network
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 34.34.34.4 30 0 4 i
*> 44.44.44.44/32 34.34.34.4 30 0 4 i
*> 144.144.144.144/32
34.34.34.4 10 0 4 i

R1#sh ip bgp | beg Network
Network Next Hop Metric LocPrf Weight Path
* i4.4.4.4/32 34.34.34.4 30 100 0 4 i
*>i 24.24.24.4 20 100 0 4 i
* i44.44.44.44/32 34.34.34.4 30 100 0 4 i
*>i 24.24.24.4 20 100 0 4 i
*>i144.144.144.144/32
34.34.34.4 10 100 0 4 i
* i 24.24.24.4 20 100 0 4 i

We can see a change in R3 that shows a MED of 10 for 144.144.144.144/32, while R1 shows the same and will now take R3 to reach the subnet.

Comments

5 Responses to "BGP MED"

Anonymous said... December 4, 2012 at 6:00 AM

You are a dream indeed. Your way of explaining and posting the scenarios is pretty simple but concise. Congratulations and keep posting such a wonderful blogs

Anonymous said... May 27, 2013 at 3:53 AM

Good job!

Unknown said... February 18, 2014 at 10:02 PM

why would you configure MED on the ISP router. I think its to suggest to the ISP router which path to use to enter its AS and we have no control whatsoever over the isp router. can you look into the configuration again??

Unknown said... February 18, 2014 at 10:56 PM

i configure the Metric on R2 and R3 inbound and this is R1's show ip bgp

Network Next Hop Metric LocPrf Weight Path
*>i4.4.4.4/32 12.12.12.2 20 100 0 4 i
* i 13.13.13.3 30 100 0 4 i
*>i44.44.44.44/32 12.12.12.2 20 100 0 4 i
* i 13.13.13.3 30 100 0 4 i
* i144.144.144.144/32
12.12.12.2 20 100 0 4 i
*>i 13.13.13.3 10 100 0 4 i

works perfectly

dreamweaver said... March 8, 2014 at 5:15 AM

Good work....Thanks for your excellent effort

Post a Comment

Certifications

Certifications

The Dreamer

A fun loving person who enjoys learning new things. Currently working as a Network Engineer supporting the global network of a Fortune 500 company. This blog serves as my notes for the labs I created for my CCIE journey. I can guarantee there are errors in my posts. If you spot them, please let me know.

Join my Facebook Page I WANT TO BE A CCIE

Donate to the Cause

My aim is to create materials for free and possibly a free lab. If you wish to help out, please send any amount. Thanks.

Join my Bandwagon

Blogs that I Read