Configuring a Static Route Using the Network Connection Editor

To create a static route to the 192.0.2.0/24 network through the gateway 198.51.100.1, ensure first that the default gateway 198.51.100.1 is reachable on the interface. Then, complete the following steps:

  1. Start the editor.
    nm-connection-editor
  2. From the list of connections, select the device under the connection name for which you want to create a static route.
    For example, under myconnection, you would select the device ens3.
  3. Click the settings icon (gear wheel) to edit the connection settings.
  4. Click the IPv4 Settings tab.
  5. Click Routes.
  6. Click Add.
  7. Enter the network's address and netmask for which the route is created, and specify the gateway IP address through which the route is established.

    You can optionally enter a metric value and select the other available options on display.

    The image shows the NetworkManager Connection Editor window where you can configure static routes for an IPv4 network.
  8. Click OK and then Save.
  9. Back at the terminal window, restart the connection.

    This step causes the connection to temporarily drop.

    sudo nmcli connection up myconnection
  10. Verify that the new route is active.
    ip route
    ...
    192.0.2.0/24 via 198.51.100.1 dev myconnection proto static metric 100