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 188.8.131.52 /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 184.108.40.206 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 220.127.116.11 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 * 18.104.22.168/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: