6

From https://stackoverflow.com/a/40189197/156458

Blocking 0.0.0.0 makes no sense. In IPv4 it is never routed.

What does "routing" a IP address mean?

Why is it the reason that blocking 0.0.0.0 does not make sense?

Thanks.

Zac67
  • 81,287
  • 3
  • 67
  • 131
Tim
  • 1,535
  • 13
  • 26
  • 2
    You route packets, not addresses. The packets are routed based on the destination address in the packet header. The `0.0.0.0` address (actually, any address in the `0.0.0.0/8` network) is not allowed to be a destination address, so explicitly blocking that address doesn't really make sense. – Ron Maupin Mar 23 '19 at 18:57
  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer. – Ron Maupin Jan 04 '21 at 23:36

1 Answers1

6

"Routing" means forwarding a packet based on its network-layer destination address, usually IPv4 or IPv6.

Routing is done by comparing the destination address to the entries in the local routing table and using the best (=longest prefix) match. The entry contains the next-hop gateway or the interface that the packet is then sent to/out of.

0.0.0.0/0 is the default route - because the prefix has zero length it matches any address. However, it is only selected when no other routing entry matches.

As IP address, 0.0.0.0 generally cannot be used (except as source address when configuring an interface, such as with DHCP).

Zac67
  • 81,287
  • 3
  • 67
  • 131
  • Thanks. Does 0.0.0.0 (as an IP address) have two completely different meanings? (1) A process specifies its own unknown address to another process not in the same host, e.g. the DHCP example, and (2) a process specifies that it is listening on all the addresses on the local host, e.g. netstat shows mysql server is listening at `::mysql` (https://unix.stackexchange.com/q/508009/674)? – Tim Mar 23 '19 at 16:42
  • In "Blocking 0.0.0.0 makes no sense. In IPv4 it is never routed", does 0.0.0.0 mean a IP address? Why is it never routed? – Tim Mar 23 '19 at 16:45
  • Yes, 0.0.0.0 is also used when specifying "all local IP addresses" when allocating a BSD-style socket - however, this is host-specific and thus off-topic here. – Zac67 Mar 23 '19 at 16:46
  • You can't use 0.0.0.0 as destination address - so it's never routed. – Zac67 Mar 23 '19 at 16:56
  • Thanks. When a server uses 0.0.0.0 to indicate it is listening at all the IP adresses of local host, is 0.0.0.0 used as source address, destination address, or neither? – Tim Mar 23 '19 at 21:46
  • When allocating a BSD-style socket, 0.0.0.0 is a placeholder for *any local destination address*. – Zac67 Mar 23 '19 at 22:10
  • Is it correct that 0.0.0.0 is used as destination address in this case? – Tim Mar 23 '19 at 22:12
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/91460/discussion-between-zac67-and-tim). – Zac67 Mar 23 '19 at 22:13
  • Is it neither a destination address nor a source adress in this case? – Tim Mar 23 '19 at 22:32