hello
is it possible to say whats the meaning of the on-link flag here?
thanks
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 127.0.0.0/8 is on-link via interface lo0.
In your example the use of on-link is wrong.
duh dont understand
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.
Example:
root@OpenWrt:~# ip address show dev br-lan | grep 'inet '
inet 192.168.92.15/24 brd 192.168.92.255 scope global br-lan
root@OpenWrt:~#
root@OpenWrt:~# ip route add 10.0.0.0/8 via 192.168.100.1 dev br-lan
Error: Nexthop has invalid gateway.
192.168.100.1 is not in the same IP subnet (192.168.92.0/24), so the route was rejected.
Now let's use the onlink
option:
root@OpenWrt:~# ip route add 10.0.0.0/8 via 192.168.100.1 dev br-lan onlink
root@OpenWrt:~#
root@OpenWrt:~# ip route show 10.0.0.0/8
10.0.0.0/8 via 192.168.100.1 dev br-lan onlink
root@OpenWrt:~#
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 10.0.0.0/8, an ARP request will be generated on the br-lan interface (asking "who has 192.168.1.100"), and the packet will be forwarded to the returned MAC address.
thanks for the explanation!