How to Migrate cPanel Accounts Between Servers Using WHM Transfer Tool (Zero-Downtime Guide) Moving live…
Linux Routing Table Troubleshooting: Fix Gateway Issues

Linux Routing Table Troubleshooting: Fix Default Gateway and Network Issues
Linux routing table troubleshooting helps identify why a Linux server cannot reach another network, access the internet, or communicate with remote systems. Even when a network interface has a valid IP address, an incorrect routing table or missing default gateway can prevent traffic from reaching its destination.
These problems commonly occur after changing network settings, configuring multiple network interfaces, modifying static routes, migrating a VPS, or applying firewall and VPN configurations. Symptoms include failed outbound connections, unreachable gateways, intermittent connectivity, and SSH sessions that suddenly stop responding.
In this guide, you will learn how to inspect the Linux routing table with ip route, identify an incorrect default gateway, diagnose routing conflicts, test network connectivity, and apply safe fixes on production Linux servers.
What Is a Linux Routing Table?
A routing table tells the Linux kernel where to send network packets. When an application connects to an IP address, the kernel checks the available routes and selects the appropriate path.
A route typically contains a destination network, a gateway when required, an outgoing interface, and sometimes a preferred source address or routing metric.
For example, a Linux server might have these routes:
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10
The first route is the default route. It sends traffic to destinations that do not match a more specific route through gateway 192.168.1.1 using eth0.
The second route represents the directly connected 192.168.1.0/24 network.
A routing problem can occur when a route is missing, points to the wrong gateway, uses an unexpected interface, or conflicts with another route.
Step 1: Check the Current Linux Routing Table
Start by displaying the server’s IPv4 routing table:
ip route
For a more detailed view, run:
ip -4 route show
To inspect IPv6 routes:
ip -6 route show
A typical IPv4 routing table may look like this:
default via 192.168.1.1 dev eth0 proto dhcp metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10
Here is how to interpret the output:
default: The route used when no more specific matching route exists.via 192.168.1.1: The gateway used to reach destinations through that route.dev eth0: The outgoing network interface.proto dhcp: The route was installed through a DHCP-related mechanism.metric 100: The route’s priority metric; a lower metric is generally preferred among otherwise comparable routes.src 192.168.1.10: The preferred source address for traffic using the route.
If the routing table does not contain a default route, the server may still communicate with directly connected networks but fail to reach external destinations.
However, not every server needs a conventional default route. Some environments intentionally use policy routing, dedicated routes, or controlled network paths. Check your network design before making changes.
Step 2: Check Network Interfaces and IP Addresses
Before modifying routes, confirm that the server’s interfaces are active and have the expected IP addresses.
Run:
ip address show
For a shorter interface overview:
ip -br address
Example output:
lo UNKNOWN 127.0.0.1/8
eth0 UP 192.168.1.10/24
Check the interface state and verify that the address matches the network configuration supplied by your hosting provider or network administrator.
Next, inspect the available interfaces:
ip link show
If the expected interface is down, investigate why before changing the routing table.
You can also check the interface’s assigned addresses and status individually:
ip address show dev eth0
Replace eth0 with the actual interface name. Modern Linux systems may use names such as ens3, ens18, or enp1s0.
An incorrect IP address or subnet mask can make a valid-looking route unusable. For example, configuring the wrong subnet may cause Linux to treat a remote destination as directly connected when it should be reached through a gateway.
Step 3: Diagnose a Missing Default Gateway
A missing default gateway is one of the most common causes of outbound connectivity problems.
Check the current default route:
ip route show default
If the command returns no output, there may be no IPv4 default route in the main routing table.
Check IPv6 separately:
ip -6 route show default
A missing default route can prevent connections to destinations outside the server’s directly connected networks. Nevertheless, policy routing or other routing tables may still provide a valid path.
Test the gateway
Suppose the expected gateway is 192.168.1.1. Test whether it responds:
ping -c 4 192.168.1.1
A failed ping does not automatically mean the gateway is unavailable, because ICMP traffic may be filtered. Check the local neighbor table as well:
ip neigh show
For a directly connected IPv4 gateway, the neighbor table may show a link-layer address or an incomplete/failed neighbor resolution state.
If the gateway is unreachable, check the interface, subnet, VLAN, virtual network, and provider-side network configuration before adding a new default route.
Add a temporary default route
Only if you have confirmed the correct gateway and interface, you can add a default route temporarily:
sudo ip route add default via 192.168.1.1 dev eth0
Replace the example gateway and interface with your actual values.
If a default route already exists, this command may fail with a route-exists error. Do not immediately delete the existing route; inspect its gateway, metric, and purpose first.
Important: Routes added using the ip route command are generally runtime changes. They may disappear after a reboot or network reconnection. Persistent configuration must be updated using the network manager responsible for the interface.
On a remote production server, make routing changes only when you have a recovery method, such as a provider console or out-of-band access.
Step 4: Troubleshoot an Incorrect Default Gateway
A default route can exist but still point to the wrong gateway.
Inspect it with:
ip route show default
For example, you might see:
default via 192.168.2.1 dev eth0
If the interface actually belongs to the 192.168.1.0/24 network and the expected gateway is 192.168.1.1, the route may be incorrect. However, the correct gateway must be verified from the actual network configuration rather than inferred from an example.
To determine how Linux will route traffic to a public IP address, run:
ip route get 1.1.1.1
Example output:
1.1.1.1 via 192.168.1.1 dev eth0 src 192.168.1.10
This indicates that Linux selected gateway 192.168.1.1, interface eth0, and source address 192.168.1.10 for this lookup.
If the selected gateway or interface is unexpected, investigate the matching routes, route metrics, routing rules, and source address selection.
Do not assume that a public DNS address must be reachable through a particular gateway. The route depends on the server’s network design.
Step 5: Identify Conflicting Routes and Incorrect Metrics
Servers with multiple network interfaces may have more than one default route. Linux can select between comparable routes using metrics, but routing behavior can also depend on policy rules and separate routing tables.
Display the main IPv4 routing table:
ip -4 route show table main
Inspect routing policy rules:
ip rule show
Inspect all available routing tables:
ip route show table all
You may discover that:
- Two interfaces have default routes with different metrics.
- A more specific route directs traffic through an unexpected gateway.
- A VPN has introduced additional routes.
- Policy routing sends traffic from a particular source address through a separate table.
- A manually configured route conflicts with routes installed by DHCP or a network manager.
Understand route metrics
Consider this example:
default via 192.168.1.1 dev eth0 metric 100
default via 192.168.2.1 dev eth1 metric 200
For otherwise comparable routes, the lower metric generally makes the first route preferable. However, Linux routing decisions are more complex when policy rules, different destination prefixes, source-based routing, or other attributes are involved.
Before changing a metric, determine whether both interfaces are intended to carry outbound traffic. Multi-homed servers may require carefully designed routing rather than a single default route.
Step 6: Test Connectivity Layer by Layer
A useful Linux routing table troubleshooting workflow tests each part of the network path separately.
1. Test the local IP configuration
ip -br address
ip route
Confirm that the expected interface, IP address, and route are present.
2. Test the gateway
ping -c 4 192.168.1.1
Use the actual gateway address. If ICMP is blocked, inspect neighbor resolution and interface configuration instead of treating ping failure as conclusive evidence.
3. Test an external IP address
ping -c 4 1.1.1.1
If this works but domain lookups fail, investigate DNS separately. If it fails, routing, filtering, upstream connectivity, or ICMP restrictions may be involved.
4. Test the selected route
ip route get 1.1.1.1
Confirm the selected gateway, interface, and source IP address.
5. Trace the network path
If traceroute is installed:
traceroute 1.1.1.1
Alternatively, use the tracepath utility if available:
tracepath 1.1.1.1
These tools can help identify where responses stop along the path. However, intermediate routers may filter probe packets, so missing hops do not necessarily indicate a routing failure.
6. Test the actual application port
For an application using HTTPS:
curl -I --connect-timeout 10 https://example.com
For a known TCP service, you can use nc if installed:
nc -vz 203.0.113.10 443
Replace the example IP address and port with the actual destination. Successful routing does not guarantee that the remote service is listening or that its firewall permits the connection.
Step 7: Fix Routing Problems on Multi-NIC Servers
Linux servers may have multiple network interfaces for public access, private networking, storage, VPN connectivity, or management traffic.
Inspect the interfaces:
ip -br address
Review the routing table:
ip route
Then check the route selected for a particular destination:
ip route get 203.0.113.10
Use the actual destination you are troubleshooting.
A common issue occurs when a server receives traffic through one interface but sends replies through another. Depending on the network design and security controls, this asymmetric routing can break connections.
If a server has separate public and private interfaces, confirm that:
- The intended default gateway is configured.
- Private subnets have the correct routes.
- Each source IP address uses the appropriate outbound path.
- Firewall and reverse-path filtering settings match the network design.
- Provider-side routing and security rules allow the expected traffic.
Avoid adding multiple default routes simply because the server has multiple interfaces. If each interface serves a different purpose, explicit routes or policy routing may be required.
Step 8: Troubleshoot SSH Connectivity After a Route Change
Incorrect routing can interrupt SSH access to a remote Linux server. A server may still be running even though new SSH connections fail.
If you still have access, inspect the route to the client or management network:
ip route get CLIENT_IP
Replace CLIENT_IP with the IP address of the computer or network connecting to the server.
This helps identify the selected outbound interface and gateway for return traffic. If the return route is wrong, the SSH connection may fail even when inbound packets reach the server.
If SSH access has already been lost, use your VPS provider’s web console, serial console, rescue environment, or another approved recovery method.
Before changing a route remotely, consider arranging a rollback mechanism or a maintenance window. A route change can terminate the session you need to reverse it.
Step 9: Make Routing Changes Persistent
A route added with ip route add usually affects the running system only. To keep it after reboot, update the configuration system managing the interface.
The correct method depends on the Linux distribution and network stack.
Ubuntu with Netplan
Check the available Netplan files:
ls -l /etc/netplan/
Review the active configuration before editing it:
sudo netplan get
A simplified example might look like this:
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.1.10/24
routes:
- to: default
via: 192.168.1.1
This is only an example. Use the actual interface, address, gateway, and other required settings from your environment. Do not replace an existing Netplan configuration with this snippet without preserving its other settings.
Validate the configuration:
sudo netplan generate
For remote systems, consider using Netplan’s interactive rollback mechanism:
sudo netplan try
Confirm the changes only after verifying connectivity. Exact behavior and support can vary with the installed Netplan version and configuration.
NetworkManager-based systems
List active connections:
nmcli connection show --active
Inspect a connection’s settings:
nmcli connection show "YOUR_CONNECTION"
Replace YOUR_CONNECTION with the correct connection name.
Persistent route changes should be made through the appropriate NetworkManager connection profile. Be cautious when bringing a modified connection up over SSH because network reconnection may interrupt remote access.
Other network managers
Some systems use systemd-networkd, traditional network scripts, cloud-init, or provider-specific networking tools. Inspect the existing configuration and use the system that owns the interface. Avoid editing multiple configuration systems for the same interface, as they can overwrite each other’s settings.
Step 10: Capture Packets to Diagnose Routing Failures
When the routing table looks correct but connections still fail, packet capture can help determine whether traffic leaves the server and whether replies return.
If tcpdump is installed, run:
sudo tcpdump -ni any host 1.1.1.1
Replace the example destination with the IP address you are troubleshooting.
For a more targeted capture on an interface:
sudo tcpdump -ni eth0 host 1.1.1.1
Look for outbound packets and corresponding responses. If requests leave the server but replies never return, investigate the remote network, upstream routing, filtering, or return path. If packets never appear on the expected interface, recheck the route selection and local rules.
Packet captures may contain sensitive network metadata. Limit the capture to the required hosts and duration, and handle any resulting files securely.
Common Linux Routing Troubleshooting Commands
| Command | Purpose |
|---|---|
ip route |
Display the main IPv4 routing table |
ip -6 route |
Inspect IPv6 routes |
ip route show default |
Check the default route |
ip route get DESTINATION |
Determine the selected route |
ip address show |
Inspect IP addresses and interfaces |
ip neigh show |
Check neighbor discovery entries |
ip rule show |
Inspect policy routing rules |
ip route show table all |
Display routes across routing tables |
traceroute DESTINATION |
Trace a network path |
tcpdump -ni any host DESTINATION |
Inspect matching packets |
Replace placeholders such as DESTINATION with the appropriate IP address or hostname, depending on the command.
Frequently Asked Questions
How do I check the default gateway in Linux?
Run ip route show default to display the IPv4 default route. For IPv6, use ip -6 route show default. If no default route appears, check whether the system uses another routing table or policy routing before changing the configuration.
Why does my Linux server have no internet connection even though its IP address is correct?
A correct IP address does not guarantee internet connectivity. The server may have a missing default route, an incorrect gateway, a broken upstream connection, firewall restrictions, or a routing policy that selects the wrong interface.
How can I fix an incorrect Linux route?
First, inspect the routing table with ip route and determine the expected gateway and interface. A temporary route can be added or changed with the ip route command, but persistent changes must be made through the system’s network manager. Verify the configuration before removing existing routes.
Do Linux routing table changes survive a reboot?
Routes added manually with ip route are generally runtime changes and may disappear after reboot or network reconnection. Configure persistent routes using Netplan, NetworkManager, systemd-networkd, or whichever network management system controls the interface.
Why does SSH stop working after changing the default gateway?
The server may send response packets through the wrong gateway or interface. This can break return traffic and interrupt remote access. Check the route to the connecting client’s IP address and use a provider console if SSH access is lost.
Conclusion
Linux routing table troubleshooting starts with verifying the interface configuration, inspecting ip route, and checking the selected path with ip route get. From there, investigate missing gateways, incorrect routes, competing metrics, policy routing, and upstream connectivity.
Make changes carefully, especially on remote VPS instances. Test temporary changes first, update the correct network manager for persistence, and verify both outbound and return traffic before considering the issue resolved.
Need a reliable environment for your Linux workloads? Explore ServerNext VPS solutions or visit ServerNext for more information about available hosting options.
