ip route add fails with next hop invalid although next hop on directly connected network
you have to use "onlink" too, like so:
ip r a 10.0.0.0/24 via 194.104.212.225 dev eth0 onlink
because the net 10.0.0.0/24 and default gw are outside of all known local networks. you probably have to configure network routes back to your host as well?! looks a bit strange to me, at least for IPv4 .. with IPv6 this would be ok. hopefully it works for you!
HTH
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
When I check the routing table I get following information:
root@vmi24:/home/user# ip route default via 194.104.212.225 dev eth0 onlink 194.104.212.224/27 via 194.104.212.225 dev eth0
When i want to add a route to 10.0.0.0/24 via 194.104.212.226 (which is part of the directly connected 194.104.212.224/27 network, I get following error:
root@vmi24:/home/user# ip route add 10.0.0.0/24 via 194.104.212.226 Error: Nexthop has invalid gateway.
Another strange issue is that if I delete the default gateway, I cannot add it again because the add command for the default gateway fails with the same "Nexthop has invalid gateway" error.
I am using Debian 10 on a hosted VM.
When I try this on a KALI based machine have no issue adding a static route.
I am running out of options, as this phenomenon prevents me from activating an openvpn (it fails inserting the /32 route to the openvpn server via the directly connected gateway on the eth0 interface
What do I fail t see? What do I overlook? I have found many problems with next-hop documented but most if not all are due to not directly connected or unreachable next-hops.
Regards
Patrick