Linux 101 : Nmcli - adding a static route, Network Manager Command Line Interface -



Adding a Static Route:

A static route is added manually in the routing table, as opposed to the dynamic routes that are added automatically using a dynamic routing protocol like RIP - Routing Information Protocol -

Displaying the connections in our system:

We can display the connections on our system, using the below command:


We can also display the routes using the below command:



Adding a new default route:

We can add a new default route using the below command:


The above command adds a default route "172.90.150.1for the "172.90.150.0/24" network, through the connection "Wired 1", that is associated with the "eno1" interface.

For the changes to take effect, we have to restart the "Wired 1" connection, using the below commands:


We could use "route" or "ip route" to display the routes depending on the system.

Remark:

To remove a route we use the "-ipv4.routes" parameter with the nmcli command.

We could see our newly added route using the below command:


Comments

Leave as a comment:

Archive