Just as a PC has a default gateway to get to its local router -- and therefore to the Internet -- many routers and switches also have default routes to access networks that aren't local. Default routes are a special type of route -- and an important part of IP routing. Understanding how and when to use default routes is imperative to proper network setup.
Think of a default route as a "gateway of last resort." This special route tells computers or other routers to contact the next hop of the default router if they don't have a more specific route. Without a default route, a router will drop a request for a network that isn't in its routing table and send ICMP Destination Unreachable to the source of the traffic.
Here's a simple example: Our PC has an IP address of 192.168.1.100 and a subnet mask of 255.255.255.0. Let's say we want to talk to a server on the LAN, which has an IP address of 192.168.1.200.
For this, we actually don't need a default route or default gateway configured on the PC. However, as soon as we want to talk to any other device not on the 192.168.1.0 network, we'll need to go to the default gateway/route -- for example, one at 192.168.1.1.
When talking about default gateways on PCs and default routes on routers and switches, it's important to differentiate between the two. A PC only connects to the network with a single interface, and it isn't a router; a switch (unless it's a Layer 3 switch) fits into the same category as the PC.
On the other hand, a router -- as long as it's really routing and not bridging -- has multiple interfaces. It uses a default route to know where to send traffic that isn't on one of the known networks.
Examples of default routes
Many times, people call default routes 0/0 routes because these routes have an IP address of 0.0.0.0 and a subnet mask of 0.0.0.0. This basically says, "For any IP address that has any subnet mask, send it my way."
What does a default route look like in a router's routing table? Here's an example:
Router# show ip route <…truncated…> Gateway of last resort is 192.168.1.1 to network 0.0.0.0 C 192.168.1.0/24 is directly connected, FastEthernet4 S* 0.0.0.0/0 [254/0] via 192.168.1.1
Here's what it looks like on a PC:
C:\> ipconfig Windows IP Configuration Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.1.105 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1
How to obtain a default route
While you can't tell it from the output, we obtained both the default route and default gateway in our examples via Dynamic Host Configuration Protocol (DHCP). There are actually three ways to obtain a default route.
- Configure a static route.
- Receive a default route from another router through a routing protocol (not usually used on a PC).
- Receive a default route via DHCP.
For more information on the differences among the three, check out Cisco's Configuring a Gateway of Last Resort Using IP Commands documentation.
While you can use the ip default-network command to set a default route on a router, I recommend just creating a static route using the ip route command. Here's an example of configuring a default route on a router or switch:
Router(config)# ip route 0.0.0.0 0.0.0.0 18.104.22.168
Here's what this command says: For all traffic that doesn't go to one of the locally connected networks, forward it to the router at IP address 22.214.171.124. (Of course, the router also has to know how to get to that IP address, so make sure you specify one of your connected networks on one of the router's interfaces.)
How to distribute a default route with a routing protocol
Let's say you want to use your core router to tell all other routers that they should come through this core router if they have any network that they can't access. When it comes to configuring this, each routing protocol is different, so you may want to check Cisco documentation for some help.
For this example, let's use the Routing Information Protocol (RIP). First, we could check out Cisco's Configuring Routing Information Protocol documentation, which offers a couple of options.
In my opinion, our best option is to use the default-information originate command to send a default route to another router. Here's an example (which assumes we've already configured RIP):
Router(config)# router rip Router(config-router)# default-information originate
This sends the default route to all other RIP routers (as shown above in the first example).
How familiar are you with default routes? Do you use them on your routers and switches? How do you distribute default routes to your routers? Share your methods in this article's discussion.
Miss a column?
Check out the Cisco Routers and Switches Archive, and catch up on David Davis' most recent columns.
Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!
David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.