MED (or metric) is the sixth BGP attribute:
- MED can be used to advertise to your neighbors how they should enter your AS.
- MED is exchanged between autonomous systems.
- The lowest MED is the preferred path.
- MED is propagated to all routers within the neighbor AS but not passed along to any other autonomous systems.
Let’s look at an example:
MED (also called metric) is exchanged between autonomous systems, and you can use it to let the other AS know which path they should use to enter your AS. R2 is sending a MED of 200 towards AS 3. R3 is sending a MED of 300 to AS 3. AS 3 will prefer the lower metric and send all traffic for AS 1 through R2.
Let me show you how to configure this on a Cisco router:
Above, we have two autonomous systems. R1 and R3 will both advertise network 18.104.22.168 /24 in BGP. We can use MED to tell AS 2 which path to use to reach this network.
R1(config)#router bgp 1 R1(config-router)#neighbor 192.168.12.2 remote-as 2 R1(config-router)#network 22.214.171.124 mask 255.255.255.0
R3(config)#router bgp 1 R3(config-router)#neighbor 192.168.23.2 remote-as 2 R3(config-router)#network 126.96.36.199 mask 255.255.255.0
R2(config)#router bgp 2 R2(config-router)#neighbor 192.168.12.1 remote-as 1 R2(config-router)#neighbor 192.168.23.3 remote-as 1
This is the BGP configuration, nothing special so far.
R2#show ip bgp BGP table version is 2, local router ID is 192.168.23.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 * 188.8.131.52/24 192.168.23.3 0 0 1 i *> 192.168.12.1 0 0 1 i
You have seen the example above before. R2 prefers the path through 192.168.12.1. Note that the default metric (MED) is 0. Let’s play with the MED now:
please check your article. the example you have given and configuration you did.
Thanks Husain, I just fixed the names so that the pictures match the configurations.
why are u running this command and please also tell me what are med and local preference.
neighbor 192.168.23.2 route-map MED out
i think it should be
neighbor 192.168.23.2 route-map MED in
please clear it
MED is used to tell your neighbor AS what link they should use to send traffic to your AS. Local preference is used to select an exit path for your AS.
The route-map is correct as we are sending the metric to our neighbor AS. For local preference you’ll need an inbound route-map.
Another fun fact: Although MED is a discretionary non-transitive attribute, it IS transitive across confederation ASes.