Adding a static route with ip route add sends traffic for one destination prefix to a chosen next hop instead of leaving that traffic to the default route. This is useful for lab networks, site-to-site VPN subnets, and hosts that need a deliberate path to one remote network without changing every other route.
The command writes the route directly into the running kernel routing table. A typical static route names the destination prefix, the gateway with via, and the egress interface with dev; if no table is specified, the route is added to the main table, while policy-routing setups can add table 100 or another custom table ID.
A static route takes effect immediately, so a wrong prefix length or unreachable next hop can break access just as quickly as a correct route fixes it. Confirm the gateway is valid for the selected interface before adding the entry, and plan to update the system's persistent network configuration separately if the route should survive a restart.
$ ip route show default via 192.0.2.1 dev eth0 192.0.2.0/24 dev eth0 proto kernel scope link src 192.0.2.10
$ sudo ip route add 198.51.100.0/24 via 192.0.2.1 dev eth0
Use dev eth0 without via only for an on-link destination. Add table 100 when the route belongs in a custom policy-routing table instead of the main table.
$ ip route show 198.51.100.0/24 198.51.100.0/24 via 192.0.2.1 dev eth0
$ ip route get 198.51.100.10
198.51.100.10 via 192.0.2.1 dev eth0 src 192.0.2.10
cache
Routes added with ip route add are usually lost after an interface restart or reboot until the network config is updated.