Static Route with Rocky Linux and NetworkManager

Mindwatering Incorporated

Author: Tripp W Black

Created: 01/31 at 06:48 PM



Task: Temporary Static Route Lasting Until Reboot
The example below creates a temporary static route to the network via the gateway/host
$ sudo /sbin/ip route add via

Task: Permanent Static Route
The example below creates a permanent static route to the network via the gateway/host
a. Get the name of the ethernet adapter/NIC using either of the two commands below:
$ sudo ip ro
(example output with a host at IP dev ens192 proto kernel scope link src metric 100


$ sudo nmcli c s
(example output)
ens192 ab1c2789-a2b3-3456-987a-789ef9012a34 ethernet ens192
lo a123451a-2620-1bc1-6789-0b1cde234567f loopback lo

b. Create the permanent route:
In this example, the NIC is ens192, use the command below to add the new static route
$ sudo nmcli con mod ens192 +ipv4.routes ""

c. Restart the network on the NIC using either of the methods below:
$ sudo nmcli con down ens192
$ sudo nmcli con up ens192


$ sudo systemctl restart NetworkManager

previous page