There's a slight difference between Linux and FreeBSD. Assume each is
configured so that the loopback device is 127.0.0.1/8. Linux will then
accept a connect to 127.126.125.124, FreeBSD will instead say
"49 EADDRNOTAVAIL Cannot assign requested address. Normally results
from an attempt to create a socket with an address not on this
machine." (FreeBSD 4.7-PRERELEASE errno(2) man page)
While the routing decision seems right with automatic routes, it's
strange that Linux accepts a connection on an IP that is not configured.
Would it be feasible that Linux looks at the destination IP before
accepting a connection on the lo interface?
This may also be related to the issue raised some time ago that Linux
lets you connect to any local IP from any interface by default, so that
eth0 clients can connect to the eth2 IP even when the route is removed.
I believe Felix von Leitner complained about this behaviour.
I'd appreciate documentation pointers on this discussion as I believe
this has been mentioned before, yet I don't recall enough to feed Google
with a decent search.