Routes onlink - missing doc

is it possible to say whats the meaning of the on-link flag here?


On-Link route means one that the addresses that belong to it can be resolved locally and gateway is not needed.
For example a route to is on-link via interface lo0.
In your example the use of on-link is wrong.

1 Like

duh dont understand :frowning:
do i have to set it to No?

That's right.

but for a what purpose do you set it Yes/ON?

The onlink option is used in very rare cases. When you create a static route, the next hop address must be directly reachable by the specified device, meaning it must be from the same IP subnet. Otherwise you'll get an error response.


root@OpenWrt:~# ip address show dev br-lan | grep 'inet '
    inet brd scope global br-lan
root@OpenWrt:~# ip route add via dev br-lan
Error: Nexthop has invalid gateway. is not in the same IP subnet (, so the route was rejected.

Now let's use the onlink option:

root@OpenWrt:~# ip route add via dev br-lan onlink
root@OpenWrt:~# ip route show via dev br-lan onlink

Using this option, we tell the kernel that the next hop is located in the same Layer 2 segment.
If a packet must be sent to network, an ARP request will be generated on the br-lan interface (asking "who has"), and the packet will be forwarded to the returned MAC address.


thanks for the explanation!