Configuring MED Attributes for BGP Routes

The MED attribute equals the metric used by an IGP. After the MED attributes of routes are set, an EBGP peer selects the route with the smallest MED value for the traffic that enters an AS if the other attributes of the routes are the same.

Context

If the router running BGP obtains multiple routes from different EBGP peers and these routes have different next hops but the same destination, the BGP device selects the route with the smallest MED value.

Procedure

  • Set the default MED value on a device.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast

      The IPv4 unicast address family view is displayed.

    4. Run default med med

      A default MED value is configured.

      The default med command is valid only for routes imported using the import-route command and summary BGP routes on the local router.

    5. Run commit

      The configuration is committed.

  • Compare the MED values of the routes from different ASs.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast

      The IPv4 unicast address family view is displayed.

    4. Run compare-different-as-med

      The MED values of routes from different ASs are compared.

      By default, the BGP device compares the MED values of only routes from different peers in the same AS.

    5. Run commit

      The configuration is committed.

  • Configure the deterministic-MED function.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast

      The IPv4 unicast address family view is displayed.

    4. Run deterministic-med

      The deterministic-MED function is enabled. If the deterministic-MED function is not enabled and the device receives multiple routes with the same prefix from different ASs, the sequence in which routes are received determines the route selection. After the deterministic-MED function is enabled, these routes are first grouped based on the leftmost AS number in the AS_Path attribute. Routes with the same leftmost AS number are grouped together and compared, and an optimal route is selected in the group. The optimal route in this group is then compared with the optimal routes from other groups to determine the final optimal route. With the deterministic-MED function, the route selection result is independent of the sequence in which routes are received.

    5. Run commit

      The configuration is committed.

  • Configure the processing mode when the MED value is lost.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast

      The IPv4 unicast address family view is displayed.

    4. Run bestroute med-none-as-maximum

      The maximum MED value is used as the MED when a route carries no MED.

      If the bestroute med-none-as-maximum command is not run and a route carries no MED, 0 is used as the MED value of the route.

    5. Run commit

      The configuration is committed.

  • Compare the MED values of routes in a confederation.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast

      The IPv4 unicast address family view is displayed.

    4. Run bestroute med-confederation

      The MED values of routes in a confederation are compared.

    5. Run commit

      The configuration is committed.

  • Compare the sums of MED multiplied by a MED multiplier and IGP cost multiplied by an IGP cost multiplier.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run ipv4-family unicast

      The IPv4 unicast address family view is displayed.

    4. Run bestroute med-plus-igp [ igp-multiplier igp-multiplier | med-multiplier med-multiplier ]

      The sums of MED multiplied by a MED multiplier and IGP cost multiplied by an IGP cost multiplier are compared.

    5. Run commit

      The configuration is committed.

  • Enable BGP to remove the MED attribute from the imported routes that are locally leaked and are to be advertised to a specified peer after an export route-policy in which the apply cost-type command is run is applied to routes to be advertised to the peer.
    1. Run system-view

      The system view is displayed.

    2. Run bgp as-number

      The BGP view is displayed.

    3. Run local-cross-routing non-med

      After an export route-policy in which the apply cost-type command is run is applied to routes to be advertised to a peer, you can run the local-cross-routing non-med command to remove the MED attribute from the imported routes that are locally leaked and are to be advertised to the peer.

    4. Run commit

      The configuration is committed.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
< Previous topic Next topic >