cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
2883
Views
20
Helpful
9
Replies

Clarification

lucad7846
Level 1
Level 1

Hi everyone

I would like to understand the difference between the various static routes once and for all. I have been watching videos, asking questions on here and I'm slowly starting to get my head around this. However I still have a few doubts about the various static routes and in what scenario I should use "this" or "that" route. 

I understand we use something like 0.0.0.0 0.0.0.0 g0/1 when the router does not know about a remote network. Then there's the next hop scenario when the IP address of the other device is known. Then I have seen scenarios when the network prefix was in the routes followed by the interface i.e. 192.168.10.0 255.255.255.0 int g0/1. 

Also when we use the interface. Sometimes we use that of the router we are configuring the route on and other times we use the interface of the directly connected router.

The more I read and watch videos the more confusing it gets.

Can someone please explain when "to use what" in more simple terms with route examples? The more I read and watch videos the more confusing it gets. 

Thanks so very much in advance to anyone who is willing to help. 

Cheers

 

3 Accepted Solutions

Accepted Solutions

Hello Luca,

You are welcome!

 

When we use the interface scenario. We are always referring to the interface on the router that we are configuring correct?

Oh, no, no. Static routes are always configured to tell the router how to reach an unknown network through a known next hop. In 99% of static route configurations, the next hop is from a directly connected network - and that one is in the routing table already so you do not need to configure a static route for it. Remember that if you have an interface configured with "ip address ...", that resulting IP network is automatically added to the routing table as a directly connected network. The router knows it automatically because it has an interface in, and in fact, that knowledge is so trustworthy that the administrative distance of such directly connected network is 0. Static routes always have an administrative distance of 1 or more and so can never beat directly connected networks anyway.

So once again: A static route is configured when you need to tell the router about a network that is not known yet so that the router knows about it and places it into the routing table with the knowledge how it can reach it. You don't need to tell it about directly connected networks on interfaces configured with "ip address ..." since they are placed into the routing table automatically. But you need to tell the router about networks that are ultimately directly attached to other routers, and you either use a routing protocol for that, or configure static routes. But for each unknown network you're configuring with a static route, the next hop must already be known, and that next hop would be in 99.9% of cases based on a directly connected network.

Remember -

ip route <unknown network> <its netmask> <known next hop from a directly connected network>

As an example:

192.168.1.1/24 --- R1 --- 192.168.12.1/30 --------- 192.168.12.2/30 --- R2 --- 192.168.2.1/24

R1 and R2 are connected with a 192.168.12.0/30 network; R1 is 192.168.12.1/30, R2 is 192.168.12.2/30. Each of these routers also has another directly connected network that the other routers does not know about. R1 does not know about 192.168.2.0/24 while R2 does not know about 192.168.1.0/24. They both need to somehow get the knowledge of them so that they can route packets to them.

With static routes, the configuration would be:

On R1:

R1(config)# ip route 192.168.2.0 255.255.255.0 192.168.12.2

On R2:

R2(config)# ip route 192.168.1.0 255.255.255.0 192.168.12.1

Would this make sense?

Keep the questions coming.

Best regards,
Peter

View solution in original post

Hi Luca,

Okay... : )

 

192.168.1.1/24 - (fa0/1) R1 (fa0/0) - 192.168.12.1/30 ------ 192.168.12.2/30 - (gi0/0) R2 (gi0/1) - 192.168.2.1/24

So I've added device labels to the example, and intentionally, I've used various ones. You'll be surprised how little has changed in the static route commands:

R1:

ip route 192.168.2.0 255.255.255.0 FastEthernet0/0 192.168.12.2

R2:

ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/0 192.168.12.1

As always, feel welcome to ask further.

Best regards,
Peter

View solution in original post

Martin L
VIP
VIP

In addition to Peter's reply, the IP and network of all 0s and mask with 0s is reserved. It literally means all IPs or any IP and any mask; In case of

ip route 0.0.0.0 0.0.0.0

also known as a default route, this special network is used to indicate all  networks and IPs (known or unknown plus Internet).  This default route is also known as "Gateway of last resort" which you can see from

show ip route

output.  Note that term "known or unknown" is misleading a bit. Routes that are unknown like Internet destinations are not present in your routing table (RIB for short).  But also you may have your own "known" routes missing in RIB on purpose.  So, you could say "I use

ip route 0/0

for all missing routes in my routing table (RIB)". 

Case 1. Since there are lots of Internet routes, it is not practical to have all possible Internet routes in RIB. This is why

ip route 0/0

is used on your Gateway router which connects to ISP.  Otherwise, you would have to know IPs and networks of millions sites, emails, other online services you visit at least once. Even if you know exact IP of this site or email servers, you wouldn't want to store all 4 billions of them on your router, right?

Case 2. Secondary use of this

ip route 0/0

route is to reduce number of routes in your router which leads to better/faster router performance, lower amount of memory, smaller tables, etc.  This is known or referred as optimization of RIB.  If your large organization have 100 remote offices with 1 unique network on single router per each location plus several thousands employees working in 50 departments in HQ (each department has its own subnet/network).  Normally only HQ would have all your networks known and installed in RIB but not Your remote office router.  Your remote office router doesn't need all 149 routes to be installed in RIB. Since he has only 1 way out to reach others (via HQ), he needs only default route ! This is also known as stub routing / stub router.

Case 3,  based on case 2, HQ could further optimize its internal network (and routers RIB) by using a summary routes. A summary route is a static route that includes common network destinations grouped into one summary route and advertised whenever it is possible.  For example you could have 1 class C network split into 32 networks each with /29 mask for some smaller departments.  Those 32 networks could be summarized into one /24 network and advertised to others instead of all 32 individual networks advertisements.  Fewer routes in router RIB, less work, better performance and faster traffic forwarding times.

Case 4, You could use static routes for traffic engineering.  If you have 2 ways to get to network x and y, you could add static routes telling router to reach net x via interface x and net y via interface y.  

Other common cases for static routing is to use them as a back up route (aka floating route), use in SLA for tracking, in PBR, just to mention a few.  

Regards, ML
**Please Rate All Helpful Responses **

View solution in original post

9 Replies 9

Peter Paluch
Cisco Employee
Cisco Employee

Hi Luca,

A static route specified with the IP address of the next hop - such as

ip route 0.0.0.0 0.0.0.0 192.0.2.1

- is the basic form of a static route, and this one will always work - assuming that the router already has a route to the next hop. Usually, the next hop is on a directly connected network, but it can be also an IP address in a remote network - but in that case, you depend on having a route to that remote network first which creates an additional dependency.

A static route specified with the outgoing interface - such as

ip route 0.0.0.0 0.0.0.0 Serial0/1/0

- is only appropriate if the outgoing interface is a point-to-point technology - so a serial interface with HDLC, PPP, or a Frame Relay point-to-point subinterface, or a Dialer interface (for PPPoE or PPPoA for example). The reason is that with a static route specified as an outgoing interface, the router will treat the static route as a directly connected network. With point-to-point interfaces, the logic is simple - "everything" is on the other side and you do not need to do any L3-to-L2 mappings because point-to-point technologies don't use varying L2 addresses. However, if you specified a static route out an Ethernet interface, you would force the router to believe that the static route is directly connected to the outgoing interface, and the router would send out an ARP for every packet's destination IP that would be routed through that static route. This would lead to high ARP traffic, high CPU load, large ARP cache, increased memory consumption, and it would completely break if the next hop router was prohibited to respond for ARP requests to addresses different from its own (the functionality is called Proxy ARP and is often disabled nowadays for security purposes). We have had a case here on Communities where a customer complained that a router on an edge of a network was periodically reloading. After some inspection, we found out that he had his default route configured as

ip route 0.0.0.0 0.0.0.0 gi0/0

- which meant that he was essentially creating an ARP cache for the whole internet. Ultimately, he exhausted his router's RAM which caused the reboots, and after a while, this would repeat. After reconfiguring his default route to "ip route 0.0.0.0 0.0.0.0 <some-next-hop-ip>", things worked like charm.

Finally, the static route specified with both the next hop IP and the outgoing interface - such as

ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/0 192.0.2.1

- means this: Use this route with this next hop but only if that next hop is reachable through Gi0/0. If you check above what I wrote about static routes with next hops, I mentioned that the next hop address needs to be reachable but it can be either a directly attached network, or a remote network, in which the next hop is located, so there is a freedom in how the next hop is reachable. There are situations where you don't wish the router to have this freedom, and you want to lock down the validity of your static route and say: Use this route only when the next hop is reachable through this particular interface, otherwise consider the static route as invalid. That is exactly when this type of route with both the outgoing interface and the next hop is used, and it is okay to be used with Ethernet interfaces as well.

To summarize:

  • The static route with the next hop IP is the most reliable and most general static route and should be used whenever possible.
  • The static route with the outgoing interface is only suitable for point-to-point interfaces such as serial interfaces with HDLC, PPP, point-to-point Frame Relay subinterfaces, or Dialer interfaces. Using this type of route may be inevitable if you do not know the IP address of the next hop router - but the interface must still be a point-to-point technology. While this route is allowed with Ethernet interfaces too, it is a very bad idea with many ill side effects and dependencies to work reliably, and should be avoided.
  • The static route with both the next hop IP and outgoing interface is generally used when you ensure that the next hop of the static route resolves through the specified interface - and if not, the route is considered invalid. This would come in specific scenarios and does not need to be considered for the majority of cases.
  • Do not use a static route with the outgoing interface with Ethernet interfaces.

And regarding whether to use "0.0.0.0 0.0.0.0" or a specific network such as "192.168.0.0 255.255.255.0" in a static route - there is no general answer for that. From a principial standpoint, we should be always using the specific network. However, if we know that all existing/remaining networks that we have not specified yet are reachable through a single route, we can use the default route with the network/netmask of 0.0.0.0/0.0.0.0. When you see us here on these forums sometimes suggesting to use 0.0.0.0/0.0.0.0 to point to a handful of networks behind the other router in a two-router topology, it's just us being lazy and avoiding the need to specify the networks one by one ; )

Please feel welcome to ask further.

Best regards,
Peter

Hi Peter. Thanks so much for taking the time to explain everything in so much detail. 

One thing I want to clarify. When we use the interface scenario. We are always referring to the interface on the router that we are configuring correct? If yes, on a route such as -

ip route 192.168.2.0 255.255.255.0 g0/0 192.168.2.1

- the g0/0 is the interface of the router we are configuring and 192.168.2.1 is the ip address of the directly connected interface on the neighbour router. Am I guessing right? 

So to recap. 

First choice static route with next hop. i.e

 ip route 0.0.0.0 0.0.0.0 192.0.2.1 

which is the same as

 ip route 192.0.2.0 255.255.255.0 192.0.2.1

correct? 

For point-to-point we can use something like ip route 0.0.0.0 0.0.0.0 s0/0/0 (never with g0/0 for the reasons you mentioned in your response) 

Lastly we have ip route 0.0.0.0 0.0.0.0 g0/0 192.0.2.1 which would be exactly the same as "saying"

ip route 192.0.2.0 255.255.255.0 g0/0 192.0.2.1 

correct? If yes I still don't get how the router will find the next hop address in the particular scenario where the next hop is located on a different network. 

Thank you so much for your time. 

Regards

Luca

Hello Luca,

You are welcome!

 

When we use the interface scenario. We are always referring to the interface on the router that we are configuring correct?

Oh, no, no. Static routes are always configured to tell the router how to reach an unknown network through a known next hop. In 99% of static route configurations, the next hop is from a directly connected network - and that one is in the routing table already so you do not need to configure a static route for it. Remember that if you have an interface configured with "ip address ...", that resulting IP network is automatically added to the routing table as a directly connected network. The router knows it automatically because it has an interface in, and in fact, that knowledge is so trustworthy that the administrative distance of such directly connected network is 0. Static routes always have an administrative distance of 1 or more and so can never beat directly connected networks anyway.

So once again: A static route is configured when you need to tell the router about a network that is not known yet so that the router knows about it and places it into the routing table with the knowledge how it can reach it. You don't need to tell it about directly connected networks on interfaces configured with "ip address ..." since they are placed into the routing table automatically. But you need to tell the router about networks that are ultimately directly attached to other routers, and you either use a routing protocol for that, or configure static routes. But for each unknown network you're configuring with a static route, the next hop must already be known, and that next hop would be in 99.9% of cases based on a directly connected network.

Remember -

ip route <unknown network> <its netmask> <known next hop from a directly connected network>

As an example:

192.168.1.1/24 --- R1 --- 192.168.12.1/30 --------- 192.168.12.2/30 --- R2 --- 192.168.2.1/24

R1 and R2 are connected with a 192.168.12.0/30 network; R1 is 192.168.12.1/30, R2 is 192.168.12.2/30. Each of these routers also has another directly connected network that the other routers does not know about. R1 does not know about 192.168.2.0/24 while R2 does not know about 192.168.1.0/24. They both need to somehow get the knowledge of them so that they can route packets to them.

With static routes, the configuration would be:

On R1:

R1(config)# ip route 192.168.2.0 255.255.255.0 192.168.12.2

On R2:

R2(config)# ip route 192.168.1.0 255.255.255.0 192.168.12.1

Would this make sense?

Keep the questions coming.

Best regards,
Peter

Hello Peter thanks so much. This make sense yes. 

So what's the difference between this static route and one that has both next hop and exit interface. I know you have already explained this before, however your last example was easier to understand for me. Would you mind sharing an example of the next hop plus exit interface in the same way? Pretty please : ) I searched YouTube but most videos on the subject are not on English unfortunately. 

Many thanks in advance for your support

Regards

Luca

Hi Luca,

Okay... : )

 

192.168.1.1/24 - (fa0/1) R1 (fa0/0) - 192.168.12.1/30 ------ 192.168.12.2/30 - (gi0/0) R2 (gi0/1) - 192.168.2.1/24

So I've added device labels to the example, and intentionally, I've used various ones. You'll be surprised how little has changed in the static route commands:

R1:

ip route 192.168.2.0 255.255.255.0 FastEthernet0/0 192.168.12.2

R2:

ip route 192.168.1.0 255.255.255.0 GigabitEthernet0/0 192.168.12.1

As always, feel welcome to ask further.

Best regards,
Peter

Thanks so much for that. 

Ok so what is the reason for adding the interface? I think you mentioned in another post that it's because we want the route only to go via that particular interface right? But why? That's what I don't understand. 

Also in this particular case the interface in the statement is always that of the router we are making the configuration on correct? : )

I'm so very sorry for asking all these questions I'm trying to learn : ) 

Thanks so very much for your patience 

Unsure your last couple of questions, were answered.

If not, for "Ok so what is the reason for adding the interface? I think you mentioned in another post that it's because we want the route only to go via that particular interface right? But why? That's what I don't understand.", this might help Why a Static Route with Interface AND Numerical Next-Hop? 

In the reference posting, you find a reference to a document where you may want to read the last paragraph in the section I'm linking to: Static Route to Interface without Next Hop IP Address 

"Also in this particular case the interface in the statement is always that of the router we are making the configuration on correct?"

Yes.

"I'm so very sorry for asking all these questions I'm trying to learn"

I don't believe you need to apologize, we learn by asking questions.  ; )

Martin L
VIP
VIP

In addition to Peter's reply, the IP and network of all 0s and mask with 0s is reserved. It literally means all IPs or any IP and any mask; In case of

ip route 0.0.0.0 0.0.0.0

also known as a default route, this special network is used to indicate all  networks and IPs (known or unknown plus Internet).  This default route is also known as "Gateway of last resort" which you can see from

show ip route

output.  Note that term "known or unknown" is misleading a bit. Routes that are unknown like Internet destinations are not present in your routing table (RIB for short).  But also you may have your own "known" routes missing in RIB on purpose.  So, you could say "I use

ip route 0/0

for all missing routes in my routing table (RIB)". 

Case 1. Since there are lots of Internet routes, it is not practical to have all possible Internet routes in RIB. This is why

ip route 0/0

is used on your Gateway router which connects to ISP.  Otherwise, you would have to know IPs and networks of millions sites, emails, other online services you visit at least once. Even if you know exact IP of this site or email servers, you wouldn't want to store all 4 billions of them on your router, right?

Case 2. Secondary use of this

ip route 0/0

route is to reduce number of routes in your router which leads to better/faster router performance, lower amount of memory, smaller tables, etc.  This is known or referred as optimization of RIB.  If your large organization have 100 remote offices with 1 unique network on single router per each location plus several thousands employees working in 50 departments in HQ (each department has its own subnet/network).  Normally only HQ would have all your networks known and installed in RIB but not Your remote office router.  Your remote office router doesn't need all 149 routes to be installed in RIB. Since he has only 1 way out to reach others (via HQ), he needs only default route ! This is also known as stub routing / stub router.

Case 3,  based on case 2, HQ could further optimize its internal network (and routers RIB) by using a summary routes. A summary route is a static route that includes common network destinations grouped into one summary route and advertised whenever it is possible.  For example you could have 1 class C network split into 32 networks each with /29 mask for some smaller departments.  Those 32 networks could be summarized into one /24 network and advertised to others instead of all 32 individual networks advertisements.  Fewer routes in router RIB, less work, better performance and faster traffic forwarding times.

Case 4, You could use static routes for traffic engineering.  If you have 2 ways to get to network x and y, you could add static routes telling router to reach net x via interface x and net y via interface y.  

Other common cases for static routing is to use them as a back up route (aka floating route), use in SLA for tracking, in PBR, just to mention a few.  

Regards, ML
**Please Rate All Helpful Responses **

Hi Martin 

Thank you very much for the info. I am learning a ton of stuff. And I am slowly but surely starting to get my head around it. There is a lot to learn and I still feel a bit confused at times, but I am definitely making progress.

Your support is greatly appreciated.

Regards

Luca

Review Cisco Networking products for a $25 gift card