| 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.el10NetworkManager 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:
ip -4 route show defaultOn the lab host the uplink NIC owns the internet path:
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 116Read the fields together:
via 10.0.2.2— next-hop gateway routerdev enp0s3— outbound interfaceproto dhcp— NetworkManager or DHCP installed this routemetric 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:
ip -4 routedefault 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 117The 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:
ip route get 8.8.8.88.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
cachevia 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:
ip route get 192.168.56.220192.168.56.220 dev enp0s8 src 192.168.56.116 uid 0
cacheNo 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:
sudo ip route add default via 192.168.56.99 dev enp0s8 metric 200List both defaults:
ip -4 route show defaultdefault 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 200Ask the kernel which path it still picks for the internet:
ip route get 8.8.8.88.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
cacheMetric 116 beats 200, so traffic stays on enp0s3. Remove the lab default before you continue:
sudo ip route del default via 192.168.56.99 dev enp0s8 metric 200When 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:
sudo ip route add default via 192.168.56.99 dev enp0s8 metric 50Confirm the kernel switched paths:
ip route get 8.8.8.88.8.8.8 via 192.168.56.99 dev enp0s8 src 192.168.56.116 uid 0
cacheRemote 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:
sudo ip route del default via 192.168.56.99 dev enp0s8 metric 50If the table had no correct default left, add the known-good gateway on the uplink:
sudo ip route replace default via 10.0.2.2 dev enp0s3ip route replace adds or updates the route in one step. Re-check selection:
ip route get 8.8.8.88.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
cacheManual 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:
ip -4 route show defaultTwo 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:
nmcli dev show enp0s3 | grep IP4.GATEWAYIP4.GATEWAY: 10.0.2.2On a secondary NIC that should never carry internet traffic:
nmcli dev show enp0s8 | grep IP4.GATEWAYIP4.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:
sudo nmcli connection modify enp0s8 ipv4.never-default yesReactivate so the setting applies:
sudo nmcli connection up enp0s8ipv4.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:
nmcli connection show enp0s3 | grep -E 'ipv4\.(method|gateway|route-metric)'ipv4.method: auto
ipv4.gateway: --
ipv4.route-metric: -1ipv4.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:
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:
sudo nmcli connection up enp0s3The 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:
sudo nmcli connection modify enp0s3 ipv4.route-metric 100On 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.
ip -4 route show defaultdefault via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 116Ask the kernel which path it would use for an off-subnet address:
ip route get 8.8.8.88.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
cacheMatching 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:
ip route get 192.168.56.220192.168.56.220 dev enp0s8 src 192.168.56.116 uid 0
cacheping 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
- ip-route(8) — Linux manual page
- NetworkManager nm-settings-nmcli(5)
- Red Hat — Configuring IP networking
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.

