cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3402
Views
15
Helpful
25
Replies

Need explaination about static routes

Hi All,

As we all have read and know that by default AD of static route (with next hop IP) is 1 and AD will be 0 if directly connected.

However, I was playing with these and found that Routing table inserts both  the routes with same AD, i.e. AD 1.

Below is my sample which i was experimenting with.

R1 is connected to R2

R1 fa0/0 connected to R2 fa0/0

R2 fa0/1 connected to R2 fa0/1

Configs as below:

** R2 **

int lo0

ip add 2.2.2.2 255.255.255.255

int fa0/0

ip add 192.168.1.2 255.255.255.252

no shut

int fa0/1

ip add 172.32.1.2 255.255.255.252

no shut

exit

ip route 0.0.0.0 0.0.0.0 192.168.1.1

ip route 0.0.0.0 0.0.0.0 fa0/1

** R1 **

int lo0

ip add 1.1.1.1 255.255.255.255

int fa0/0

ip add 192.168.1.1 255.255.255.252

no shut

int fa0/1

ip add 172.32.1.1 255.255.255.252

no shut

exit

ip route 0.0.0.0 0.0.0.0 192.168.1.2

ip route 0.0.0.0 0.0.0.0 fa0/1

How ever, now if you look at routing table for either R1 and R2, you will see that default route has got 2 paths.

I turned on the debugs and it also shows the same thing that 0.0.0.0 is added with metric [1/0] also where i have given exit interface.

R1#sh ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance 1, metric 0 (connected), candidate default path

  Routing Descriptor Blocks:

  * 192.168.1.2

      Route metric is 0, traffic share count is 1

    directly connected, via FastEthernet0/1

      Route metric is 0, traffic share count is 1

With fa0/0 shut

R1#sh ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance 1, metric 0 (connected), candidate default path

  Routing Descriptor Blocks:

  * directly connected, via FastEthernet0/1

      Route metric is 0, traffic share count is 1

R1#

With fa0/1 shut

R1#sh ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance 1, metric 0, candidate default path

  Routing Descriptor Blocks:

  * 192.168.1.2

      Route metric is 0, traffic share count is 1

R1#

With both fa0/0 and fa0/1 UP

R1#debug ip routing

IP routing debugging is on

R1#

R1#clear ip route *

R1#

*Mar  1 00:15:18.395: RT: NET-RED 0.0.0.0/0

*Mar  1 00:15:18.395: RT: is_up: FastEthernet0/0 1 state: 4 sub state: 1 line: 1 has_route: True

*Mar  1 00:15:18.395: RT: add 192.168.1.0/30 via 0.0.0.0, connected metric [0/0]

*Mar  1 00:15:18.395: RT: NET-RED 192.168.1.0/30

*Mar  1 00:15:18.395: RT: interface FastEthernet0/0 added to routing table

*Mar  1 00:15:18.395: RT: is_up: FastEthernet0/1 1 state: 4 sub state: 1 line: 1 has_route: True

*Mar  1 00:15:18.395: RT: add 172.32.1.0/30 via 0.0.0.0, connected metric [0/0]

*Mar  1 00:15:18.395: RT: NET-RED 172.32.1.0/30

*Mar  1 00:15:18.399: RT: interface FastEthernet0/1 added to routing table

*Mar  1 00:15:18.399: RT: is_up: Loopback0 1 state: 4 sub state: 1 line: 0 has_route: True

*Mar  1 00:15:18.399: RT: add 1.1.1.1/32 via 0.0.0.0, connected metric [0/0]

*Mar  1 00:15:18.403: RT: NET-RED 1.1.1.1/32

*Mar  1 00:15:18.403: RT: interface Loopback0 added to routing table

*Mar  1 00:15:23.403: RT: add 0.0.0.0/0 via 0.0.0.0, static metric [1/0]

*Mar  1 00:15:23.403: RT: NET-RED 0.0.0.0/0

*Mar  1 00:15:23.407: RT: default path is now 0.0.0.0 via 0.0.0.0

*Mar  1 00:15:23.407: RT: new default network 0.0.0.0

*Mar  1 00:15:23.407: RT: NET-RED 0.0.0.0/0

*Mar  1 00:15:23.411: RT: add 0.0.0.0/0 via 192.168.1.2, static metric [1/0]

*Mar  1 00:15:23.411: RT: NET-RED 0.0.0.0/0

*Mar  1 00:15:23.411: RT: NET-RED 0.0.0.0/0

*Mar  1 00:15:23.415: RT: NET-RED 0.0.0.0/0

R1#

So, is it like what we have read and known about AD is wrong ??

Any guidance will be appreciated.

Regards,

Smitesh

25 Replies 25

Peter Paluch
Cisco Employee
Cisco Employee

Hi Smitesh,

It is true that a directly connected route has AD=0 and a static route has AD=1. However, a static route is always a static route to the routing table manager, regardless of the egress part configuration, whether it is a next-hop IP or an egress interface. You have configured two static routes to the same destination, so they will both be present in the routing table, just as you have seen yourself. Observe closely the output you have yourself provided:

R1#sh ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance 1, metric 0 (connected), candidate default path

  Routing Descriptor Blocks:

  * 192.168.1.2

      Route metric is 0, traffic share count is 1

    directly connected, via FastEthernet0/1

      Route metric is 0, traffic share count is 1

See the "distance 1" comment - it means that both these entires have AD=1, the one through 192.168.1.2 and also the one out the interface Fa0/1.

Once more, to the routing table, a static route will always be a static route, despite being configured with an egress interface. The AD=0 will be assigned only to networks that result from the IP address/mask asssigned to directly connected interface.

There is a confusing fact about distance-vector protocols on Cisco routers: RIP, IGRP and EIGRP treat the static routes with egress interfaces as if they were directly connected, and hence can be imported into the routing protocol using the ordinary network command (not necessary to redistribute them in the usual redistribute fashion). However, this is valid only for RIP/IGRP/EIGRP. OSPF and IS-IS do not work this way. This behavior is definitely a nuisance, perhaps even an annoyance, but that's the way it is. However, this behavior is concerned only about advertising these routes. Within the routing table, however, these routes still have AD=1 because they are still defined statically.

Best regards,

Peter

Hi Peter,

Then why does it shows the below output when I shut down the Fa0/0

With fa0/0 shut

R1#sh ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance  1, metric 0 (connected), candidate default path

  Routing Descriptor Blocks:

  * directly connected, via FastEthernet0/1

      Route metric is 0, traffic share count is 1

R1#

Note connected in brackets and also *directly  connected.

So, you want to mean that AD will be zero of interaces only and none of the static route, for which we give exit  interface will have AD= 1 only.

If it is so, then output of show ip route when we have given an exit interface is misleading.

Any explanation, for why it is so.

Regards,

Smitesh

Hi Smitesh,

R1#sh ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance  1, metric 0 (connected), candidate default path

  Routing Descriptor Blocks:

  * directly connected, via FastEthernet0/1

      Route metric is 0, traffic share count is 1

R1#

Note connected in brackets and also *directly  connected.

I agree that the output of the show ip route is confusing. However, note that the route is 'Known via "static"', i.e. its origin is a static config, and hence the AD=1. The (connected) means that the route is defined only with its egress interface, in other words, it is "on the interface", "via the interface", in almost all aspects it is directly connected - but not truly connected, as this route is not configured on the interface itself.

So, you want to mean that AD will be zero of interaces only and none of  the static route, for which we give exit  interface will have AD= 1  only.

Exactly. Only networks configured on interfaces will ever have AD=0. You will never be able to configure a static route with AD=0. Static routes will always have AD=1 or higher.

If it is so, then output of show ip route when we have given an exit interface is misleading.

Any explanation, for why it is so.

Essentially, it is because a static route configured with an egress interface is used as if it was a directly connected route. For example, defining a static route out the FastEthernet interface will mean that the router will consider all destinations in that network as directly connected on that interface, and will try to ARP for their MAC addresses - a process that is usual only if the network is on a directly connected interface.

There are always two aspects to having a route in the routing table: the one aspect is how the route got there and what is its origin (i.e. the control plane of the router), the other aspect is about using that route after it has been placed into the routing table (i.e. the forwarding plane of the router). For the control plane that is responsible for building the routing table, a static route is a static route without further discussion, and it does not matter whether it uses a next-hop or an egress interface. Therefore, unconditionally, AD of static routes is always at least 1, and never 0. For the data plane, there is a difference in how the static route is used when encountered during packet routing: static route with a next-hop IP address will result in this IP address being recursively looked up in the routing table and the packet will be sent out the interface that is the result of this recursive lookup. For a static route with an egress interface, the route is handled as directly connected, and the router will ARP for the MAC address, using the packet's destination IP directly in the ARP (note that the real network may be several hops away, prompting the ProxyARP to jump into action).

Does this make it a little more understandable? Please feel welcome to ask further.

Best regards,

Peter

Hi Peter,

I completely agree to the fact that when we have a static routing pointing to a destination other than the local subnet and if we have it via connected interface then the router will arp for the destination network and if we have a static route using next hop then  it will arp for the next hop ip.

The question here is, when using static route with egress interface or static route with next hop, we incur a different AD values.

The answer is NO for the new IOS version and YES for the OLD.

if we had two static routes from the SAME ROUTER towards a single destination network via TWO DIFFERENT INTERFACES assuming, 10.1.1.0 is the destination N/W reachable via ROUTER R1 via two different interfacec FA0/1 (12.1.1.1) and FA0/2 (11.1.1.1) and if I happened to configure the static routes as

ip route 10.1.1.0 255.255.255.0 FA0/1

ip route 10.1.1.0 255.255.255.0 11.1.1.2

and then when u do a sh ip route 10.1.1.0 , u will see a route that points out FA0/1 or Next Hop 11.1.1.2 ? and with which AD ?

If it was an OLD IOS :

It would have had installed FA0/1 for its AD being 0

if its a new IOS :

We have both the routes getting installed if IP CEF is enabled or if its disabled than again we will see connected interface FA0/1 as the route being installed this time with the AD of 1

Hello,

If it was an OLD IOS :

It would have had installed FA0/1 for its AD being 0

Aaah, yes, you are correct. I have not worked with IOSes that assign the AD=0 to static routes defined with egress interfaces, I have only heard about them but yes, I definitely concur, I have heard of this behavior. Nevertheless, I do not like this old behavior. A static route is a static route - why should it be as trustworthy as a network on a directly connected interface? I must say that I find the new behavior with static routes having AD=1 much more appropriate in this respect.

Still, +5 points for pointing out this peculiarity

if its a new IOS :

We  have both the routes getting installed if IP CEF is enabled or if its  disabled than again we will see connected interface FA0/1 as the route  being installed this time with the AD of 1

Here, I disagree. Regardless of CEF, you will get both routes installed and used. CEF is about optimizing the routing table contents and lookups after the routing table has been populated, but should have no effect as to what routes may enter the routing table. Confirmed on a 12.4T IOS:

Router#conf t 

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip cef

Router(config)#int fa0/0

Router(config-if)#ip addr 10.0.0.1 255.255.255.0

Router(config-if)#no shut

Router(config-if)#exit

Router(config)#

*Mar  1 00:00:35.699: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar  1 00:00:36.699: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.2

Router(config)#ip route 0.0.0.0 0.0.0.0 fa0/0

Router(config)#do show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

Gateway of last resort is 10.0.0.2 to network 0.0.0.0

     10.0.0.0/24 is subnetted, 1 subnets

C       10.0.0.0 is directly connected, FastEthernet0/0

S*   0.0.0.0/0 [1/0] via 10.0.0.2

               is directly connected, FastEthernet0/0

Router(config)#do show ip cef

%CEF not running

Prefix              Next Hop             Interface

Router(config)#

Best regards,

Peter

Thanks Peter,

Actually again there is a catch here... you are seeing both routes without CEF is because your next hop and egress interface are the same.

Fa0/0 is your egress interface and 10.0.0.2 is the next hop IP of your FA0/0.

So in your case you are pointing two static routes via the same interface, one via connected and other via its own next hop and hence you can see both being installed even without CEF enabled.

if you point two static routes via two different interfaces(of different n/ws) as i have mentioned above, with one pointing via its egress interface and one via its next hop... you will see only one route being installed with the destination n/w reachable via the egress interface with an AD of 1 and IP CEF disabled.

Regards,

Vinayak

Hello Vinayak,

Thank you for response but I can not confirm that neither. Check the following output:

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip cef

Router(config)#int fa0/0

Router(config-if)#ip addr 192.168.0.1 255.255.255.0

Router(config-if)#no shut

Router(config-if)#

*Mar  1 00:00:35.871: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

*Mar  1 00:00:36.871: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

Router(config-if)#int fa0/1

Router(config-if)#ip addr 192.168.1.1 255.255.255.0

Router(config-if)#no shut

Router(config-if)#

*Mar  1 00:00:46.959: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up

*Mar  1 00:00:47.959: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up

Router(config-if)#exit

Router(config)#ip route 0.0.0.0 0.0.0.0 192.168.0.2

Router(config)#ip route 0.0.0.0 0.0.0.0 fa0/1

Router(config)#ip route 192.0.2.0 255.255.255.0 192.168.1.2

Router(config)#ip route 192.0.2.0 255.255.255.0 fa0/0

Router(config)#

Router(config)#do show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

Gateway of last resort is 192.168.0.2 to network 0.0.0.0

C    192.168.0.0/24 is directly connected, FastEthernet0/0

C    192.168.1.0/24 is directly connected, FastEthernet0/1

S    192.0.2.0/24 [1/0] via 192.168.1.2

                  is directly connected, FastEthernet0/0

S*   0.0.0.0/0 [1/0] via 192.168.0.2

               is directly connected, FastEthernet0/1

Router(config)#do show ip cef

%CEF not running

Prefix              Next Hop             Interface

Note that this time, I have created an unspecific (default) and a specific 192.0.2.0/24 route and pointed them through two different interfaces, always one pointing to a next-hop IP, the second pointing to an egress interface. IP CEF is deactivated, yet the routing table contains both networks and both entries for each of them.

Best regards,

Peter

Hi Peter,

As you can see from your sh ip route o/p :

for both 0.0.0.0/0 and 192.0.2.0/24 , the routing table shows only one route towards the static route for which you have mentioned the egress interface.

Router(config)#do show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is 192.168.0.2 to network 0.0.0.0

C    192.168.0.0/24 is directly connected, FastEthernet0/0
C    192.168.1.0/24 is directly connected, FastEthernet0/1
S    192.0.2.0/24 [1/0] via 192.168.1.2
                  is directly connected, FastEthernet0/0
S*   0.0.0.0/0 [1/0] via 192.168.0.2
               is directly connected, FastEthernet0/1

This is what you have configured for the above two prefixes as static routes pointing the egress interface,

Router(config)#ip route 0.0.0.0 0.0.0.0 fa0/1
Router(config)#ip route 192.0.2.0 255.255.255.0 fa0/0

It has not installed two routing entries for the network 192.0.2.0 and 0.0.0.0 rather in routing table it shows only 1 routing entry for both prefixes for which you have used static route with egress interface.


Regards,
Vinayak



Hi Vinayak,

No, you are reading the routing table incorrectly. There are two routing descriptor blocks present for both routes: one of them is the IP address, the second (on the second line) is the egress interface. This can be confirmed by looking at the routing table in detail:

Router#show ip route 192.0.2.0

Routing entry for 192.0.2.0/24

  Known via "static", distance 1, metric 0 (connected)

  Routing Descriptor Blocks:

  * 192.168.1.2

      Route metric is 0, traffic share count is 1

    directly connected, via FastEthernet0/0

      Route metric is 0, traffic share count is 1

Router#show ip route 0.0.0.0

Routing entry for 0.0.0.0/0, supernet

  Known via "static", distance 1, metric 0 (connected), candidate default path

  Routing Descriptor Blocks:

  * 192.168.0.2

      Route metric is 0, traffic share count is 1

    directly connected, via FastEthernet0/1

      Route metric is 0, traffic share count is 1

Best regards,

Peter

Hi Peter,

If you enable CEF then... in the routing table, you will see two entries for both the networks 192.0.2.0 and 0.0.0.0

Currently it is showing only one entry for both prefixes, and it is pointing out the interface for which you have used static route with egress interface.

If you enable CEF, then you will see two entries for 192.0.2.0 , one going out via the static route used via connected and one via the interface used via next hop and same is the case for 0.0.0.0

Hi Peter,

Yes seems you are right here

Yes, I mis read the routing table, we can see two routes even without CEF being enabled.

oooops, seems since the AD now comes to 1 for both, it will take into account for both. CEF will be used only when it requires to be packet switched rather than process switched.

Thanks again for clearing on this.

Hi Smitesh,

Hope you have got two answers though you had asked only 1.

1. Static routes pointing towards an egress interface and pointing towards a next hop, both will have AD of 1 (earlier IOS version considered static routing pointing egress interface as AD of 0 and with next hop AD as 1)

2. If we have both static routes one pointing with an egress interface and one pointing towards a next hop for the same destination then routing table will insert both the routes irrespective of CEF.

Regards,

Vinayak

Peter and Vinayak,

Thanks for a wonderful discussion.

No offense intended, but I would like if any Hall of Fame members can also shed there inputs on this.

Peter: Can you pull couple of strings to get them involved in this. I'm not too sure of them definately jumping into this discussion. Just a request, if you can pull some of them.

Regards,

Smitesh

Smitesh,

Sure. I'll try to contact some of them.

Best regards,

Peter

Smitesh

I am responding to this as Peter dropped me a private message.

Firstly i would say the only reason Peter is not a Hall of Fame member is because he hasn't been around long enough ie. he simply hasn't answered enough questions yet. His knowledge and his answers are certainly of the quality, in my opinion, of any Hall of Famer. So you won't necessarily get any more insights from other HoFs.

As for the actual question not sure what else can be added to be honest. This has come up in the past on NetPro. As already mentioned the old IOS versions used to differentiate between a static route with a next-hop IP address and a static route pointing out of an interface. With later IOS versions they are not seen as different and both have an AD of 1.

Personally i think the later IOS version behaviour is more sensible. They are both static routes added manually to the router and neither is actually a directly connected network. Only directly connected networks should really have an AD of 0 and having a static route with an exit interface does not make that network directly connected.

Jon

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card