.. _example_protocols_bgp_parameters_always-compare-med: ################## Always-Compare-Med ################## Scenario to verify BGP **always-compare-med** parameter configuration. The Multi-Exit Discriminator (MED) is a BGP attribute used to suggest the preferred entry point into an AS when multiple entry points exist. Lower MED values are preferred. By default, BGP only compares MED values between routes learned from the **same AS**. This means if you receive routes to the same destination from different ASes (for example AS 200 and AS 300), BGP will not use MED to decide which route is better because the routes originated from different autonomous systems. The ``always-compare-med`` parameter changes this behavior. When enabled, BGP compares MED values across **all routes** regardless of the originating AS. This is useful in environments where you want MED to influence path selection even when routes come from different upstream providers. In this test, **DUT0** receives the same route from two eBGP neighbors in different ASes with different MED values, demonstrating that MED comparison only occurs when ``always-compare-med`` is enabled. *************************** Test BGP Always Compare MED *************************** Description =========== This test demonstrates the effect of ``always-compare-med`` on BGP path selection. **DUT0** (AS 100) receives route ``192.168.10.0/24`` from two eBGP neighbors: **DUT1** (AS 200) with MED 100 and **DUT2** (AS 300) with MED 50. Without ``always-compare-med``, BGP does not compare MEDs because the routes come from different ASes, so selection depends on other criteria like router-id. After enabling ``always-compare-med``, BGP compares MEDs and selects the route via DUT2 because 50 is lower than 100. Scenario ======== .. include:: always-compare-med/testbgpalwayscomparemed .. raw:: html