Linux: How to Find the Default Gateway
To check the default gateway in Linux, run ip -4 route show default. The address after via in the output is the next hop gateway for that default route, and IPv6 can be checked separately with ip -6 route show default.
What is a Default Gateway?
A default gateway is the next hop used to forward packets when there is no more specific route matching the destination. In home or small networks, it is often a router address, but in servers, virtual machines, or VPN environments, it can be another device or virtual interface. The gateway address and your computer's IP address are different values.
The following commands query routing information and does not change network settings. It can usually be run without administrative privileges. Example addresses and interface names are for illustration, and actual results in your environment may differ.
Checking the IPv4 Default Route
Run the following command in the terminal.
ip -4 route show default
The following is an example of possible output.
default via 192.0.2.1 dev enp1s0 proto dhcp metric 100
default: Indicates the default route.via 192.0.2.1: The next hop address to forward packets.dev enp1s0: The network interface used for this route.proto dhcp: In this example, it indicates a route obtained via DHCP. Other values such as manual settings are also possible.metric 100: The value used for route priority. When comparing routes with the same conditions, generally the smaller value takes precedence.
There may be multiple default routes. In cases of VPN or multiple interfaces, you should also check which destination the traffic is for and the policy routing. You can check the meaning of routes and metrics in the ip-route manual.
Checking the IPv6 default route
IPv6 routes are viewed separately from IPv4 routes.
ip -6 route show default
For example, it may be displayed as follows.
default via fe80::1 dev enp1s0 proto ra metric 100
In this example, fe80::1 is a link-local address, so it is interpreted together with dev enp1s0 on the same interface. If IPv6 is not used or a default route is not set, there may be no output. The gateways for IPv4 and IPv6 do not necessarily have to be the same or exist together.
Check the route to use for a specific destination
Just because a default route is displayed does not mean all destinations use that route. If there is a more specific route or policy routing, the selected route may differ. The following command checks the route chosen by the kernel for a sample destination.
ip route get 198.51.100.25
If via appears in the result, it indicates the next hop, and dev indicates the interface to use. Destinations that are directly connected may not have via. This check does not actually send packets, so it is not a test to confirm connection success. Replace the destination address with the actual address you want to check.
In an environment using policy routing, ip route show displays the main table by default, whereas ip route get performs a route lookup using applicable rules. Use the following command to review the rules and the entire table, and perform the lookup considering actual traffic conditions such as the source if necessary.
ip rule show
ip route show table all
When there is no output or access is not possible
- No default route: Check the interface connection status and address with
ip addr show, and verify DHCP or network administrator settings. In systems that require only specific routes, a configuration without a default route may be intentional. - Route exists but communication fails: Just because a gateway address appears does not guarantee internet or destination connectivity. Check interfaces, firewalls, next hops, and DNS sequentially.
- Multiple default routes: Check interfaces, metrics, policy rules, and
ip route getresults together. VPNs or containers may use separate routes.
Sending ping to the gateway can help check reachability, but in networks where responses are blocked, failure does not necessarily mean a connectivity issue. Before changing the routing settings of a remote server, verify the possibility of disconnection and recovery paths.
Check with the existing route command
You can also use route -n on older systems. Check the Gateway and Iface of the row where Destination is 0.0.0.0 in the output. -n displays a numeric address instead of a name.
route -n
If route is not installed, try using the already provided ip route before adding a new package. The network tools and output of the distribution may vary depending on the version.




