Manual routes alter how the kernel selects an outgoing interface and next hop. A mistake can disconnect the host or redirect sensitive traffic, so inspect the effective route, configuration owner, and recovery path before changing state.
Network Config · Lesson 2
route
Learn how to inspect, add, replace, delete, and safely verify Linux routes with ip.
Inspecting the Current Decision
Record relevant routes and ask the kernel how it currently reaches the destination:
$ ip -4 route show
$ ip route get 192.168.2.25
Also inspect policy rules and alternate tables when present. The route lookup is local evidence; it does not send traffic.
Why run ip route get DESTINATION before a route change?
Adding or Replacing a Route
Add a route to the canonical prefix through a reachable next hop:
$ sudo ip route add 192.168.2.0/23 via 10.11.12.3 dev enp1s0
The gateway must be reachable according to the relevant link or an explicit valid on-link design. add fails when an equivalent route already exists. replace creates or changes a route, which is useful for idempotent configuration but can overwrite working state; preview the exact target first.
What commonly happens if ip route add targets a route that already exists?
Deleting Precisely
Delete the exact route attributes when more than one candidate or table could exist:
$ sudo ip route del 192.168.2.0/23 via 10.11.12.3 dev enp1s0
A destination-only deletion can match more broadly than intended or be ambiguous. Capture the original command needed to restore the route before removing it.
Why include next hop and device when deleting a route?
Persistence and Remote Safety
An ip route command changes current kernel state only. NetworkManager, systemd-networkd, netplan, ifupdown, DHCP, routing daemons, or orchestration may later replace it. Store the route in the active owner only after testing runtime behavior.
For a remote host, preserve an independent console and use a rollback that does not depend on the route being changed. Then verify route lookup, neighbor state, both traffic directions, and the real service.
What can happen to a manually added route after a network-manager reload?
Lesson complete
You finished route
You can now make a scoped Linux route change with a recoverable workflow.
Capture current routes, rules, and effective lookup.
Use a canonical prefix and reachable next hop.
Distinguish add from deliberate replacement.
Delete the exact route and preserve a restore command.
Persist through the active manager and verify both directions.
Keep your learning progress
Create a free account to save this lesson and continue learning on any device.
Create a free account