Is it possible to find and bind to a random unused IP address in the private block 127.0.0.0/8?

314 Views Asked by At

The alternative is to use a daemon to manage and hand out those IP addresses. Trying to get DHCP daemon software to serve out IP addresses in 127.0.0.0/8 is weird and doesn't seem to work well for me and the alternative is to write my own DHCP like daemon (but for localhost.) Also, a daemon has troubles with staleness unlike with the OS which knows when applications unexpectedly exit.

Also, I can't use the trick of connecting to a broadcast address to auto-bind to an address because that doesn't allow me to select the port.

1

There are 1 best solutions below

8
Ron Maupin On

The 127.0.0.0/8 block is not able to be used outside the host on which it is configured. It is not a "Private" block, and most DHCP servers are smart enough to not assign addresses from this block. The addresses in this range are of no use other than for the host to talk to itself.