in a cisco router. if i have for example :
route 0.0.0.0 via 192.168.1.1
route 0.0.0.0 via 192.168.2.1 ad 254
let's say i don't have ipsla configured. in a case of 192.168.1.1 being unreachable, the route will be updated to the next hop? or it forever stays on the 192.168.1.1 even if it's down?
The static route via 192.168.1.1 will remain in the routing table until the egress interface to that next-hop goes into a link down state. At that point the second static route will be used for routing to that destination.
What you described is know as a floating static route.
as stated by others both defaults would be in the router rib table - however intermittent traffic communication would occur as half of the traffic will be blackholed
To further clarify what Seb is telling you, much depends on how 192.168.1.1 becomes unreachable.
If 192.168.1.1 is a physical next hop connected interface, and the interface goes down, all traffic will then be redirected to 192.168.2.1 (generally pretty quickly, like 50ms or less).
If 192.168.1.1's interface is not down, all traffic will continue to be sent out that interface, so all the traffic, using it, will backhole.
IPSLA can be used, in cases where 192.168.1.1 cannot be reached, but it has become unreachable. Then traffic can be shifted to 192.168.2.1, as if the interface went down.
BTW, you probably know this, but a dynamic routing protocol normally will detect that 192.168.1.1 is unreachable either by drop of the connecting interface (where it will also very, very quickly shift to a backup path) or by lost of some form of routing protocol peer relationship (the latter, depending on the routing protocol, and its configuration, might take quite [multiple seconds up to even a large fraction of a minute] to detect the lost path and reroute).
BTW, I believe Georg's and Paul's answers overlooked the AD value on the second route statement. They would be correct if both static routes have the same AD value.
As a starting point I would wish that we saw output directly from show ip route rather than the interpreted output of the post. I agree with @Seb Rupik about his analysis of this situation. I can only hope that @Georg Pauwen and @paul driver did not read the original post carefully. Given the difference in AD only one of those routes would be used at a time. @Joseph W. Doherty makes a good summarization of this situation with additional comments about static vs dynamic routing..
@Richard Burts it isn’t the first time i have mis-read a configuration and i know it won’t be the last-
All i can say the concept was correct if the defaults did have the same AD value as its now been pointed out to me that are not the same and without any ip sla or tracked routing all traffic would be blackholed if the line protocol of the wan interface was kept up with upstream routing having failed
thank you all for your great information. so in case of no ipsla in the router's license. the best coverage will come from dynamic routing, right? because multiple static routing with AD, will only get me so far (will only detect an interface failure). while a protocol like bgp can detect a gw failure only by "no pulse" by the peer on the other end, thus failing over to the next bgp peer, without having to actually dropping the physical interface.
@paul driver I sympathize. I have (many times) done the same thing. One of the good things about the community is that we have multiple eyes looking at discussions and sometimes they help us realize that we were not as careful as we should have been.
To the original poster: some times there are valid reasons why we might choose to use static routes rather than a dynamic protocol. But a dynamic protocol does have the advantage of being able to detect when a peer is no longer active and to make adjustments in the routing table.
"the best coverage will come from dynamic routing, right?"
Well, that depends on the physical topology.
router<>router, difficult for you to lose the other side w/o an interface drop.
router<>switch<>router, easy for you to lose the other side w/o an interface drop.
That noted, I would say using a routing protocol is often a better choice, but they do have their own issues over static route statements.
"while a protocol like bgp can detect a gw failure only by "no pulse" by the peer on the other end, thus failing over to the next bgp peer, without having to actually dropping the physical interface."
BGP can detect loss by EITHER interface drop or peer drop.