IP Subnet – Difference Between 0.0.0.0/0 and 0.0.0.0/1

filteripmasksubnetwildcard

In the history, I mostly used 0.0.0.0/0 for "match every IP address". Recently, I saw a 0.0.0.0/1 subnet filter.

What is the difference between 0.0.0.0/0 and 0.0.0.0/1 and what's the practical use of 0.0.0.0/1?

Best Answer

The 0.0.0.0/0 matches every IP address, whereas 0.0.0.0/1 only matches half of them (0.0.0.0-127.255.255.255) and requires 128.0.0.0/1 as its pair to match the rest (128.0.0.0-255.255.255.255).

In basic routing, the smallest available subnet containing the IP address takes precedence. This rule comes from RFC 4632, 5.1. It is typical there will be overlapping networks as, for example, 192.168.1.0/24 is part of 192.168.0.0/16, which is – just like any IP address – part of 0.0.0.0/0.

Therefore, by splitting the 0.0.0.0/0 into smaller chunks one can constrain the interface to take precedence over any other interface that has default route 0.0.0.0/0, without playing with metric values. This is a common technique with VPNs that would not want data to bypass the tunnel. The same logic is the reason you could still use resources from your local subnet (e.g., /24) while the VPN is on – if no other methods are used to enforce everything gets tunneled.

Likewise, the entire IPv4 address space could be divided into even smaller subnets, e.g. in four chunks:

  • 0.0.0.0/2 (0.0.0.0-63.255.255.255)
  • 64.0.0.0/2 (64.0.0.0-127.255.255.255)
  • 128.0.0.0/2 (128.0.0.0-191.255.255.255)
  • 192.0.0.0/2 (192.0.0.0-255.255.255.255)

Or eight with 0.0.0.0/3, 32.0.0.0/3, 64.0.0.0/3, 96.0.0.0/3, 128.0.0.0/3, 160.0.0.0/3, 192.0.0.0/3 & 224.0.0.0/3, etc., etc.