Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"0.0.0.0 is the invalid, un-routable address."

  That's apparently a windows-centric statement.  In Linux,
0.0.0.0 is the same as 127.0.0.1, whereas 0.0.0.1 works as your invalid address.


It's true both in Windows and Linux that it's a non-routable address. It's false both in Windows and Linux that it's an invalid address. It's also false that 0.0.0.0 is "the same as 127.0.0.1" in general. That it's a valid but non-routable address makes it a good address for applications to assign a special purpose to. You'll find that in some cases 0.0.0.0 means localhost, but in other cases it has other meanings.

For example, you might be in for a nasty surprise if you assume that "nc -l 0.0.0.0 1234" is equivalent to "nc -l 127.0.0.1 1234".


By golly, Linux does map 0.0.0.0 to localhost. That produced a bunch of searches to try to find out why it does that. Nothing found. At this point I strongly suspect that Linux is simply exhibiting incorrect behaviour...

It does it for :: as well...


0.0.0.0 is the address programs will listen on to be able to respond to any IP address assigned to the system.

When you are setting up a socket to listen for connections on a particular port you would specify 0.0.0.0 so then things can connect from anywhere like localhost or on any of the many possible IP addresses assigned to the machine, or you can specify a particular IP address and only be able to get traffic from that. For example if you wanted a program only reachable from the same machine you could listen on localhost (127.0.0.1) and then nothing external could directly connect to that particular service.


I've used "telnet 0", for example, as a quick path to localhost on Linux for decades.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: