Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

4.2. Configuring Static Routes Using nmcli

To configure static routes using the nmcli tool, use one of the following:
  • the nmcli command line
  • the nmcli interactive editor

Example 4.1. Configuring Static Routes Using nmcli

To configure a static route for an existing Ethernet connection using the command line:
~]# nmcli connection modify eth0 +ipv4.routes ""
This will direct traffic for the subnet to the gateway at

Example 4.2. Configuring Static Routes with nmcli Editor

To configure a static route for an Ethernet connection using the interactive editor:
~]$ nmcli con edit type ethernet con-name ens3

===| nmcli interactive connection editor |===

Adding a new '802-3-ethernet' connection

Type 'help' or '?' for available commands.
Type 'describe [>setting<.>prop<]' for detailed property description.

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6, dcb
nmcli> set ipv4.routes
nmcli> save persistent
Saving the connection with 'autoconnect=yes'. That might result in an immediate activation of the connection.
Do you still want to save? [yes] yes
Connection 'ens3' (704a5666-8cbd-4d89-b5f9-fa65a3dbc916) successfully saved.
nmcli> quit