BGP Path Attributes - MED - www.ipcisco.com : www.ipcisco.com
Content Protection by DMCA.com

BGP Path Attributes – MED

MED (Multi Exit Discriminator) attribute is the BGP Path attribute which provides information to the external neighbours, about how to come their Autonomous System. This is opposite of Local Preference. Local Preference says to the internal neighbours, “How to Exit AS”. MED says to the external neighbours, “How to Enter AS”.

MED (Multi Exit Discriminator) attribute is applied to the outbound interface and shows the best inbound interface into its AS (Autonomous System).

If BGP Best Path is selected via MED (metric) attribute, the lowest MED (metric) value is better and it is selected as BGP path. The default MED (metric) value is 0.

Local preference was sending only to IGP neighbours. MED attribute can be sent only EGP neighbours. In other words, Local Preference can exchanged in the AS, MED attribute can exchange between ASs.

Here, one of the important point is this, MED attribute can be carried into an AS and used inside this AS. But it does not leave that AS. If leaved, it is set as metric 0.

MED (Multi Exit Discriminator) attribute is an Optional and Non-transitive BGP Path attribute. This means that it can be or can not be supported in any BGP implementation and in BGP update the unsupported attribute is discarded.

MED (Multi Exit Discriminator) attribute is indicated as metric in the BGP table. When you use “show ip bgp” command, you can see the metric value after the neighbour value.

bgp path attribute, MED

BGP Path Attribute, MED

As an important note, there are two commands used with MED attribute. These commands are:

• bgp deterministic-med
• bgp always-compare med

“bgp deterministic-med” command provides to compare different MED values that advertised by neighbours in the same AS for routes selection.

“bgp always-compare med” command provides to compare different MED values that advertised by neighbours in different ASs for routes selection.

Let’s do an example configuration and understand MED (metric) attribute better.

bgp path attribute, MED

BGP Path Attribute, MED

For our example, we will use the topology above. As you can see, there are four different ASs. Think about that, for 40.40.40.40 ip address, different routers in same and different ASs are sending routes with different metric values. Which route does Router A select?

By default MED (metric) attribute is compared between the routers in the same AS. So, for the above example, the Router A selects Router D, between Router D and Router E. But if you use “bgp always-compare med” command on RouterA, then the other metrics from the other ASs are compared. And according to these comparison, the less metric value (metric 10) is selected. The route from Router C is selected as BGP best Path.

Here, do not forgot the BGP Best Path selection algorithm. The MED (metric) attribute is coming after AS Path attribute. So, if you want to use MED (metric) attribute to select BGP Best path, you need to ignore AS path first. Because, for the above topology, accorfing to AS Path, the BGP Best path is through Router E. It is two hop away only. So, to disable this, you need to use “bgp bestpath as-path ignore” command on Router A.

Let’s check the whole configuration of the routers.

(I will not show the whole neighbour configurations, because this is not our main focus)

RouterA (config)# router bgp 10
RouterA (config-router)# neighbour 20.20.20.2 remote-as 20
RouterA (config-router)# neighbour 30.30.30.2 remote-as 30
RouterA (config-router)# neighbour 40.40.40.2 remote-as 40
RouterA (config-router)# neighbour 50.50.50.2 remote-as 40
RouterA (config-router)# bgp bestpath as-path ignore
RouterA (config-router)# bgp always-compare-med

RouterB (config)#  route-map METRICSET permit 10
RouterB (config-route-map)# set metric 40
RouterB (config-route-map)# exit
RouterB (config)#  router bgp 20
RouterB (config-router)# neighbour 20.20.20.1 remote-as 10
RouterB (config-router)# neighbour 20.20.20.1 route-map METRICSET out

RouterC (config)#  route-map METRICSET permit 10
RouterC (config-route-map)# set metric 10
RouterC (config-route-map)# exit
RouterC (config)#  router bgp 30
RouterC (config-router)# neighbour 30.30.30.1 remote-as 10
RouterC (config-router)# neighbour 30.30.30.1 route-map METRICSET out

RouterD (config)#  route-map METRICSET permit 10
RouterD (config-route-map)# set metric 20
RouterD (config-route-map)# exit
RouterD (config)#  router bgp 40
RouterD (config-router)# neighbour 40.40.40.1 remote-as 10
RouterD (config-router)# neighbour 40.40.40.1 route-map METRICSET out

RouterD (config)#  route-map METRICSET permit 10
RouterD (config-route-map)# set metric 30
RouterD (config-route-map)# exit
RouterD (config)#  router bgp 40
RouterD (config-router)# neighbour 50.50.50.1 remote-as 10
RouterD (config-router)# neighbour 50.50.50.1 route-map METRICSET out

According to these configuration, for the route 40.40.40.40, the BGP Best Path is through Router C. Here the important command is “bgp always-compare-med” command, for the comparison of different routers’s MED (metric) values from different ASs. And another important part is the configuration of metric values. As you can see, here we configured the metric values via route maps.

You can find other BGP Path Attribute Articles below:

BGP Path Attributes – Weight
BGP Path Attributes – Local Preference
BGP Path Attributes – AS Path
BGP Path Attributes – Origin
BGP Path Attributes – MED

Main BGP Article Series :

BGP – Part 1
BGP – Part 2 (BGP Peers, BGP Sessions, BGP Messages)
BGP – Part 3 (IBGP, IBGP Topologies and EBGP)
BGP – Part 4 (BGP Administrative Distance and BGP Path Attributes)
BGP – Part 5 (Packet Tracer BGP Configuration Example)

Youn can join OUR Facebook Group with the below links!!!




About the Author
Gokhan Kosem is a telecommunation and network engineer. His ambition to IP networks and end-to-end system installation made him to prepare this web-site. By sharing his experiences about various networking protocols beside different system installation experiences and Cisco, Juniper, Alcatel-Lucent devices configurations, he is aimed to be helpful for his collegues in all over the world. He is currently lives in Istanbul, Turkey.

Leave a Reply

 Copy Protected by Chetan's WP-Copyprotect.