Routing
One command family per address family. The default gateway is simply the 0.0.0.0/0 route, or ::/0 for IPv6 — there is no separate WAN or LAN concept. ip route is IPv4-only and ipv6 route is IPv6-only; the ipv6 keyword is compulsory.
Static routes
Three forms per family. A gateway route needs no egress interface, because the next-hop lives in exactly one connected subnet and egress is derived from it; interface with no gateway makes a connected or link route out that interface. The next-hop may also be given with no gateway keyword at all — the bare-gateway shorthand. Adds and deletes stage into the candidate and apply live on commit: the RIB reconciles without dropping sessions.
ip route add <a.b.c.d/p> gateway <ip> [interface <name>] \
[distance <n>] [metric <n>] [weight <n>]
ip route add <a.b.c.d/p> interface <name> [distance <n>] ...
ip route add <a.b.c.d/p> <ip> [distance <n>] ... # bare gateway
ip route delete <a.b.c.d/p> [gateway <ip>]
ipv6 route add <x::y/p> gateway <ip6> [interface <name>] ...
ipv6 route add <x::y/p> <ip6> ... # bare gateway
ipv6 route delete <x::y/p> [gateway <ip6>]
ip route add 0.0.0.0/0 gateway 203.0.113.5
ip route add 10.4.4.0/29 10.20.50.1
ipv6 route add ::/0 2001:db8::1
commit ; save
How a route is selected
Administrative distance decides across sources, with the lowest live distance winning. A distance of 0 means the source's own default, which for static is 10. Metric tie-breaks within one distance, lower winning. Weight sets the ECMP share among equal-distance routes to the same prefix, defaulting to 1.
connected 0 RADIUS 5 static 10 (the default for ip route add) DHCP 15 BGP 20 OSPF 110
Inspecting the RIB and FIB
The RIB is what you configured and what was learned; the FIB is what was actually programmed into the data plane. Selection flags in show ip route read S for selected, R for resolved, lowercase r for recursive and i for inactive.
show ip route [detail] # prefix, gateway, source, distance, # metric, weight, flags (S R r i) show ip fib # selected route per prefix: # prefix, nexthop, egress, # configured-nh, resolved-nh, state show ip nexthop # egress port + resolved gateway MAC show ipv6 route [detail] | show ipv6 fib | show ipv6 nexthop routing # routing knobs (recursive-via-default)
Recursive resolution
A static route whose gateway is not on a connected subnet resolves recursively through the covering route, flagged r in show ip route. show ip fib exposes both the configured next-hop — the route's own gateway — and the resolved next-hop, the terminal on-link gateway the recursion reached; they differ exactly when the route is recursive. Recursion through the default route is allowed by default, loop-guarded and capped at eight hops. Disabling it makes an off-net static gateway resolve to blackhole instead, and the toggle re-resolves the RIB immediately.
routing recursive-via-default <enable|disable> commit show ip fib
Live default-gateway re-point
Changing the live default gateway does not drop sessions. The change stages, and on commit the daemon ARPs the new gateway and swaps forwarding only once it answers — resolve-then-swap rather than swap-and-hope. This is a good candidate for commit confirmed if you are re-pointing the gateway you are managing the box through. The default gateway is simply the 0.0.0.0/0 route, so it is set with the ordinary ip route command — there is no separate default-gw verb.
ip route add 0.0.0.0/0 gateway 203.0.113.9 commit confirmed 10 confirm