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:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
This will direct traffic for the
~]# nmcli connection modify enp1s0 +ipv4.routes "192.168.122.0/24 10.10.10.1"
~]# nmcli connection modify enp1s0 +ipv4.routes "192.168.122.0/24 10.10.10.1"
192.168.122.0/24
subnet to the gateway at 10.10.10.1
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 ens3 ===| nmcli interactive connection editor |=== Editing existing '802-3-ethernet' connection: 'ens3' 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, dcb, ipv4, ipv6, tc, proxy nmcli> set ipv4.routes 192.168.122.0/24 10.10.10.1 nmcli> save persistent Connection 'ens3' (23f8b65a-8f3d-41a0-a525-e3bc93be83b8) successfully updated. nmcli> quit
~]$ nmcli con edit ens3
===| nmcli interactive connection editor |===
Editing existing '802-3-ethernet' connection: 'ens3'
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, dcb, ipv4, ipv6, tc, proxy
nmcli> set ipv4.routes 192.168.122.0/24 10.10.10.1
nmcli> save persistent
Connection 'ens3' (23f8b65a-8f3d-41a0-a525-e3bc93be83b8) successfully updated.
nmcli> quit