0

As I understand 0.0.0.0 means all network interfaces of this host (including 127.0.0.1).

Suppose I have three interfaces 192.0.2.40, 203.0.113.150 and 127.0.0.1 on server (OS linux).

On 192.0.2.40:777, I have ServerA. On 203.0.113.150:777, I have ServerB. How will server process the request to 0.0.0.0:777? I mean when the same port (777) is listening on different interfaces. Or I understand everything wrong?

Patrick Mevzek
  • 9,921
  • 7
  • 32
  • 43
Pavel_K
  • 85
  • 12

2 Answers2

2

0.0.0.0 and 127.0.0.1 are used internally. 0.0.0.0 is used to designate all interfaces, and 127.0.0.1 designates the loopback interface. They have nothing to do with the incoming traffic.

If a client needs to connect to your server, they will need to specify the actual IP address of interface, like 192.0.2.40:777 or 203.0.113.150:777. This is how the your Linux machine will know which server should serve the request. (If the client were to try to connect to 127.0.0.1 or 0.0.0.0, they would be connecting to their own system, not yours.)

Jenny D
  • 27,780
  • 21
  • 75
  • 114
Abu Zaid
  • 499
  • 2
  • 6
  • But if I do on this computer telnet 0.0.0.0 777 to what interface will be connected? – Pavel_K Mar 21 '18 at 12:07
  • @PavelK That's an entirely different question from the one that you were asking. If you want the answer for Unix, I suggest you ask it in [unix.se]. – Jenny D Mar 21 '18 at 19:03
  • @JennyD No, this is the question I asked - 100/100. So I don't see the point to ask the same question there. – Pavel_K Mar 21 '18 at 20:28
  • @PavelK Your original question asks how the server will respond if it gets a request for 0.0.0.0:777. Your comment asks how telnet will act if it gets asked to connect to 0.0.0.0:777. Those are two different questions. – Jenny D Mar 21 '18 at 20:55
  • @JennyD No. You misunderstand me. I am not asking about `telnet`. I am asking how will server process request to 0.0.0.0 when this request comes from current host (but not other host). And as example I can give `telnet 0.0.0.0 port`, `ssh 0.0.0.0 -p port` etc. So the question is what I asked, telnet is example. I hope I could explain the idea. And thank you for your comments. – Pavel_K Mar 22 '18 at 18:05
  • @PavelK You are assuming that telnet, ssh and the other programs will in fact just pass 0.0.0.0:777 on to the server. That's not what happens; they will either give an error message or parse it into something usable. Again, that's something that happens on the client side, not on the server side - and again, it's something a couple of the very smart people at [unix.se] will be able to explain in detail. – Jenny D Mar 23 '18 at 04:27
  • @JennyD Thank you for your explanation. I consider that there is only one computer in network. So when I do telnet and ssh on 0.0.0.0 I make request to `this` computer on which I currently work. And such requests work without any problems. You can try `telnet 0.0.0.0. anyport` and you will see the result. It works! – Pavel_K Mar 23 '18 at 06:04
  • @JennyD I am asking this question here but not on Unix & Linux as I think that this is some specification and other OS must work the same. – Pavel_K Mar 23 '18 at 06:36
  • @PavelK Go ask on Superuser, then. In any case, the question should be "how does the OS resolve a request to connect to 0.0.0.0", not "how does the server respond when a connection is made to 0.0.0.0". – Jenny D Mar 23 '18 at 06:53
  • @JennyD If you so insist, please https://superuser.com/questions/1307050/how-does-the-os-resolve-a-request-to-connect-to-0-0-0-0 – Pavel_K Mar 23 '18 at 07:19
2

How will server process the request to 0.0.0.0:777

It will not - you can not send a requst to 0.0.0.0, period.

What this means is that the host will react to EVERY request (on Port 777), regardless of the IP address used. Obviously the server msut be configured with an IP address, but this means the server process does not do any additional filtering.

TomTom
  • 51,649
  • 7
  • 54
  • 136