2

I can add route over the interface using ip route add command, for example:

ip r a 1.1.244.244/32 dev main-br

How to achieve the same using nmcli?

slawek
  • 31
  • 3

1 Answers1

2

A search for nmcli add route brings us to this documentation, which says that we can add a static route like this:

nmcli connection modify enp1s0 +ipv4.routes "192.168.122.0/24 10.10.10.1"

Experimenting with that command, it looks like if you want to specify a device route as in your example, you can simply leave out the nexthop address, giving you:

nmcli connection modify enp1s0 +ipv4.routes "192.168.122.0/24"

Or in your case:

nmcli connection modify <connection_name> +ipv4.routes 1.1.244.244/32

Where you would replace <connection_name> with the name of the networkmanager connection associated with device main-br.

larsks
  • 43,623
  • 14
  • 121
  • 180
  • I have the same requirement as OP. That is, this works: ip route add 192.168.39.11/32 dev br0 the nmcli connection name is also br0. `nmcli connection modify br0 +ipv4.routes 192.168.39.11/32` but the bridge breaks now. The VM can not connect. the br0.nmconnection now has this: `[ipv4] method=auto route1=192.168.39.11/32 ` – Tim Richardson Aug 21 '23 at 00:39