Junos Static Routes and Qualified Next Hops Explained - 夜莺博客

Junos Static Routes and Qualified Next Hops Explained

Static routing is the workhorse of the network edge: stub sites, point-to-point uplinks and default routes are almost always built from static routes because they are simple and predictable. On Junos OS a static route is defined under routing-options and has a global preference (administrative distance) of 5, which makes it preferred over any dynamic route unless you change it. This article explains basic Junos static route configuration and the qualified-next-hop feature that gives you deterministic failover between two upstreams.

Basic Junos Static Route Configuration

Junos routes are configured with set commands under edit routing-options static. A route becomes active only when its next hop is reachable:

set interfaces ge-1/2/0 unit 0 family inet address 172.16.1.1/24
set routing-options static route 192.168.47.0/24 next-hop 172.16.1.2

The provider router R1 reaches the customer prefix 192.168.47.0/24 through the point-to-point link. On the customer side you typically configure a default route pointing back at the provider:

set routing-options static route 0.0.0.0/0 next-hop 172.16.1.1

IPv6 works the same way: set routing-options static route 2001:db8:2::/48 next-hop 2001:db8:1:1::2 and a default route ::/0 on the stub side.

Route Preference and Metrics

The global default preference for static routes is 5, lower (better) than OSPF (10) and BGP (170). You can raise it when a static route must act as a backup to a dynamic route, e.g. a floating static default that only appears when BGP disappears:

set routing-options static route 0.0.0.0/0 next-hop 172.16.1.1 preference 200

Qualified Next Hops for Deterministic Failover

When one destination has several next hops, Junos picks one for the forwarding table; without extra configuration the choice can look random. The qualified-next-hop statement lets you assign a different preference and metric to each next hop so the best path is always chosen, and the route automatically switches when that next hop becomes unreachable:

set routing-options static route 192.168.47.0/24 next-hop 172.16.1.2
set routing-options static route 192.168.47.0/24 qualified-next-hop 192.168.2.2 preference 25

Here the primary next hop 172.16.1.2 keeps the default preference, while the backup 192.168.2.2 is marked preference 25. The router installs the lower-preference path and fails over to the qualified next hop only when the primary is unreachable. Qualified next hops can also carry BFD settings so failure detection is faster than interface hold timers — useful when the two next hops share the same physical link.

Verification

show route 192.168.47.0/24
show route protocol static
show route table inet.0

The asterisk in the output marks the active route; the Preference column shows the per-route preference, and you can confirm the qualified next hop is installed only as a backup. If a static route is not active, verify the next hop is reachable and there is no route with a lower preference competing for the same prefix — the same reasoning used when troubleshooting Junos IRB/ARP reachability. Static routes pair naturally with commit-confirmed change management, described in our Junos commit confirmed guide. For switching-side VLAN and IRB design see our Junos VLAN configuration examples.

原文链接:https://www.juniper.net/documentation/us/en/software/junos/static-routing/topics/topic-map/config_static-routes.html