ip route on Linux: Default Gateway, Static Routes and ip addr

ip route linux - custom-iproute-featured.png

ip route on Linux (from iproute2) replaced many route and ifconfig workflows. Searches spike when a VM loses internet after a NIC change or when you add a static route to a VPN subnet.

See: nmcli & netplan,
ss,
ping & traceroute.

Show routing table

ip route show (or ip r) lists defaults and connected subnets.

bashshow
ip -4 route show
ip route get 8.8.8.8
ip route
default

Addresses on NICs

ip addr shows CIDR addresses — link state UP/DOWN matters for routing.

bashaddr
ip -br addr
ip addr
CIDR

Temporary static route

Routes added with ip route add vanish on reboot unless your network manager persists them.

bashstatic
sudo ip route add 10.20.0.0/16 via 10.0.0.1 dev eth0
via
static

Make routes persistent

Use Netplan, NetworkManager keyfiles, or /etc/sysconfig/network-scripts on legacy RHEL — not manual ip alone.

Tipip route get IP shows which interface and gateway the kernel would use — great for asymmetric routing bugs.
netplan
persist

Quick Reference

  • Table: ip route show
  • Test path: ip route get 8.8.8.8
  • Persist via Netplan/nmcli, not reboot-lost ip alone

Related tutorials

Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.