3 ms·
I'll point out for the benefit of others that not all operating systems treat 127.0.0.0/8 as belonging to the loopback interface. Linux does, so this will prob
by jlgaddis 10y ago
I'll point out for the benefit of others that not all operating systems treat 127.0.0.0/8 as belonging to the loopback interface.
Linux does, so this will probably work for the majority of users here, but, I believe, it will not work for FreeBSD, for example (I'm on an iPad and don't have an SSH client at the moment so I can't verify). In those cases, however, you can add "aliases" to the loopback interface, with specific IP addresses in the 127/8 subnet, and then use them.
- andrewstuart2 10y agoYeah, good point. I fired up my Windows VM and confirmed that I can listen on a randomly-chosen 127.* address as well, so that should mean most people don't need that extra step. :-)
- JonathonW 10y agoOn OSX (and, I suspect, vanilla FreeBSD), this looks like (replacing 127.1.2.3 with the address you want to use; 0xff000000 must stay the same, since netmasks of all addresses on an interface must not confict if they're on the same subnet): sudo ifconfig lo0 alias 127.1.2.3 0xff000000 And then, when you're done: sudo ifconfig lo0 -alias 127.1.2.3 to tear it back down.
- inferiorhuman 10y agoOn FreeBSD at least you can assign whatever address you want to a loopback interface. I'm currently using aliases on a loopback device (lo1 in this case) for host <-> jail communication. The jails get 172.16.0.0/16. You can manage this trivially in rc.conf and then restart the netif and route services.
- X-Istence 10y agoRecommendation for aliases on an interface is to use 255.255.255.255 as the netmask on FreeBSD. For example to add extra interfaces to lo0 on FreeBSD you may use: ipv4_addrs_lo0="127.0.0.2-5/8" in rc.conf And now those addresses are automatically assigned to lo0, the netmask will be set to 255.255.255.255 automatically for all but the first in that range (.2). Since 127.0.0.1 is unconditionally assigned to lo0, you could also use: ipv4_addrs_lo0="127.0.0.2-5/32" This is what I do on FreeBSD.
- cimnine 10y agoI had some fun with this as well a while ago. It's too bad that with IPv6 we'll only get one loopback address (i.e. ::1) and not again a whole loopback subnet.
- kijin 10y agoIPv6 has a humongous private network range, though. fd00:/8 has 2^120 IP addresses. You could set up a Docker bridge with that range and run containers with random addresses. Correctly guessing one of 2^120 addresses would be nearly as difficult as cracking AES128.