In this article we will define and discuss Default and Static Routes.
We often see the incorrect implementation and understanding of ‘default routes’. The default route is a “gateway of last resort.” This special route tells computers or other routers to contact the defined next hop of the default router if they don’t have a more specific route.
Without a default route, a router would need all internet routing (think what that would do to your old Linksys router or home router!). Since the routers do not have this information, without a default route a router will drop a packet destined 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: Your PC has an IP address of 192.168.1.27 and a subnet mask of 255.255.255.0 or /24. Let’s say we want to talk to a server on the LAN, which has an IP address of 192.168.1.2. For this to work, we actually don’t need a default route or default gateway configured on the PC (they are in the same subnetwork).
However, as soon as we want to talk to any other device not on the 192.168.1.0/24 network, we’ll need to know where to go. This means we need either a static route that defines how you reach a given network, or we nee a 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 technically a router even though it may have a routing table; 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.
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:
Cell_P1# 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, FastEthernet0
S* 0.0.0.0/0 [254/0] via 192.168.1.1
We see in the last line that a static route (s) has been configured for any IP address – this makes it a default route.
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.27
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
There are three ways to obtain a default route.
1. Configure a static route.
2. Receive a default route from another router through a routing protocol (not usually used on a PC).
3. Receive a default route via DHCP.
You can use the ‘ip default-network’ command to set a default route on a router, we 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:
Cell_P1(config)# ip route 0.0.0.0 0.0.0.0 192.168.1.1
What the command says is that for all traffic that doesn’t go to one of the locally connected interfaces, forward it to the router at IP address 191.168.1.1. (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.)
Now, we want this route advertised to neighbor routers. Here is the example for RIP:
Cell_P1(config)# router rip
Cell_P1(config-router)# default-information originate
This sends the default route to all other RIP routers (as shown above in the first example). For other protocols, be sure to look at how this is implemented.
We can use a simple variation of this command to create a static route. The generic format is:
Router(config)# ip route [destination network] [mask] [gateway address]
The command above tells the router the following information: ‘if you want to send a packet to the following “destination network”, then send it to this “gateway address”’.
Let’s say that network 10.0.0.0/8 is on interface 1, and network 172.16.0.0/16 is on interface 2, and network 192.168.1.0/24 is on interface 3. We would then configure the following static routes:
Cell_P1(config)# ip route 10.0.0.0 255.0.0.0 10.0.0.1
Cell_P1(config)# ip route 172.16.0.0 255.255.0.0 172.16.0.1
Cell_P1(config)# ip route 192.168.1.0 255.255.255.0 192.168.1.1
I have assumed that the interfaces are the first address of those subnets.
Static routes can remove the need for dynamic routing protocols. The problem is, what if that network interface goes down? The network operator would have to react by changing the static configuration. That could take minutes or hours.
Short and sweet. We hope this helps with explaining Default Routes.