Troubleshoot Default Routes in Linux

Tested on RHEL 10.2 (Coughlan) — vm1.lab.example (192.168.56.116); uplink enp0s3 (10.0.2.15, gateway 10.0.2.2); lab LAN enp0s8 (192.168.56.0/24)
Package iproute 6.17.0-2.el10
NetworkManager 1.56.0-1.el10
Applies to Ubuntu, Debian, Kali Linux, Linux Mint, Pop!_OS, Raspberry Pi OS, elementary OS, Zorin OS, Parrot OS, MX Linux, RHEL, Rocky Linux, AlmaLinux, Oracle Linux, CentOS Stream, Fedora, Arch Linux
Privilege Normal user for read-only ip route and nmcli; sudo or root to add, delete, or change routes and connection profiles
Scope Diagnose and fix Linux default route and default gateway problems — missing routes, wrong gateway, multiple defaults, and route metrics — using ip route, ip route get, and NetworkManager. Does not cover full ip route command reference or policy routing tables.
Related guides Network is unreachable
ip route command
nmcli command examples
Linux slow network troubleshooting
Destination host unreachable

Traffic to the internet leaves through one default gateway — but the routing table can list the wrong via address, two competing default lines, or no default at all. Symptoms range from network is unreachable on every remote IP to packets exiting the slow lab NIC while the uplink sits idle.

The steps below read the installed default, ask the kernel which route it would pick, use metrics to explain multiple gateways, fix bad entries, and persist the correct profile with NetworkManager.


Check the current default route

The default route is the catch-all for destinations that do not match a more specific prefix. List only those lines:

bash
ip -4 route show default

On the lab host the uplink NIC owns the internet path:

output
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 116

Read the fields together:

  • via 10.0.2.2 — next-hop gateway router
  • dev enp0s3 — outbound interface
  • proto dhcp — NetworkManager or DHCP installed this route
  • metric 116 — preference when more than one default exists

No output means off-subnet traffic has no path until you add a default — see network is unreachable when ping to remote IPs fails with that message.

List the full IPv4 table when you need connected subnets beside the default:

bash
ip -4 route
output
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 116
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 116
192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.116 metric 117

The 192.168.56.0/24 line is a direct link route — LAN peers use enp0s8 without touching the default gateway.


Check which route Linux actually selects

The routing table can list several defaults; ip route get shows the one the kernel chooses for a specific destination:

bash
ip route get 8.8.8.8
output
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
    cache

via and dev here are authoritative — this is the path ping, curl, and ssh use for that address. Compare against a peer on the local subnet:

bash
ip route get 192.168.56.220
output
192.168.56.220 dev enp0s8 src 192.168.56.116 uid 0
    cache

No via line means the kernel uses the connected route on enp0s8, not the default gateway. When ip route get prints RTNETLINK answers: Network is unreachable, there is no matching route — add or fix the default before you chase DNS or firewalls.


Understand route metrics

Metric is a cost or preference value on a route. For two equally specific routes — including two default lines — the kernel prefers the lower metric.

The lab uplink uses metric 116 and the LAN interface link route uses 117. DHCP and NetworkManager often assign close metrics per interface; manual routes need an explicit metric when you add them.

Add a second default on the lab NIC with a high metric so it does not steal traffic:

bash
sudo ip route add default via 192.168.56.99 dev enp0s8 metric 200

List both defaults:

bash
ip -4 route show default
output
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 116
default via 192.168.56.99 dev enp0s8 metric 200

Ask the kernel which path it still picks for the internet:

bash
ip route get 8.8.8.8
output
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
    cache

Metric 116 beats 200, so traffic stays on enp0s3. Remove the lab default before you continue:

bash
sudo ip route del default via 192.168.56.99 dev enp0s8 metric 200

When the wrong default has the lower metric, ip route get follows it — covered in the next section.


Fix an incorrect default route

A default pointing at a dead gateway or the wrong interface sends every off-subnet packet into a black hole. On the lab host I added a bogus default with metric 50 — lower than the real uplink — to reproduce that mistake:

bash
sudo ip route add default via 192.168.56.99 dev enp0s8 metric 50

Confirm the kernel switched paths:

bash
ip route get 8.8.8.8
output
8.8.8.8 via 192.168.56.99 dev enp0s8 src 192.168.56.116 uid 0
    cache

Remote traffic now leaves enp0s8 toward a gateway that does not exist on the LAN. Delete the bad entry with the same via, dev, and metric you used when adding it:

bash
sudo ip route del default via 192.168.56.99 dev enp0s8 metric 50

If the table had no correct default left, add the known-good gateway on the uplink:

bash
sudo ip route replace default via 10.0.2.2 dev enp0s3

ip route replace adds or updates the route in one step. Re-check selection:

bash
ip route get 8.8.8.8
output
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
    cache

Manual ip route changes last until reboot or until NetworkManager reapplies the profile — use them to prove the gateway, then persist through nmcli below.


Troubleshoot multiple default routes

Servers with two NICs, laptops on Wi-Fi and Ethernet, or VPN clients often accumulate more than one default via line. List them all:

bash
ip -4 route show default

Two lines are not automatically wrong — compare metrics and ip route get for the destinations you care about. The broken pattern is a low-metric default on a LAN-only interface.

Check what NetworkManager learned on each device:

bash
nmcli dev show enp0s3 | grep IP4.GATEWAY
output
IP4.GATEWAY:                            10.0.2.2

On a secondary NIC that should never carry internet traffic:

bash
nmcli dev show enp0s8 | grep IP4.GATEWAY
output
IP4.GATEWAY:                            --

-- on enp0s8 is expected for an isolated lab segment — the uplink profile should own the only default. If DHCP on a secondary NIC installs an unwanted default, block it on that connection profile:

bash
sudo nmcli connection modify enp0s8 ipv4.never-default yes

Reactivate so the setting applies:

bash
sudo nmcli connection up enp0s8

ipv4.never-default yes stops NetworkManager from installing a default route from that profile while leaving LAN addresses intact. Remove stray manual defaults with ip route del and verify with ip route get before you close the change ticket.


Make the route persistent

ip route add and ip route del are lost on reboot unless something in your network stack reinstalls them. On NetworkManager-managed hosts, the connection profile owns the gateway.

Inspect the uplink profile:

bash
nmcli connection show enp0s3 | grep -E 'ipv4\.(method|gateway|route-metric)'
output
ipv4.method:                            auto
ipv4.gateway:                           --
ipv4.route-metric:                      -1

ipv4.gateway shows -- because DHCP supplies the gateway at runtime — the live value still appears in ip route show default and nmcli dev show. For a static uplink, set address and gateway on the profile:

bash
sudo nmcli connection modify enp0s3 ipv4.method manual ipv4.addresses '10.0.2.15/24' ipv4.gateway '10.0.2.2' ipv4.dns '8.8.8.8'

Apply the profile:

bash
sudo nmcli connection up enp0s3

The gateway must sit on a subnet connected to enp0s3 — a via address outside the interface prefix leaves you with the same unreachable errors as a wrong manual route.

Prefer the lab NIC for outbound traffic only when you intend it — lower the metric on that profile, not the uplink:

bash
sudo nmcli connection modify enp0s3 ipv4.route-metric 100

On Debian and Ubuntu with Netplan, put gateway4 or routes: [{ to: default, via: … }] in the correct YAML file and apply with netplan apply. After edits on Ubuntu desktops, see refresh network on Ubuntu.


Verify route selection

After every change, confirm the kernel still picks the gateway you expect — do not rely on the routing table alone when multiple defaults exist.

bash
ip -4 route show default
output
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 116

Ask the kernel which path it would use for an off-subnet address:

bash
ip route get 8.8.8.8
output
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
    cache

Matching via and dev on both commands means off-subnet traffic uses the uplink. Test a LAN peer to confirm local traffic does not hairpin through the default:

bash
ip route get 192.168.56.220
output
192.168.56.220 dev enp0s8 src 192.168.56.116 uid 0
    cache

ping or curl to a remote IP can still fail when ICMP is filtered upstream even though routing is correct — pair route checks with test port connectivity on the TCP port your application uses. If the gateway is right but transfers are slow, continue with Linux slow network troubleshooting.


Troubleshooting

Symptom Likely cause Fix
ip route show default is empty DHCP failure or deleted default nmcli connection up UPLINK; add ip route replace default via GW dev IF
ip route get uses wrong dev Lower metric on wrong interface Delete bad default; set ipv4.never-default yes on secondary profile
Two defaults, traffic OK Higher metric backup route Remove unused default or raise its metric if it causes confusion
Gateway on wrong subnet Manual typo in via address Gateway must be reachable on the dev interface subnet
Route fix lost after reboot Only ip route was used Set ipv4.gateway or DHCP on NM profile; netplan on Ubuntu
LAN works, internet unreachable Missing or wrong default only Restore default on uplink; check ip route get not just link routes
VPN sends all traffic wrong interface VPN installs low-metric default Adjust VPN split-tunnel or route metric per VPN client docs

References


Summary

Linux default route problems start with ip -4 route show default — the via, dev, and metric fields tell you what is installed. ip route get DESTINATION is the decisive check because it shows which default the kernel actually selects, which matters the moment you have more than one default via line.

Metrics break ties: lower wins among routes of the same specificity. A secondary NIC with a better metric steals internet traffic even when the uplink looks fine in nmcli. Delete bad entries with ip route del, restore with ip route replace, and block unwanted DHCP defaults using ipv4.never-default on secondary NetworkManager profiles.

Persistence belongs in the connection profile — ipv4.gateway and ipv4.method for static uplinks, DHCP on the interface that should own the default, or Netplan on Ubuntu. Verify with matching output from ip route show default and ip route get for both a remote IP and a LAN peer. When the default is missing entirely, work through network is unreachable; when the gateway answers but transfers stall, check destination host unreachable and link-level guides next.


Frequently Asked Questions

1. How do I check the default route on Linux?

Run ip -4 route show default or ip route show default. The line lists default via GATEWAY dev INTERFACE and often a metric. Use ip route get REMOTE_IP to confirm which default the kernel actually selects for outbound traffic.

2. What does route metric mean on Linux?

Metric is a preference number on a route. When several routes match, the kernel picks the one with the lowest metric. Two default routes can coexist; only the lowest-metric default is used unless policy routing overrides the table.

3. Why does my host have two default routes?

Multiple NICs with DHCP, a manual route left on a secondary interface, or a VPN client can each install default via lines. Check ip route show default and ip route get. Remove or raise the metric on defaults that should not carry internet traffic.

4. How do I delete a wrong default gateway?

Use sudo ip route del default via WRONG_GW dev INTERFACE, including metric if multiple defaults share the same gateway form. Then confirm with ip route get 8.8.8.8 and make the fix persistent through nmcli or your netplan config.

5. How do I make a default route persistent across reboot?

On NetworkManager systems set ipv4.gateway and ipv4.method on the uplink connection with nmcli connection modify, then nmcli connection up. For secondary NICs that must not steal the default, set ipv4.never-default yes on that profile.
Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, networking, and security, delivering robust and efficient solutions for diverse projects.

  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security
  • Cloud Computing
  • Kubernetes
  • Linux
  • Ansible (software)