Routes added via NetworkManager are incorrect vs ip route. How do I make NetworkManager create correct routes?
Perhaps your problems are related to the setup of the VM? In a simpler case, where I have another router on my network, nmcli works as expected. In my case, the network is 192.168.1.0/24, default route is 192.168.1.1, and there is another router at 192.168.1.9 which connects to another network 192.168.8.0/24.
nmcli c modify eth0 +ipv4.routes "192.168.8.0/24 192.168.1.9"
nmcli c up eth0
This produces expected result in ip route:
default via 192.168.1.1 dev eth0 proto static metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.5 metric 100
192.168.8.0/24 via 192.168.1.9 dev eth0 proto static metric 100
and in nmcli c show eth0:
IP4.ADDRESS[1]: 192.168.1.5/24
IP4.GATEWAY: 192.168.1.1
IP4.ROUTE[1]: dst = 192.168.8.0/24, nh = 192.168.1.9, mt = 100
This is on fedora 24.
Related videos on Youtube
pacmanwa
Odd configurations is the name of the game. Why weird and obscure? Answer: very demanding customer requirements.
Updated on September 18, 2022Comments
-
pacmanwa over 1 year
When I add a route using
nmcli
, the route as reported byip route show
is incorrect:nmcli connection modify eth2 +ipv4.routes "10.0.6.1/32 10.1.7.1"
10.0.6.1 dev eth2 proto static src 10.1.7.1
This route does not work.
However if I use
ip route add
theip route show
is correct and the route works:ip route add 10.0.6.1/32 dev eth2 src 10.1.7.1
10.0.6.1 dev eth2 scope link src 10.1.7.1
I can't seem to find the correct way to add the route using nmcli and have it show up correctly. Any ideas, or is there something I'm missing?
-
user2948306 over 7 yearscan you be more specific about why you know the reported route is incorrect?
proto static
sounds reasonable to me, it looks the same as my default route (using networkmanager+DHCP4 on Fedora 24). -
pacmanwa over 7 yearsI have a virtual machine assigned the 10.0.6.1 address. When the route is added by NetworkManager via
nmcli
resulting in a route withproto static
ntp time sync fails. When the route is added byip route add
resulting in a route withscope link
ntp time sync succeeds. To be honest its confusing the heck out of me because I know theproto static
route SHOULD work. -
Bratchley over 7 yearsAre you sure NM isn't changing something else about the routing table?
-
user2948306 over 7 yearsHmm, maybe it works differently because default route has a target IP as well. Anyway perhaps you could look at the result of
ip route get
in each case unix.stackexchange.com/a/192065/29483 -
thaller over 7 yearsThe route has a
src
but NM doesn't support that. Hence it looks like the route is not added by NM. Also,nmcli con modify
modifies a connection profile. Did you activate the connection afterwards for the change to take effect? -
pacmanwa over 7 yearsYes,
nmcli connection up eth2
is the last thing I do.
-