Default gateway

On this page 7

A default gateway is the router interface that receives every packet bound outside the local subnet when the host has no more specific route for it. In routing it is the practical form of the default route, written 0.0.0.0/0 in IPv4 and ::/0 in IPv6, and it is what lets an ordinary computer reach the Internet without knowing anything about the networks beyond its local link.

Every IP host makes the same first decision for each outgoing packet: is the destination on the local subnet or not. Local destinations are reached directly through ARP or Neighbor Discovery; everything else goes to the default gateway, which then consults its own routing table. A missing or wrong gateway is therefore one of the most common reasons why a device can reach local printers but not the Internet.

How a host uses its default gateway

When a host sends a packet, it compares the destination address with its own address and subnet mask. If both fall in the same prefix, the packet is delivered directly. Otherwise the host looks up its routing table, finds the default route, and resolves the MAC address of the gateway, not of the final destination. The Ethernet frame is addressed to the gateway’s MAC address while the IP header still carries the final destination address.

The router receives the frame, removes the layer 2 header, decrements the TTL or hop limit, looks up the destination in its routing table and forwards the packet toward the next hop. The table follows a single packet from a laptop to a remote server.

StepDeviceAction
1. Local or remote checkHostApplies the subnet mask to the destination
2. Route lookupHostSelects the default route
3. Address resolutionHostUses ARP or NDP to find the gateway MAC
4. Frame deliverySwitchForwards the frame to the gateway port
5. Forwarding decisionGateway routerLongest-prefix match in its routing table
6. Next hopGateway routerSends the packet toward the destination
Steps of a packet leaving a subnet

How hosts learn the default gateway

In IPv4, the gateway is usually delivered by DHCP option 3 (Router) together with the address, mask and DNS servers. IPv6 works differently: routers announce themselves in Router Advertisement messages, and hosts install the router’s link-local address as their default gateway, even when addresses come from DHCPv6. Servers and network devices often use a manually configured gateway for predictability.

MethodProtocol versionTypical use
DHCP option 3IPv4Client devices on most networks
Router AdvertisementIPv6All IPv6 hosts with SLAAC or DHCPv6
Static configurationIPv4 and IPv6Servers, printers, network equipment
PPP or tunnel negotiationIPv4 and IPv6Dial-up, VPN and mobile links
Ways a host obtains its default gateway

A gateway must be on the same subnet as the host. A configured gateway outside the host’s prefix cannot be reached by ARP, and most operating systems refuse it or report the network as unreachable.

The default gateway is a host-side view of the default route. Routers also carry default routes, often learned from BGP or OSPF or set as a static route toward an Internet provider, but the term default gateway usually refers to the address configured on end devices. The comparison separates these related ideas.

ConceptWhat it isRelation to the default gateway
Default routeRouting table entry for 0.0.0.0/0 or ::/0Points to the default gateway
Static routeManually configured routeA default route is often static
Routing tableList of prefixes and next hopsContains the default route as last resort
Gateway of last resortRouter term for its default routeSame idea on a router
Next hopImmediate router for one routeThe gateway is the next hop for unknown prefixes
Default gateway and neighboring terms

Because routing uses longest-prefix match, a more specific route always wins over the default route. A VPN client, for example, can add routes for company networks while leaving Internet traffic on the local gateway, which is known as split tunneling.

Gateway redundancy

Since hosts usually have a single default gateway, the router that holds it is a single point of failure. First-hop redundancy protocols solve this by letting two or more routers share a virtual IP address and virtual MAC address; if the active router fails, a standby takes over within seconds, and hosts never notice the change.

ProtocolStatusLoad sharingTypical failover
VRRPOpen IETF standardPer group onlyAbout 1 to 3 seconds by default
HSRPCisco proprietaryPer group onlyAbout 10 seconds by default, tunable
GLBPCisco proprietaryAcross several routersSimilar to HSRP
IPv6 Router AdvertisementsBuilt into IPv6Hosts may use several routersDepends on timers
First-hop redundancy protocols

Troubleshooting and common mistakes

Gateway problems show a recognizable pattern: local resources work, remote ones do not. The first checks are the host’s configured gateway, a ping to the gateway address and a traceroute, whose first hop should be the gateway.

  • Wrong subnet mask makes the host think a remote address is local, so it never uses the gateway.
  • Two default gateways on different interfaces cause unpredictable routing; use one default route and add specific routes for other networks.
  • A gateway that blocks ICMP may look unreachable to ping while still forwarding traffic correctly.
  • Rogue Router Advertisements or DHCP servers can redirect traffic through an attacker; RA guard and DHCP snooping prevent this.

Stripped to the essentials

Think of your home network as a small town. Sending a message to a neighbor is easy, because you know where they live. For anyone outside town, you simply hand the message to the post office at the edge of town, and it figures out the rest.

The default gateway is that post office. Your computer sends everything addressed outside the local network to it, usually your home router. If the computer has the wrong post office address, it can still talk to devices at home but cannot reach anything on the Internet.

Where it is applied

A warehouse office uses the subnet 192.168.20.0/24, with its router at 192.168.20.1 handed out by DHCP. One morning, ten handheld scanners can print labels on the local printer but cannot upload data to the cloud inventory system.

The technician checks one scanner and finds the gateway set to 192.168.2.1, a typing error in a static profile pushed the night before. Pings to the printer succeed, but a traceroute to the cloud service stops before the first hop. After the profile is corrected, the scanners send traffic to the right router, and uploads resume within minutes. To prevent a repeat, the office moves the scanners back to DHCP and adds a second router with VRRP, so the gateway address survives a hardware failure.