Configure IP Default Static Routes

Default Static Route

This topic shows you how to configure a default route for IPv4 and IPv6. It also explains the situations in which a default route is a good choice. A default route is a static route that matches all packets. Instead of routers storing routes for all of the networks in the internet, they can store a single default route to represent any network that is not in the routing table.

Routers commonly use default routes that are either configured locally or learned from another router, using a dynamic routing protocol. A default route does not require any far-left bits to match between the default route and the destination IP address. A default route is used when no other routes in the routing table match the destination IP address of the packet. In other words, if a more specific match does not exist, then the default route is used as the Gateway of Last Resort.

Default static routes are commonly used when connecting an edge router to a service provider network, or a stub router (a router with only one upstream neighbor router).

The figure shows a typical default static route scenario.

R1 only needs to know about directly connected networks. For all other networks it can use a default static route pointing to R2

IPv4 Default Static Route

The command syntax for an IPv4 default static route is similar to any other IPv4 static route, except that the network address is 0.0.0.0 and the subnet mask is 0.0.0.0. The 0.0.0.0 0.0.0.0 in the route will match any network address.

Note: An IPv4 default static route is commonly referred to as a quad-zero route.

The basic command syntax for an IPv4 default static route is as follows:

Router(config)# ip route 0.0.0.0 0.0.0.0 {ip-address | exit-intf}

IPv6 Default Static Route

The command syntax for an IPv6 default static route is similar to any other IPv6 static route, except that the ipv6-prefix/prefix-length is ::/0, which matches all routes.

The basic command syntax for an IPv6 default static route is as follows:

Router(config)# ipv6 route ::/0 {ipv6-address | exit-intf}

Configure a Default Static Route

In the figure, R1 could be configured with three static routes, one to reach each of the remote networks in the example topology. However, R1 is a stub router because it is only connected to R2. Therefore, it would be more efficient to configure a single default static route.

The example shows an IPv4 default static route configured on R1. With the configuration shown in the example, any packets not matching more specific route entries are forwarded to R2 at 172.16.2.2.

R1(config)# ip route 0.0.0.0 0.0.0.0 172.16.2.2

An IPv6 default static route is configured in similar fashion. With this configuration any packets not matching more specific IPv6 route entries are forwarded to R2 at 2001:db8:acad:2::2

R1(config)# ipv6 route ::/0 2001:db8:acad:2::2

Verify a Default Static Route

Verify IPv4 Default Static Route

The show ip route static command output from R1 displays the contents of the static routes in the routing table. Note the asterisk (*) next to the route with code ‘S’. As displayed in the codes table in the show ip route output, the asterisk indicates that this static route is a candidate default route, which is why it is selected as the Gateway of Last Resort.

R1# show ip route static
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 
+ - replicated route, % - next hop override 

Gateway of last resort is 172.16.2.2 to network 0.0.0.0

S* 0.0.0.0/0 [1/0] via 172.16.2.2 
R1#

Verify IPv6 Default Static Route

This example shows the show ipv6 route static command output to display the contents of the routing table.

R1# show ipv6 route static
IPv6 Routing Table - default - 8 entries
Codes: C - Connected, L - Local, S - Static, U - Per-user Static route
       B - BGP, R - RIP, H - NHRP, I1 - ISIS L1
       I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary, D - EIGRP
       EX - EIGRP external, ND - ND Default, NDp - ND Prefix, DCE - Destination
       NDr - Redirect, RL - RPL, O - OSPF Intra, OI - OSPF Inter
       OE1 - OSPF ext 1, OE2 - OSPF ext 2, ON1 - OSPF NSSA ext 1
       ON2 - OSPF NSSA ext 2, la - LISP alt, lr - LISP site-registrations
       ld - LISP dyn-eid, lA - LISP away, le - LISP extranet-policy
       a - Application
S   ::/0 [1/0]
     via 2001:DB8:ACAD:2::2

R1#

Notice that the static default route configuration uses the /0 mask for IPv4 default routes and the ::/0 prefix for IPv6 default routes. Remember that the IPv4 subnet mask and IPv6 prefix-length in a routing table determines how many bits must match between the destination IP address of the packet and the route in the routing table. A /0 mask or ::/0 prefix indicates that none of the bits are required to match. As long as a more specific match does not exist, the default static route matches all packets.

 

Configure Floating Static Routes