Shared server guidance · Question & answer

How do I check the default gateway and route used by my Linux server?

The routing table determines which interface and gateway carry traffic to a destination. Listing a default route is useful, but ip route get is more specific because it shows the route the kernel would select for the address you ask about. Neither command transmits application traffic or changes a route.

BeginnerLinux dedicated servers and VPSs with iproute2
Go to the answer

Before you start

  • The real destination IP involved in the problem.

Instructions

1. Read the current routes

Inspect both address families when the server is expected to support them. A default route may use a gateway, a point-to-point interface or a provider-specific routed design; use the supplied network specification as the reference.

Remote Linux shell
ip -4 route show
ip -6 route show

These commands list the IPv4 and IPv6 routing tables without modifying them.

2. Check the route to one destination

Replace the documentation address with the actual destination. Read the dev and src values as well as via, when present. A correct-looking route still needs a separate connectivity test.

Remote Linux shell
ip route get 198.51.100.20

Shows the selected outgoing interface and source address for this destination.

3. Account for policy routing

Multiple interfaces, VPNs or management networks may select different tables. Collect policy rules if the selected path differs from the ordinary default route.

Remote Linux shell
ip rule show

Lists policy-routing rules in priority order.

Check the result

  • The selected source and interface match the intended network.
  • A subsequent test to the real service succeeds using the same destination and address family.

Troubleshooting

Network is unreachable
Check whether the address family has a usable address and route. Do not insert a guessed default gateway over the active SSH connection.

Official references

Use the documentation for your installed version when a flag, service name or platform feature differs.