Juniper Static Routing
Hello, in this article, we will explore how to configure static routes on Juniper devices. The main topics covered are summarized below:
- default preference value : 5
- defaults
- qualified-next-hop and preference
- next-hop reject and discard
- resolve
- no-readvertise
1- Default Preference Value : 5
In the example below, a single static route is written on the device. When we want to see this route in the routing table, we can observe that the default preference value for this route is 5

In Juniper, preference is a value that indicates which protocol the device will prioritize. Its equivalent in Cisco is known as Administrative Distance. By specifying the preference value when entering a route, we can see this value reflected in the routing table.

2 – Defaults
Under the “Defaults” section, we can modify default values for the protocol. For instance, let’s change the preference value from 5 to 15 and add a new route for 9.9.9.9.

Upon committing and checking both routes, we see that the preference value for the entered 8.8.8.8 is maintained, and 9.9.9.9 takes the default value defined under “Defaults,” which is 15.

3- Qualified-Next-Hop and Preference
When adding a second next-hop for an existing route, we use “qualified-next-hop” and “preference” to determine the selection between the two routes. Let’s examine how a route appears when there are two different next-hops for a destination network.



After checks, it becomes apparent that the device will use the ge-0/0/1 interface (next-hop 10.255.255.5) to reach 9.9.9.9. If we want to backup these two next-hops, we need to use “qualified-next-hop.”

The configuration is updated accordingly. If the value specified in “qualified-next-hop” is higher than the one defined under “Defaults,” it will be less prioritized and will be placed in the second position.

This can be confirmed from the forwarding table, ensuring that traffic will be sent from ge-0/0/0 first and then from ge-0/0/1 if the first port is down.

4-Next-Hop Reject and Discard
In some cases, the next-hop for the static route we wrote may not be live. This is referred to as a null route or black hole route. If we want an ICMP unreachable response to be sent to a host trying to access this destination, we use “reject” instead of the next-hop. If an ICMP unreachable response is not desired, we use “discard” instead of the next-hop.

5- Resolve
By default, Juniper doesn’t perform recursive lookups. In the static routes we define, the next-hop device is on the same subnet as an IP belonging to an interface on the device. Therefore, the device knows from which interface to forward the packet.
In the case of a next-hop IP that is not within the device’s subnet, a static route definition with the “resolve” option triggers an additional recursive lookup for the next-hop. It checks whether there is a route for the next-hop through recursive lookup. If a route is found, the packet is directed there.

Let’s consider the topology above where the IP address 8.8.8.8 is located on the vSRX2 device. As evident from the configuration, the routing for 8.8.8.8 doesn’t point to an IP address within the 192.168.12.0/24 network. Instead, it is directed to 172.16.255.2. Furthermore, upon querying for 172.16.255.2, it can be observed that there is a valid route leading to 192.168.12.2.
6- No-readvertise

In the topology, there is an OSPF adjacency between the vSRX2 and vSRX3 devices. The OSPF neighborhood on vSRX3 includes static routes thanks to a defined policy. However, there is a requirement to exclude certain static routes from being included in OSPF, despite the general inclusion of static routes through the defined policy.

On the vSRX2 device, examining the routes learned from the OSPF neighbor vSRX3 reveals that only the route for 1.1.1.1 is visible. The route written for 5.5.5.5 is not being observed.
