How to set up recursive routing on Openwrt?

My LAN network is 10.0.0.1/24, and I already have a static route of 10.1.0.1/24 via 10.0.0.254.

I now want to add a route 198.18.0.1/16 via 10.1.0.4, because this route depends on the previous static route, it will prompt Network unreachable when adding it.

Even if the onlink flag is added successfully, this recursive route does not work. What is the problem? Does openwrt not support recursive routing?

No idea what you mean by brand new term "recursive route", it is jusrt two routes ones gateway is not in same subnet,

2nd route goes via 0.0.254 which then knows how to reach that subnet.
No need to type commands, you can enter static routes via luci

My first test was through luci. After adding the static route, the command "ip route show" actually did not show the secondary route.

As I understand recursive routing, the next hop address of a static route is not directly reachable and needs to rely on another static route to reach it.

But the point is that this is not necessary. A router only needs to have the gateway by which it can reach the next network. It doesn’t need to worry about the networks/gateways beyond the next one.

2 Likes

Yes a gateway always has to be an IP that is directly reachable from the router configured with that route. The next hop to 192.168.0.0/16 would be the router holding 10.1.0.0. That router would have an entry in its table for 192.168.0.0.

I'm not entirely sure but I think recursive routes are only a thing with bgp speaker because back in the days peers needed to be directly reachable.
But I think since bgp4 and route reflectors and route servers this was loosend and peers did not need to be directly reachable and could be connected with multiple hops and it was called recursive routing...

Recursive route resolves local gateway towards unreachable gateway.