Which two route source codes are automatically created within a routing table whenever a router interface is configured with an IP address and activated?

Introduction

This document describes how to configure a default route or gateway of last resort.

Prerequisites

Requirements

There are no specific requirements for this document.

Components Used

This document is not restricted to specific software and hardware versions. The command outputs shown were taken from a Cisco 3900 Series router with Cisco IOS®Software Release 15M.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.

Conventions

For more information on document conventions, see theCisco Technical Tips Conventions.

Background Information

Default routes are used to direct packets addressed to networks not explicitly listed in the routing table. Default routes are invaluable in topologies where it is not desirable to learn all the more specific networks, as in case of stub networks, or not feasible due to limited system resources such as memory and limited resources.

The next IP commands are used and described in more detail:

  • ip default-gateway

  • ip default-network

  • ip route 0.0.0.0 0.0.0.0

Use Command ip default-gateway

Theip default-gatewaycommand differs from the other two commands as it must be used only be used whenip routingis disabled on the Cisco router. For instance, if the router is a host in the IP world, you can use this command to define a default gateway for it. You can also use this command when your low end Cisco router is in boot mode in order to TFTP a Cisco IOS® Software image to the router. In boot mode, the router does not haveip routingenabled. This example defines the router on IP address 172.16.15.4 as the default route:

ip default-gateway 172.16.15.4

Use Command ip default-network

Unlike theip default-gatewaycommand, you can useip default-network whenip routingis enabled on the Cisco router. When you configureip default-networkthe router considers routes to that network for installation as the gateway of last resort on the router. For every network configured withip default-network, if a router has a route to that network, that route is flagged as a candidate default route. This network diagram displays the routing table taken from router R1:

Which two route source codes are automatically created within a routing table whenever a router interface is configured with an IP address and activated?

R1#show ip route
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks


C 10.44.192.0/24 is directly connected, GigabitEthernet0/0
L 10.44.192.1/32 is directly connected, GigabitEthernet0/0
C 10.108.99.0/24 is directly connected, GigabitEthernet0/1
L 10.108.99.1/32 is directly connected, GigabitEthernet0/1
S 192.168.1.0/24 [1/0] via 10.44.192.2

Notice that the static route to 192.168.1.0 via 10.44.192.2 and that the gateway of last resort is not set. If you configureip default-network 192.168.1.0, the routing table changes as follows:

R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip default-network 192.168.1.0
R1(config)#end
R1#
R1#show ip route
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is 10.44.192.2 to network 192.168.1.0

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


10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.44.192.0/24 is directly connected, GigabitEthernet0/0
L 10.44.192.1/32 is directly connected, GigabitEthernet0/0
C 10.108.99.0/24 is directly connected, GigabitEthernet0/1
L 10.108.99.1/32 is directly connected, GigabitEthernet0/1
S* 192.168.1.0/24 [1/0] via 10.44.192.2
R1#
R1#show ip protocols
*** IP Routing is NSF aware ***

Routing Protocol is "application"


Sending updates every 0 seconds
Invalid after 0 seconds, hold down 0, flushed after 0
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Maximum path: 32
Routing for Networks:
Routing Information Sources:
Gateway Distance Last Update
Distance: (default is 4)

R1#

The gateway of last resort is now set as 10.44.192.2. This result is independent of any routing protocol, as shown by theshow ip protocolscommand output no routing protocol is configured. You can add another candidate default route with the configuration of another instance ofip default-network:

R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip route 172.17.24.0 255.255.255.0 10.108.99.2
R1(config)#ip default-network 172.17.24.0
R1(config)#end
R1#
R1#show ip route
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is 10.44.192.2 to network 192.168.1.0

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


10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.44.192.0/24 is directly connected, GigabitEthernet0/0
L 10.44.192.1/32 is directly connected, GigabitEthernet0/0
C 10.108.99.0/24 is directly connected, GigabitEthernet0/1
L 10.108.99.1/32 is directly connected, GigabitEthernet0/1
172.17.0.0/16 is variably subnetted, 2 subnets, 2 masks
S 172.17.0.0/16 [1/0] via 172.17.24.0
S 172.17.24.0/24 [1/0] via 10.108.99.2
S* 192.168.1.0/24 [1/0] via 10.44.192.2

Note: After theip default-networkcommand was entered you can observe that the network was not flagged as a default network. TheFlag a Default Networksection explains the reason.

Flag a Default Network

Theip default-networkcommand is classful, this means that if the router has a route to the subnet indicated by this command, it installs the route to the major network. At this point neither network has been flagged as the default route. Theip default-networkcommand must be run again, this time with the use of the major network in order to flag the candidate as a default route.

R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#ip default-network 172.17.0.0


R1(config)#endR1#sh*Jul 15 22:32:42.829: %SYS-5-CONFIG_I: Configured from console by conso

R1#show ip route

Codes: L - local, 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, H - NHRP, l - LISP a - application route + - replicated route, % - next hop override, p - overrides from PfRGateway of last resort is 172.17.24.0 to network 172.17.0.0S* 0.0.0.0/0 [1/0] via 172.17.24.0 10.0.0.0/8 is variably subnetted, 4 subnets, 2 masksC 10.44.192.0/24 is directly connected, GigabitEthernet0/0L 10.44.192.1/32 is directly connected, GigabitEthernet0/0C 10.108.99.0/24 is directly connected, GigabitEthernet0/1L 10.108.99.1/32 is directly connected, GigabitEthernet0/1

* 172.17.0.0/16 is variably subnetted, 2 subnets, 2 masks


S* 172.17.0.0/16 [1/0] via 172.17.24.0S 172.17.24.0/24 [1/0] via 10.108.99.2

S* 192.168.1.0/24 [1/0] via 10.44.192.2

If the original static route had been configured to the major network, the previous step would not have been necessary.

There are still no IP Protocols configured in the router, without any dynamic protocols you can configure your router to choose from a number of candidate default routes based on whether the routing table has routes to networks other than 0.0.0.0/0. Theip default-networkcommand allows you to configure robustness into the selection of a gateway of last resort. Rather than the use of static routes to specific next-hops, you can have the router choose a default route to a particular network based in the routing table information.

If you lose the route to a particular network, the router selects the other candidate default. In that scenario, you can then remove the lost route from the configuration as shown in the next output:

R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#no ip route 172.17.24.0 255.255.255.0 10.108.99.2
R1(config)#end
*Jul 15 22:52:59.047: %SYS-5-CONFIG_I: Configured from console by console

After you remove the static route to the network, the routing table looks like this:

R1#show ip route
Codes: L - local, 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, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is 10.44.192.2 to network 192.168.1.0

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


10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.44.192.0/24 is directly connected, GigabitEthernet0/0
L 10.44.192.1/32 is directly connected, GigabitEthernet0/0
C 10.108.99.0/24 is directly connected, GigabitEthernet0/1
L 10.108.99.1/32 is directly connected, GigabitEthernet0/1
S* 192.168.1.0/24 [1/0] via 10.44.192.2
R1#

Use Different Routing Protocols

Gateways of last resort selected via theip default-networkcommand are propagated differently based on which routing protocol is used. For EIGRP there are different methods to Configure a Default Route in EIGRP which are preferred. The default route announced with theip default-networkcommand is not propagated by Open Shortest Path First (OSPF) or by Intermediate System-to-Intermediate System (IS-IS). For more detailed information on behavior of default routes with OSPF, refer toHow Does OSPF Generate Default Routes?.

Use Command ip route 0.0.0.0 0.0.0.0

A static route configured with the command ip route 0.0.0.0 0.0.0.0 is another way to set the gateway of last resort on a router. As with theip default-networkcommand, the use of the static route to 0.0.0.0 is not dependent on any routing protocols. However,ip routingmust be enabled on the router.

Note: EIGRP propagates a route to network 0.0.0.0, but the static route must be redistributed into the routing protocol.

In earlier versions of RIP, the default route created through theip route 0.0.0.0 0.0.0.0was automatically advertised by RIP routers. In Cisco IOS Software Release 12 and later, RIP does not advertise the default route if the route is not learned via RIP. It can be necessary to redistribute the route into RIP.

The default routes configured with theip route 0.0.0.0 0.0.0.0command are not propagated by OSPF and IS-IS. Additionally, this default route cannot be redistributed into OSPF or IS-IS through theredistributecommand. Use the default-information originate command to generate a default route into an IS-IS or OSPF routing domain. For more detailed information about the behavior of default routes with OSPF, please refer toHow Does OSPF Generate Default Routes?. The next output is an example on how to configure a gateway of last resort with the use of theip route 0.0.0.0 0.0.0.0command:

R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#ip route 0.0.0.0 0.0.0.0 10.108.99.2


R1(config)#endR1#

R1#show ip route

Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static route, H - NHRP, l - LISPa - application route+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is 10.108.99.2 to network 0.0.0.0

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

10.0.0.0/8 is variably subnetted, 4 subnets, 2 masksC 10.44.192.0/24 is directly connected, GigabitEthernet0/0L 10.44.192.1/32 is directly connected, GigabitEthernet0/0C 10.108.99.0/24 is directly connected, GigabitEthernet0/1L 10.108.99.1/32 is directly connected, GigabitEthernet0/1D 192.168.1.0/24 [90/130816] via 10.44.192.2, 00:20:24, GigabitEthernet0/0

R1#show ip route 0.0.0.0 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:* 10.108.99.2

Route metric is 0, traffic share count is 1

Note:If you configure multiple networks as candidate default routes via theip default-networkcommand, the network that has the lowest administrative distance is chosen as the network for the gateway of last resort. If all the networks have the same administrative distance then the network listed first in the routing table is chosen as the network for the gateway of last resort. If you use both theip default-networkandip route 0.0.0.0 0.0.0.0commands to configure candidate default networks theip route 0.0.0.0 0.0.0.0command, takes precedence and is chosen for the gateway of last resort. If you use multipleip route 0.0.0.0 0.0.0.0commands to configure a default route, traffic is load-balanced over the multiple routes.

Summary

Use theip default-gatewaycommand whenip routingis disabled on a Cisco router. Use theip default-networkorip route 0.0.0.0 0.0.0.0commands to set the gateway of last resort on Cisco routers that haveip routingenabled. The way in which routing protocols propagate the default route information varies for each protocol.