Default Gateway
A default gateway is the door out of your local network. When your computer needs to reach something that is not on the same network (like a website on the internet), it sends the request to the gateway, which is usually your router. The router then figures out where to send it next. Without a gateway, your device can only talk to other devices on the same local network.
The default gateway is the IP address of the next-hop router that a host uses when no more specific route exists in its routing table for a given destination. It corresponds to the route entry 0.0.0.0/0 (IPv4) or ::/0 (IPv6), which matches all destinations not covered by more specific routes.
When a host needs to send a packet:
- It compares the destination IP against its own subnet (using the subnet mask)
- If the destination is on the same subnet, it sends the frame directly to the destination’s MAC address (resolved via ARP)
- If the destination is on a different subnet, it sends the frame to the gateway’s MAC address, with the original destination IP preserved in the packet header
- The gateway router then performs a routing table lookup and forwards the packet toward the destination
The default gateway is typically:
- Assigned via DHCP (Option 3: Router)
- Configured statically on servers and infrastructure devices
- The first or last usable IP in a subnet by convention (e.g., .1 or .254)
In environments with multiple gateways, protocols like VRRP (RFC 5798), HSRP (Cisco proprietary), or GLBP provide gateway redundancy through a virtual IP that floats between physical routers.
The gateway router typically performs NAT (Network Address Translation) when forwarding traffic from a private network (RFC 1918 addresses) to the public internet, translating the source IP to a public address.
Viewing and setting the default gateway
# View current default gateway (Linux)
$ ip route show default
default via 192.168.1.1 dev eth0 proto dhcp metric 100
# View on macOS
$ netstat -rn | grep default
default 192.168.1.1 UGScg en0
# View on Windows
> ipconfig
Default Gateway . . . . . . . . . : 192.168.1.1
# Add a static default route (Linux)
$ sudo ip route add default via 192.168.1.1 dev eth0 The default gateway is one of the three essential pieces of information every networked device needs (alongside an IP address and a subnet mask). When users report “I have an IP but can’t reach the internet,” the first check is whether the default gateway is set and reachable. In data centers, servers often have multiple gateways for different traffic paths: one for public traffic, one for management, and one for storage. Cloud VPCs use implicit gateways (the first IP in each subnet, e.g., 10.0.0.1 in a 10.0.0.0/24), and route tables attached to subnets control where traffic flows. Misconfigured gateways cause asymmetric routing, where traffic leaves via one path but returns via another, which breaks stateful firewalls and load balancers.