How to Configure a Default Route

This post covers how to configure default routes in both IPv4 and IPv6 on Cisco routers using static route commands. It includes verification steps using show commands and explains key concepts like gateway of last resort and longest-prefix matching. Practical CLI examples are provided throughout.

How to Configure a Default Route

When a router receives a packet and has no specific route to the destination, it needs somewhere to send it. That "somewhere" is the default route. Think of it like the "if all else fails, send it here" instruction in your routing table. For most networks, the default route points toward the internet or an upstream device that knows where everything else is.

In this post, we will cover how to configure default routes for both IPv4 and IPv6, verify they are working correctly, and understand what is actually happening in the routing table.

What Is a Default Route?

A default route matches any destination that does not have a more specific entry in the routing table. In IPv4, it is represented as 0.0.0.0/0. In IPv6, the equivalent is ::/0. These prefixes have a prefix length of zero, meaning they match everything. Because of longest-prefix matching, a more specific route will always win over the default route when both exist.

Configuring a Default Route in IPv4

The syntax for a static default route in IPv4 is straightforward. You use the ip route command followed by the network 0.0.0.0 and subnet mask 0.0.0.0, then the next-hop IP address or exit interface.

Router(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.1

In this example, any packet without a matching route will be forwarded to the next-hop address 192.168.1.1. You can also specify an exit interface instead of a next-hop address, though using a next-hop IP is generally preferred on multi-access networks like Ethernet.

Verifying the IPv4 Default Route

After configuring the route, use show ip route to confirm it appears in the routing table. Look for the entry marked with an S (static) and an asterisk, which indicates it is a candidate default route.

Router# show ip route
...
Gateway of last resort is 192.168.1.1 to network 0.0.0.0

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

The line "Gateway of last resort is 192.168.1.1" confirms that the default route is active. The [1/0] shows the administrative distance of 1 and a metric of 0, both standard for a static route.

Configuring a Default Route in IPv6

IPv6 default route setup follows the same logic, but uses the ipv6 route command and the ::/0 prefix.

Router(config)# ipv6 route ::/0 2001:db8:1::1

This tells the router: for any IPv6 destination not found in the routing table, forward the packet to 2001:db8:1::1. Make sure IPv6 routing is enabled on the router first with ipv6 unicast-routing, otherwise IPv6 packets will not be routed at all.

Verifying the IPv6 Default Route

Use show ipv6 route to verify the entry was added correctly.

Router# show ipv6 route
...
S   ::/0 [1/0]
     via 2001:db8:1::1

Just like IPv4, the S code indicates a static route. If you also see "IPv6 Routing Table" at the top and ::/0 listed, your default route setup is complete and working.

A Few Things to Keep in Mind

  • Routing loops: Be careful pointing the default route at a device that points back at you. This creates a loop and packets will bounce until their TTL expires.
  • Floating static routes: You can configure a backup default route by increasing the administrative distance. For example, ip route 0.0.0.0 0.0.0.0 10.0.0.1 254 will only be used if the primary route goes down.
  • Redistribution: If you need routers further into the network to learn about the default route, you may need to redistribute it into a routing protocol like OSPF using default-information originate.

What's Next

Now that you know how to configure a default route, the next step is understanding how static routes work more broadly, including host routes, summary routes, and when to use a next-hop versus an exit interface. We will also look at how dynamic routing protocols like OSPF handle default route propagation automatically across larger networks. Stay tuned.


Tools and resources for this topic