what is the difference between a route metric and a route preference in Junos and does metric has any effect choosing the active route ?
The routes advertised by a protocol are associated with route preference. This value helps in choosing the route from most reliable protocol. For instance say you have 22.214.171.124/32 route being received by OSPF (internal) as well as by RIP.
In this case, theoretical OSPF would be the obvious choice. In JUNOS, a route from OSPF(internal) would have preference of 10 while the same route from RIP would have 100. The lowest preference would be used as active route in routing table.
Refer below for preference values of all protocols:
Now, in case if you still have same routes coming from different neighbors but with same protocol, then you will select the route based on the route metric. The one with least metric would be active in routing table.
On route metric,
A) set routing-instances To_Z routing-options static route 0.0.0.0/0 qualified-next-hop 172.16.0.1 metric 6B) set routing-instances To_Z routing-options static route 0.0.0.0/0 qualified-next-hop 172.16.0.2 metric 5
Which will take a higher priority? B) right?
The answer is "it depends"
if 172.16.0.1 and 172.16.0.2 are both reachable via direct routes, then routeB wins.
If one or both next-hop IPs are not reachable via direct routes and "resolve" knob is not configured (it isn't if the config below is the complete one), then it could be A or B or none.
The "resolve" knob is used when your specified next hop is not directly reachable (indirect next-hop) - by default that route would not be considered. If you append your route with that option (route xx.xx.xx.xx next-hop xx.xx.xx.xx resolve) AND if there is another route that will allow traffic to get to that next hop then it is an a valid route entry.
Please, help me, the documentation says:
Metric The metric is a preference number, with the lowest number having thehighest priority.All directly connected networks have a metric of zero. All staticroutes have a default metric of one.There may be cases in which you need to addthe same route twice, the preferred route with the lower metric and the less preferredroute with the higher metric. If the first route is unavailable, the firewall willuse the next route.
"If the first route is unavailable...", how does Juniper know this? Just if the interface is down?
I want it to use the next route(metric 1 to metric 2) if the gateway is unavailable.
(In my case, when the gateway is unavailable, the interface is not down)
I already read about track IP, but it's for HW failover, and not route. So I can't use it to ping the gateway, and disable the route when it's not responding.
I don't believe that the only way to do this is configuring a tunnel interface.
I'd say that the right process follow the RIB in order to store the active path in the FIB.
1) Select the lowest Route Preference.
2) If we have 2 routes with same route preference, Junos will check the secondary route preference:
example: " set routing-options static route 192.168.47.0/24 qualified-next-hop 192.168.2.2 preference <value>"
3) If we have 2 routes with same route preference, let's check the metric.