Supported Platforms
Related Documentation
- ACX, M, MX, PTX, T Series
- Example: Associating the MED Path Attribute with the IGP Metric and Delaying MED Updates
- ACX, J, M, MX, PTX, SRX, T Series, QFabric System, QFX Series standalone switches
- Understanding BGP Path Selection
- ACX, J, M, MX, SRX Series
- Understanding External BGP Peering Sessions
- BGP Configuration Overview
Example: Configuring the MED Attribute Directly
This example shows how to configure a multiple exit discriminator (MED) metric to advertise in BGP update messages.
Requirements
No special configuration beyond device initialization is required before you configure this example.
Overview
To directly configure a MED metric to advertise in BGP update messages, include the metric-out statement:
metric is the primary metric on all routes sent to peers. It can be a value in the range from 0 through 4,294,967,295 (232 – 1).
The following optional settings are also supported:
- minimum-igp—Sets the metric to the minimum metric value calculated in the interior gateway protocol (IGP) to get to the BGP next hop. If a newly calculated metric is greater than the minimum metric value, the metric value remains unchanged. If a newly calculated metric is lower, the metric value is lowered to that value.
- igp—Sets the metric to the most recent metric value calculated in the IGP to get to the BGP next hop.
- delay-med-update—Delays sending MED updates when the MED value increases. Include the delay-med-update statement when you configure the igp statement. The default interval to delay sending updates, unless the MED is lower or another attribute associated with the route has changed is 10 minutes. Include the med-igp-update-interval minutes statement at the [edit routing-options] hierarchy level to modify the default interval.
- offset—Specifies a
value for offset to increase or decrease
the metric that is used from the metric value calculated in the IGP.
The metric value is offset by the value specified. The metric calculated
in the IGP (by specifying either igp or igp-minimum) is increased if the offset value
is positive. The metric calculated in the IGP (by specifying either igp or igp-minimum) is decreased if the offset value is negative.
offset can be a value in the range from –231 through 231 – 1. Note that the adjusted metric can never go below 0 or above 232 – 1.
Figure 1 shows a typical network with internal peer sessions and multiple exit points to a neighboring autonomous system (AS).
Figure 1: Typical Network with IBGP Sessions and Multiple Exit Points

Device R4 has multiple loopback interfaces configured to simulate advertised prefixes. The extra loopback interface addresses are 44.44.44.44/32 and 144.144.144.144/32. This example shows how to configure Device R4 to advertise a MED value of 30 to Device R3 and a MED value of 20 to Device R2. This causes all of the devices in AS 123 to prefer the path through Device R2 to reach AS 4.
Configuration
CLI Quick Configuration
To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.
Device R1
Device R2
Device R3
Device R4
Configuring Device R1
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R1:
- Configure the interfaces.[edit interfaces fe-1/2/0 unit 1]user@R1# set family inet address 12.12.12.1/24
[edit interfaces fe-1/2/1 unit 2]user@R1# set family inet address 13.13.13.1/24
[edit interfaces lo0 unit 1]user@R1# set family inet address 192.168.1.1/32 - Configure BGP.[edit protocols bgp group internal]user@R1# set type internaluser@R1# set local-address 192.168.1.1user@R1# set export send-directuser@R1# set neighbor 192.168.2.1user@R1# set neighbor 192.168.3.1
- Configure OSPF.[edit protocols ospf area 0.0.0.0]user@R1# set interface lo0.1 passiveuser@R1# set interface fe-1/2/0.1user@R1# set interface fe-1/2/1.2
- Configure a policy that accepts direct routes.
Other useful options for this scenario might be to accept routes learned through OSPF or local routes.
[edit policy-options policy-statement send-direct term 1]user@R1# set from protocol directuser@R1# set then accept - Configure the router ID and autonomous system (AS) number.[edit routing-options]user@R1# set autonomous-system 123user@R1# set router-id 192.168.1.1
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
If you are done configuring the device, enter commit from configuration mode.
Configuring Device R2
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R2:
- Configure the interfaces.[edit interfaces fe-1/2/0 unit 3]user@R2# set family inet address 12.12.12.21/24
[edit interfaces fe-1/2/1 unit 4]user@R2# set family inet address 24.24.24.2/24
[edit interfaces lo0 unit 2]user@R2# set family inet address 192.168.2.1/32 - Configure BGP.[edit protocols bgp group internal]user@R2# set type internaluser@R2# set local-address 192.168.2.1user@R2# set export send-directuser@R2# set neighbor 192.168.1.1user@R2# set neighbor 192.168.3.1
[edit protocols bgp group external]user@R2# set type externaluser@R2# set export send-directuser@R2# set peer-as 4user@R2# set neighbor 24.24.24.4 - Configure OSPF.[edit protocols ospf area 0.0.0.0]user@R2# set interface lo0.2 passiveuser@R2# set interface fe-1/2/0.3user@R2# set interface fe-1/2/1.4
- Configure a policy that accepts direct routes.
Other useful options for this scenario might be to accept routes learned through OSPF or local routes.
[edit policy-options policy-statement send-direct term 1]user@R2# set from protocol directuser@R2# set then accept - Configure the router ID and autonomous system (AS) number.[edit routing-options]user@R2# set autonomous-system 123user@R2# set router-id 192.168.2.1
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
If you are done configuring the device, enter commit from configuration mode.
Configuring Device R3
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R3:
- Configure the interfaces.[edit interfaces fe-1/2/0 unit 5]user@R3# set family inet address 13.13.13.3/24
[edit interfaces fe-1/2/1 unit 6]user@R3# set family inet address 34.34.34.3/24
[edit interfaces lo0 unit 3]user@R3# set family inet address 192.168.3.1/32 - Configure BGP.[edit protocols bgp group internal]user@R3# set type internaluser@R3# set local-address 192.168.3.1user@R3# set export send-directuser@R3# set neighbor 192.168.1.1user@R3# set neighbor 192.168.2.1
[edit protocols bgp group external]user@R3# set type externaluser@R3# set export send-directuser@R3# set peer-as 4user@R3# set neighbor 34.34.34.4 - Configure OSPF.[edit protocols ospf area 0.0.0.0]user@R3# set interface lo0.3 passiveuser@R3# set interface fe-1/2/0.5user@R3# set interface fe-1/2/1.6
- Configure a policy that accepts direct routes.
Other useful options for this scenario might be to accept routes learned through OSPF or local routes.
[edit policy-options policy-statement send-direct term 1]user@R3# set from protocol directuser@R3# set then accept - Configure the router ID and autonomous system (AS) number.[edit routing-options]user@R3# set autonomous-system 123user@R3# set router-id 192.168.3.1
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
If you are done configuring the device, enter commit from configuration mode.
Configuring Device R4
Step-by-Step Procedure
The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.
To configure Device R4:
- Configure the interfaces.[edit interfaces fe-1/2/0 unit 7]user@R4# set family inet address 24.24.24.4/24
[edit interfaces fe-1/2/1 unit 8]user@R4# set family inet address 34.34.34.4/24
[edit interfaces lo0 unit 4]user@R4# set family inet address 192.168.4.1/32user@R4# set family inet address 44.44.44.44/32user@R4# set family inet address 144.144.144.144/32Device R4 has multiple loopback interface addresses to simulate advertised prefixes.
- Configure a policy that accepts direct routes.
Other useful options for this scenario might be to accept routes learned through OSPF or local routes.
[edit policy-options policy-statement send-direct term 1]user@R4# set from protocol directuser@R4# set then accept - Configure BGP.[edit protocols bgp group external]user@R4# set type externaluser@R4# set export send-directuser@R4# set peer-as 123
- Configure a MED value of 30 for neighbor Device R3, and
a MED value of 20 for neighbor Device R2.[edit protocols bgp group external]user@R4# set neighbor 34.34.34.3 metric-out 30user@R4# set neighbor 24.24.24.2 metric-out 20
This configuration causes autonomous system (AS) 123 (of which Device R1, Device R2, and Device R3 are members) to prefer the path through Device R2 to reach AS 4.
- Configure the router ID and AS number.[edit routing-options]user@R4# set autonomous-system 4user@R4# set router-id 192.168.4.1
Results
From configuration mode, confirm your configuration by entering the show interfaces, show policy-options, show protocols, and show routing-options commands. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.
If you are done configuring the device, enter commit from configuration mode.
Verification
Confirm that the configuration is working properly.
- Checking the Active Path From Device R1 to Device R4
- Verifying That Device R4 Is Sending Its Routes Correctly
Checking the Active Path From Device R1 to Device R4
Purpose
Verify that the active path goes through Device R2.
Action
From operational mode, enter the show route protocol bgp command.
user@R1> show route protocol bgp
inet.0: 13 destinations, 19 routes (13 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 12.12.12.0/24 [BGP/170] 3d 22:52:38, localpref 100, from 192.168.2.1 AS path: I > to 12.12.12.2 via fe-1/2/0.1 13.13.13.0/24 [BGP/170] 3d 03:15:16, localpref 100, from 192.168.3.1 AS path: I > to 13.13.13.3 via fe-1/2/1.2 24.24.24.0/24 [BGP/170] 3d 22:52:38, localpref 100, from 192.168.2.1 AS path: I > to 12.12.12.2 via fe-1/2/0.1 34.34.34.0/24 [BGP/170] 3d 03:15:16, localpref 100, from 192.168.3.1 AS path: I > to 13.13.13.3 via fe-1/2/1.2 44.44.44.44/32 *[BGP/170] 01:41:11, MED 20, localpref 100, from 192.168.2.1 AS path: 4 I > to 12.12.12.2 via fe-1/2/0.1 144.144.144.144/32 *[BGP/170] 00:08:13, MED 20, localpref 100, from 192.168.2.1 AS path: 4 I > to 12.12.12.2 via fe-1/2/0.1 192.168.2.1/32 [BGP/170] 3d 22:52:38, localpref 100, from 192.168.2.1 AS path: I > to 12.12.12.2 via fe-1/2/0.1 192.168.3.1/32 [BGP/170] 3d 03:15:16, localpref 100, from 192.168.3.1 AS path: I > to 13.13.13.3 via fe-1/2/1.2 192.168.4.1/32 *[BGP/170] 01:41:11, MED 20, localpref 100, from 192.168.2.1 AS path: 4 I > to 12.12.12.2 via fe-1/2/0.1
Meaning
The asterisk (*) shows that the preferred path is through Device R2. The reason for the path selection is listed as MED 20.
Verifying That Device R4 Is Sending Its Routes Correctly
Purpose
Make sure that Device R4 is sending update messages with a value of 20 to Device R2 and a value of 30 to Device R3.
Action
From operational mode, enter the show route advertising-protocol bgp 24.24.24.2 command.
user@R4> show route advertising-protocol bgp
24.24.24.2
inet.0: 11 destinations, 13 routes (11 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 24.24.24.0/24 Self 20 I * 34.34.34.0/24 Self 20 I * 44.44.44.44/32 Self 20 I * 144.144.144.144/32 Self 20 I * 192.168.4.1/32 Self 20 I
user@R4> show route advertising-protocol bgp
34.34.34.3
inet.0: 11 destinations, 13 routes (11 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 24.24.24.0/24 Self 30 I * 34.34.34.0/24 Self 30 I * 44.44.44.44/32 Self 30 I * 144.144.144.144/32 Self 30 I * 192.168.4.1/32 Self 30 I
Meaning
The MED column shows that Device R4 is sending the correct MED values to its two external BGP (EBGP) neighbors.
Related Documentation
- ACX, M, MX, PTX, T Series
- Example: Associating the MED Path Attribute with the IGP Metric and Delaying MED Updates
- ACX, J, M, MX, PTX, SRX, T Series, QFabric System, QFX Series standalone switches
- Understanding BGP Path Selection
- ACX, J, M, MX, SRX Series
- Understanding External BGP Peering Sessions
- BGP Configuration Overview
Published: 2013-12-09
Supported Platforms
Related Documentation
- ACX, M, MX, PTX, T Series
- Example: Associating the MED Path Attribute with the IGP Metric and Delaying MED Updates
- ACX, J, M, MX, PTX, SRX, T Series, QFabric System, QFX Series standalone switches
- Understanding BGP Path Selection
- ACX, J, M, MX, SRX Series
- Understanding External BGP Peering Sessions
- BGP Configuration Overview