1
root@Andromeda:~# nmcli con show "Wired connection 1" | grep -i routes
ipv4.routes:                            --

then ...

root@Andromeda:~# nmcli con modify "Wired connection 1" +ipv4.routes "188.88.88.88/23 172.16.2.1"
root@Andromeda:~# nmcli connection up "Wired connection 1" 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
root@Andromeda:~# nmcli con show "Wired connection 1" | grep -i routes
ipv4.routes:                            { ip = 188.88.88.88/23, nh = 172.16.2.1 }

but ...

root@Andromeda:~# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         speedport-entry 0.0.0.0         UG    100    0        0 enp3s0
10.10.10.0      0.0.0.0         255.255.255.240 U     0      0        0 br-f8186d7831df
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 enp3s0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.1.0     0.0.0.0         255.255.255.0   U     100    0        0 enp3s0
root@Andromeda:~# ip route
default via 192.168.1.1 dev enp3s0 proto dhcp metric 100 
10.10.10.0/28 dev br-f8186d7831df proto kernel scope link src 10.10.10.1 linkdown 
169.254.0.0/16 dev enp3s0 scope link metric 1000 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 dev enp3s0 proto kernel scope link src 192.168.1.6 metric 100 

Why isn't the specific route being shown by either ip route or route commands although it seems to exist when using nmcli ?

2

First of all, nmcli connection ... shows that the manual route is in the connection profile. A profile is a bunch of settings for configuring a networking device. But it is not the configuration of the device itself. If you want to see the routes that are currently configured, then nmcli -f all device show enp3s0 or ip route show are right. These two commands don't do exactly the same, the first asks NetworkManager what it thinks is the current configuration, the second asks kernel via netlink API. Of course, the information provided by both command should agree.

Anyway, so you set the route in the profile and activate it. You are right to expect to see the route on the device.

It's not there because the 172.16.2.1 gateway is not directly reachable. Kernel won't allow to add this route and probably in NetworkManager's logfile you would see a warning about the failure to add the route. You would also be unable to add this route with ip route add directly.

The potential solution is to either configure the route as onlink (which kernel and NetworkManager only supports relatively recently). A better solution is to also add a direct route to the gateway as well (+ipv4.routes 172.16.2.1/32). Provided, that that is the right configuration in your network.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.