Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add a persistent static route, first identify which network manager owns the interface, then configure the route in that manager’s persistent settings. On Debian, that may be ifupdown, NetworkManager, systemd-networkd, or Netplan; RHEL 9’s documented approach uses NetworkManager connection profiles. A static route directs traffic for a destination prefix through a specified next hop or interface when the default gateway is not the right path.

Before adding a static route

A route needs a destination network and prefix, such as 198.51.100.0/24. It may also need a next-hop gateway, which must be reachable through the interface you select. Choose the persistent configuration method that already manages that interface; configuring the same interface through multiple tools can cause conflicts. Debian’s network setup documentation describes its range of managers and cautions against conflicting configuration.

  • Identify the interface and its active network manager.
  • Determine the destination prefix and the correct next-hop address, if one is needed.
  • Use a console or other recovery path if changing an active remote connection could disconnect you.

Configure a static route on Debian

Debian does not have one universal route-configuration file. Its release, installation type, and local setup determine whether the interface is managed by ifupdown, NetworkManager, systemd-networkd, or Netplan. In the setup described by Debian’s documentation, interfaces listed in /etc/network/interfaces are not managed by NetworkManager by default. Confirm ownership before editing.

ifupdown: add interface up and down hooks

For an interface managed by ifupdown, Debian’s NetworkFAQ describes adding commands that run when the interface comes up or goes down. The following is an adapted example using ip route; the addresses and interface are documentation-only examples, not values to copy unchanged:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
auto enp1s0
iface enp1s0 inet static
    address 192.0.2.10/24
    gateway 192.0.2.1
    up ip route add 198.51.100.0/24 via 192.0.2.254 dev $IFACE
    down ip route del 198.51.100.0/24 via 192.0.2.254 dev $IFACE

Adapt the destination, next hop, interface, and address configuration to your network. The up hook adds the route when the interface starts; the matching down hook removes it when the interface stops. Check the installed ifupdown and iproute2 manuals for syntax appropriate to your system. Do not add a second default route without accounting for existing gateways and route metrics.

NetworkManager: store the route in the connection profile

If NetworkManager manages the Debian interface, add the route to that interface’s connection profile. Debian Bookworm’s NetworkManager settings manual documents route settings, including destination prefixes, optional next hops, metrics, and additional route attributes. For a known profile, the basic IPv4 pattern is:

sudo nmcli connection modify "Wired connection 1" +ipv4.routes "198.51.100.0/24 192.0.2.254"
sudo nmcli connection up "Wired connection 1"
ip route

Replace the profile name, destination, and next hop with your actual values. Bringing the profile up may reconnect the interface and interrupt remote access, so use an available console or maintenance path when necessary.

systemd-networkd or Netplan

Debian Reference describes systemd-networkd configuration under /etc/systemd/network/ and Netplan YAML in some cloud setups. Netplan can use NetworkManager or systemd-networkd as its backend. The applicable route syntax and apply procedure depend on the manager and local configuration; consult its current documentation rather than copying settings for a different manager. Do not use Netplan on a host that is not configured to use it.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure a static route on RHEL 9

RHEL 9’s networking guide documents static routes through NetworkManager tools and automation options. With nmcli, add the route to the connection profile for the interface on the same network as the next hop:

nmcli connection modify <connection-name> +ipv4.routes "192.0.2.0/24 10.0.1.2"
nmcli connection up <connection-name>
ip route

Replace the profile name, destination prefix, and next-hop address with values appropriate to your network. The addresses in Red Hat’s example are illustrative. The command updates the profile and activates it; reconnecting the profile can affect a live connection. Red Hat explains that a static route is for sending traffic to a destination that cannot be reached through the default gateway in its RHEL 9 static-route guide.

Verify the route and troubleshoot traffic

After applying the persistent setting, inspect the live route table. Use ip route for IPv4 and ip -6 route for IPv6. Check that the destination prefix, next hop, device, and metric match your intent. If the route does not appear, confirm that you edited the profile or configuration owned by the active manager and that the updated connection or interface was applied.

If the route is installed but traffic still fails, check whether the next hop is reachable over the selected link, whether a more-specific route or lower-metric route takes precedence, and whether the route belongs in a different routing table. Also check that the remote network has a return route. Installing a route directs packets along a path; it does not by itself guarantee end-to-end connectivity.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choosing the right configuration method

System and manager Where to configure Apply and verify
Debian with ifupdown Interface up/down hooks in /etc/network/interfaces Use the host’s ifupdown procedure; inspect with ip route or ip -6 route.
Debian with NetworkManager NetworkManager connection profile Modify and activate the profile with nmcli; inspect the route table.
Debian with systemd-networkd or Netplan The configuration for the active manager; the specific non-default route syntax depends on that setup Follow that manager’s apply procedure; inspect the route table.
RHEL 9 with NetworkManager NetworkManager profile for the interface connected to the next-hop network Modify and activate the profile with nmcli; inspect the route table.

For either operating system, IPv4 and IPv6 use distinct route properties and verification commands. If you need metrics or policy routing, consult the active manager’s route settings rather than assuming a basic destination-and-gateway entry covers those requirements.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.