0

This question already has an answer here:

Tanenbaum's Computer Networks says

The IP address 0.0.0.0, the lowest address, is used by hosts when they are being booted. It means ‘‘this network’’ or ‘‘this host.’’

[::] is IPv6 version of IPv4's 0.0.0.0.

Questions:

1) When does [::] or 0.0.0.0 mean this network and when this host?

2) When it means this host, does it mean all the network interfaces on this host, or just one specified network interface on this host?

3) Why does [::] allow me to access the mysql server from other hosts in the same LAN? Does it mean this network or this host here? Why is [::] used by mysql server, although the host is not in the case "when they are being booted"?

   $ sudo netstat -ap | grep mysql
   tcp6       0      0 [::]:mysql              [::]:*                  LISTEN      23683/mysqld        
   tcp6       0      0 [::]:33060              [::]:*                  LISTEN      23683/mysqld        
   unix  2      [ ACC ]     STREAM     LISTENING     1169294  23683/mysqld         /var/run/mysqld/mysqld.sock
   unix  2      [ ACC ]     STREAM     LISTENING     1169513  23683/mysqld         /var/run/mysqld/mysqlx.sock
   unix  2      [ ]         DGRAM                    1169211  23683/mysqld

Thanks.

marked as duplicate by Stephen Kitt, GAD3R, Mr Shunz, user34720, elbarna Mar 23 at 21:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • From my understanding [::] and 0.0.0.0 is for local host only unless there is static route or default route set on the network! – Vivek Kanadiya Mar 22 at 15:19
  • unix.stackexchange.com/questions/507564/… You completely ignored the answer you've got. And how it's not the case? Doesn't the MySQL server run exactly the same machine with netstat? – 炸鱼薯条德里克 Mar 23 at 0:38
  • @StephenKitt Your link doesn't answer the "this network" part. I am also still not sure about "0.0.0.0 is used only as a source address", so I left a comment there. – Tim Mar 23 at 0:46
2

In the netstat output you gave, the "0.0.0.0" and "[::]" don't mean "this host", they mean that the services in question are listening on "all interfaces on this host". Thus, those ports are open for any host to connect to, including the local host.

  • Thanks. "services in question are listening on all interfaces on this host", are such service also listening on those IP addresses which are not bound to any (virtual or physical) network interface? unix.stackexchange.com/questions/508007/… – Tim Mar 22 at 16:18
  • In the case of the loopback address and network in the question you referred to, yes. 127.0.0.1 is also referred to as "localhost" or "loopback", meaning "this IP references the host itself". But be careful of extrapolating behavior of any 127.*.*.* address to any other address - the loopback network (127/8) has always behaved very differently. – John Mar 22 at 16:26
  • Thanks. May I ask what Stephen meant by "0.0.0.0 isn’t valid as a destination address, only as a source address"? When mysql server listens at 0.0.0.0, Is it not the destination of a request sent from a mysql client? How can it be used as a source? unix.stackexchange.com/a/419881/674 – Tim Mar 22 at 21:01
  • When a service is listening on "0.0.0.0", it is actually listening on "all IPv4 addresses on this host". So no, 0.0.0.0 is not a valid destination address for incoming requests, instead valid destinations are "all extant IPv4 addresses on this machine". – John Mar 24 at 0:14
2

[::] and 0.0.0.0 are better thought of as "Null" from other areas of computing. Depending on context it can mean "nothing", "don't know", "don't care" or occasionally "error". It's meaning is really context sensitive.

IP addresses can be used to represent a network or host. Eg 192.168.1.1 is a host on 192.168.1.0/24. Which it represents entirely depends on what the software was expecting to receive.

When it means this host, does it mean all the network interfaces on this host, or just one specified network interface on this host?

When referring to bound (listening) sockets, it means "don't care" which IP. But that is limited to only the IPs for the current host, so in practice means connections will be accepted on any interface addressed to any IP from the current host.

Not the answer you're looking for? Browse other questions tagged or ask your own question.