3 ms·
If you run tests through the loopback interface, you should be able to use any of the 127.0.0.0/8 addresses, instead of 127.0.0.1 (a.k.a ”localhost”). Each addr
by MawKKe 5y ago
If you run tests through the loopback interface, you should be able to use any of the 127.0.0.0/8 addresses, instead of 127.0.0.1 (a.k.a ”localhost”). Each address has its independent port space, so you would avoid collisions/contention.
- toast0 5y agoYou can use the whole 127/8, but only if you've added the address to your loopback interface. Unix sockets skip all of tcp though, so I'd recommend them vs loopback, if possible. I hear Linux short circuits a lot of tcp for loopback, but there's probably still a bunch of connection state that doesn't need to be there. FreeBSD runs normal tcp on loopback, and you can get packet loss if you overrun the buffer, and congestion collapse and the whole nine yards. Great for validating the tcp stack, not the best for performance; better to skip it.
- edoceo 5y agoHmm. I've not added 127.1.2.3 to lo interface but I can ping it. Start a listening server and connect to it. I didn't have to add anything in 127 - because it's a /8
- MawKKe 5y agoI just tested this and it seems to work by default on Linux but not on FreeBSD. On both the address is configured as 127.0.0.1/8, i.e the whole block. Go figure. This discussion [1] sheds some light on the matter, but does not fully explain the reasons for differing behaviour across OS's. [1]: https://serverfault.com/questions/293874/why-cant-i-ping-an-address-on-the-loopback-device-under-freebsd https://serverfault.com/questions/293874/why-cant-i-ping-an-...
- nousermane 5y agoInteresting. Linux also does that with any other address/subnet added to "lo": # ping -c 1 10.10.10.10 1 packets transmitted, 0 received # ip addr add 10.10.10.1/24 dev lo # ping -c 1 10.10.10.10 64 bytes from 10.10.10.10: time=0.023 ms 1 packets transmitted, 1 received
- edoceo 5y agoThe 127 I get. This one seems odd though.
- toast0 5y agoIt seems to me (based on reported behavior), that Linux is special casing the loopback interface: when you add an address with a netmask to the loopback interface, it considers all of those addresses as local addresses. As opposed to a normal interface where only the specific address is a local address, but the rest of the network specified are accessible through that interface. Maybe one /8 wasn't enough addresses for you, so you added more? Doesn't seem like an unreasonable way to behave, even if it's different than BSD behavior; it certainly makes it easier to use lots of loopback addresses.