This problem usually occurs with servers, but the question itself is about network.
When I have a gateway with 10.1.1.1 and an interface with /24 network, the network routes are automatically installed by the os as follows:
0.0.0.0/0 via 10.1.1.1 dev eno1 src 10.1.1.10 10.1.1.0/24 dev eno1
And if I have a packet destined to 10.1.1.20 from local, it doesn't send the packet to its gateway 10.1.1.1. Instead, it looks up an arp table for 10.1.1.20 and writes a destination address for 10.1.1.20 in its frame.
However, if there's a static host route to 10.1.1.20 with the next hop 10.1.1.1 in the route table (see below), it seems to look up an arp table for 10.1.1.1 and write a destination address for 10.1.1.1 in its frame.
10.1.1.20/32 via 10.1.1.1 dev eno1 src 10.1.1.10
So what's going on here?
Why does it look up an arp entry for a destination host when the route table has only network address, but it looks up an arp entry for the next hop when the route table has a host address?