0

I has service that binds random loopback IP on 127.0.0.0/8 subnet on demand (like 127.12.34.56).

It works fine on Linux but does not work on OS X.

Only solution I found was to make alias for each single address with ifconfig. But because I need all of 16,777,216 addresses and cannot modify source code, this not that case.

  • OS X:

    % nc -l 127.12.34.56 1234
    nc: Can't assign requested address
    
  • Linux:

    $ nc -l 127.12.34.56 1234
    # it works
    
mlebd
  • 1

1 Answers1

0

If you see many TCP sessions in CLOSED, FIN_WAIT_1 state and similar other states, then the TCP close timer is too long.

For the case where all these connections are in use, not just closed but not yet deleted, I quote the answer by Everett, which says that this disabling of all loopback addresses other than 127.0.0.1 is motivated by the standards.

Here is the short answer: sudo ifconfig lo0 alias 127.0.0.* up

Each alias must be added individually (sudo ifconfig lo0 alias 127.0.0.2 up, sudo ifconfig lo0 alias 127.0.0.3 up). It can be done manually for testing, or a subset or the complete list of the other 250 available numbers in that subnet can be made into StartupItems script that will do it automagically at boot time.

The long answer: According to RFC3330, 127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher level protocol to an address anywhere within this block should loop back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback, but no addresses within this block should ever appear on any network anywhere.

But be warned that an operation that will open all 16,777,216 addresses will be very slow.

harrymc
  • 498,455