This article describes how qualified next hops can be configured in EX and QFX switches by using an example.
For more information about qualified next hops, see Understanding Static Route Preferences and Qualified Next Hops .
In this example scenario:
R1 is connected to R2 through three links (1g)
R1 wants to reach the loopback address R2 10.10.10.10
Configuring a static route on R1
For a static route, R2’s loopback address can be reached by using any of the three next-hops (1.1.1.2, 2.2.2.2, or 3.3.3.2).
First let’s configure a static route to reach 10.10.10.10 (lo0):
set routing-options static route 10.10.10.10/32 next-hop 1.1.1.2 commit
root# run show route 10.10.10.10 10.10.10.10/32 *[Static/5] 00:32:31 > to 1.1.1.2 via ge-0/0/0.0
Now let's configure three possible static routes to reach 10.10.10.10 as shown below:
set routing-options static route 10.10.10.10/32 next-hop 1.1.1.2 set routing-options static route 10.10.10.10/32 next-hop 2.2.2.2 set routing-options static route 10.10.10.10/32 next-hop 3.3.3.2
root# run show route 10.10.10.10 10.10.10.10/32 *[Static/5] 00:00:05 > to 1.1.1.2 via ge-0/0/0.0 >>> Junos chooses one route randomly . to 2.2.2.2 via ge-0/0/1.0 to 3.3.3.2 via ge-0/0/2.0
As seen above, Junos OS chooses one of the three next-hop addresses in a random fashion to install into the forwarding table.
Now let’s see how a qualified next hop works in this situation by adding the following configuration:
set routing-options static route 10.10.10.10/32 qualified-next-hop 2.2.2.2 preference 4
The route now:
root# run show route 10.10.10.10 10.10.10.10/32 *[Static/4] 00:00:15 > to 2.2.2.2 via ge-0/0/1.0 >>>> Route is this way. Preference is given to this next-hop. [Static/5] 00:08:33 to 1.1.1.2 via ge-0/0/0.0 to 2.2.2.2 via ge-0/0/1.0 > to 3.3.3.2 via ge-0/0/2.0
As seen above, by using the qualified next-hop knob, preference can be assigned to a specific next-hop configuration.
What happens when preference is configured globally as below?
set routing-options static route 10.10.10.10/32 preference 3
root# run show route 10.10.10.10 10.10.10.10/32 *[Static/3] 00:00:03 > to 1.1.1.2 via ge-0/0/0.0 >>Route is this way (random); global preference is lower than the qualified next hop. to 2.2.2.2 via ge-0/0/1.0 to 3.3.3.2 via ge-0/0/2.0 [Static/4] 00:02:05 > to 2.2.2.2 via em1.0
In the above output, it can be seen that the global preference value of 3 is common for all the three next hops.
Note: If other qualified next-hops are configured, preference is given to the lowest value among the qualified next-hops and the global preference value.