Yes, the machine does immediately know the request is is destined for itself. It does this by comparing the destination address of the packets to all known IP addresses assigned to network interfaces, marking the packet as local, consulting a special routing table (
ip route show table local
) which is automatically updated with rules for locally assigned IP addresses, and replacing the network interface to deliver it with
lo, even if the the destination address is not
tcpdump -ni lo while ping'ing a local address).
You can also use
ip route get 22.214.171.124 to show how the linux kernel classifies the route (
local) and via what interface it will deliver the packet, together with other information like the gateway etc.