What Is a Default Gateway?

A default gateway is the network device (usually a router) that your server sends traffic to when the destination is not on the local network. It is the exit point from your local network to the rest of the network or the internet.
How Default Gateways Work
When your server needs to communicate with another host, it checks whether the destination IP address is on the same subnet. If it is, the server sends the packet directly to the destination. If it is not, the server sends the packet to the default gateway.
The default gateway then examines the packet's destination address and forwards it toward the correct destination using its own routing table. This process continues through multiple routers until the packet reaches its destination.
Default Gateway on Linux
To view your current default gateway: ip route show default
This shows the default route, typically in the format: default via 10.0.0.1 dev eth0
To set a default gateway temporarily: sudo ip route add default via 10.0.0.1
For persistent configuration, edit the network configuration files (Netplan on Ubuntu, NetworkManager or ifcfg files on CentOS).
Troubleshooting Default Gateway Issues
If you cannot reach external hosts but local connectivity works: 1. Check if the default route exists: ip route show default 2. Test connectivity to the gateway: ping gateway-ip 3. Check if the gateway interface is up: ip link show 4. Verify the gateway IP address is correct for your network
A missing or incorrect default gateway is a common cause of network connectivity problems after server provisioning or network reconfiguration.
Multiple Default Routes
In configurations with multiple network interfaces, you may have multiple default routes with different metrics. The route with the lowest metric is preferred. This is used in multi-homed server configurations.
Cloud Server Default Gateways
Cloud servers are automatically configured with a default gateway during provisioning. The gateway IP is typically the first usable address in the subnet (for example, 10.0.0.1 in a 10.0.0.0/24 network).
If you modify network settings on a cloud server, be careful not to remove the default gateway, as this will break internet connectivity. ## Key Takeaways
- The default gateway is the router that forwards traffic from your server to destinations outside the local subnet
- On Linux, check your default gateway with ip route show default; a missing or incorrect gateway is a common cause of connectivity failures
- Cloud servers are provisioned with a default gateway automatically — avoid removing it when editing network configuration manually
- Multi-homed servers may have multiple default routes with different metrics; the lowest-metric route takes precedence