2

When I add a route using nmcli, the route as reported by ip 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 the ip 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?

  • can 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). – sourcejedi Dec 5 '16 at 16:18
  • I have a virtual machine assigned the 10.0.6.1 address. When the route is added by NetworkManager via nmcli resulting in a route with proto static ntp time sync fails. When the route is added by ip route add resulting in a route with scope link ntp time sync succeeds. To be honest its confusing the heck out of me because I know the proto static route SHOULD work. – pacmanwa Dec 5 '16 at 16:58
  • Are you sure NM isn't changing something else about the routing table? – Bratchley Dec 5 '16 at 18:07
  • Hmm, 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 – sourcejedi Dec 5 '16 at 18:12
  • The 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? – thaller Dec 5 '16 at 23:21
1

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.

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.