Today we are going to talk about default gateway and default routes. These two are vital when it comes to internetworking and external communication. A default gateway is a router that serves as the “exit door” into subnets that hosts are not currently in. Lets break it down, picture a topology with 10 PCs connected to a switch in the same subnet. PC1 can talk to PC2 and PC2 can talk to PC3. Now what if PC1 wants to browse the internet and communicate with a web server 1000 miles away. How would it get there? There’s no way a layer 2 switch can provide a service like that, so the default gateway would have to be a router that the PC is connected to. The router must have an interface connected to the subnet that the PCs are on. If the router doesn’t have an interface in the same subnet as the PCs, the PCs will not be able to send traffic to it in the first place. A packet must come from the PC to an interface on the router that belongs to the same subnet. From there the router which has an WAN connection will forward any packets destined for external networks to the next hop. With a default gateway hosts on a subnet are able to freely communicate with other subnets no matter the location.
When traffic from the PCs comes to the router, the router then looks at the routing table. It inspects the destination IP and compares it to routes on the table to see if any match. If there’s a route with a destination network that includes the destination IP, the router will forward that packet per route instruction to the next hop address or outgoing interface. But what if there is no route on the table? That is where default routes come in. Default routes are a route that represents every single IP address regardless of network size or prefix length. It is represented as 0.0.0.0/0 for IPv4 and ::/0 for IPv6. This will cover IP addresses like 30.0.0.1 or 203.0.0.1, it truly covers every IP address. So when a route reaches the default gateway and there is no match in the routing table, the router will forward it to the next hop address or outgoing interface on the default route. But where does the packet go? The most common set ups are routers that have LAN interfaces where the local devices are, but also a WAN interface where the router has a connection to an ISP router. The next hop from the router will be to the ISP router and from that router the packet will continue on its path until it finally reaches the destination host. A default route is labeled “Gateway of Last Resort” on the routing table. This allows routing tables to be concise and prevents a routing table from being too long while ensuring that the host has access to unknown external networks.
Leave a Reply