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.
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
Good job!
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??
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
Good work....Thanks for your excellent effort