I know that 0.0.0.0/0 represents a default route.
But I would like to understand what does 0.0.0.0/1 represents? Is it even a valid thing in networking?
- 697
- 1
- 8
- 22
-
see also https://networkengineering.stackexchange.com/q/78785/25437 – ilkkachu Nov 14 '22 at 21:18
3 Answers
Zac is muddying the waters by excluding 0.0.0.0/8 and 127.0.0.0/8. While addresses in those two prefixes should never appear on the wire, 0.0.0.0/1 does cover them. The slash notation works the same for zero and one as it does for any number from 0 to 32, inclusive. "The number of bits that matter." One bit means 0-127, and 128-255; since you stated 0.0.0.0/1, it's the former [addresses 0.0.0.0 through 127.255.255.255, or in hex 00000000 - 7FFFFFFF]
It's a common trick of VPN software to use 0/1 and 128/1 routes as more specific than the (0/0) default route, without having to muck with other processes (eg. DHCP - if you mess with the routes DHCP installed, it will reinstall them when the lease renews.)
(But otherwise, yes, 0.0.0.0 is not a legal interface address.)
- 32,147
- 2
- 43
- 85
-
I would add that the pair of CIDRs allow you to "override"
0.0.0.0/0without "overwriting" you0.0.0.0/0route. – Aron Nov 15 '22 at 03:38 -
1
0.0.0.0 is no valid IP address, regardless of prefix length. 0.0.0.0/0 as prefix matches any address, so it's used for the default route. Also, 0.0.0.0 is the unspecified address used in many APIs, indicating 'all local addresses'.
A 0.0.0.0/1 prefix matches any address from 0.0.0.0 to 127.255.255.255 (practically 1.0.0.0 to 126.255.255.255; 0.0.0.0/8 is reserved for IANA special use and generally invalid, 127.0.0.0/8 is reserved for local loopback) - if that makes sense for you. I've seen at least one instance of crude 'load balancing' with two WAN uplinks where one was used for 0.0.0.0/1 and the other for 128.0.0.0/1.
0.0.0.0/8 and 0.0.0.0/32 specifically are reserved by RFC 1122 section 3.2.1.3.
- 84,333
- 4
- 69
- 133
-
1So the CIDR representation -
0.0.0.0/1is practically used to represent an IP addresses range -1.0.0.0to126.255.255.255, is that right? – Deepak Nov 14 '22 at 14:09 -
1
-
So
0.0.0.0/0is the only CIDR representation which is considered as default route, correct? – Deepak Nov 14 '22 at 14:37 -
2
-
3I've also seen the CIDR pair
0.0.0.0/1and128.0.0.0/1being using to apply a reversible route to0.0.0.0/0. This is typically done onvpn-up/down.shscripts. – Aron Nov 15 '22 at 03:36 -
I thought reserving the .0 network address was considered obsolete. Is there a different reason why 0.0.0.0 specifically is invalid? – user253751 Nov 15 '22 at 05:15
-
1@user253751 With a prefix shorter than /24, the .0 address might not be anything special. It's the all-host-bits-zero address that's largely unusable with IPv4. – Zac67 Nov 15 '22 at 07:37
-
-
@user253751: It's inverse broadcast. You fill in 0.0.0.0 as a source IP address when you don't have an IP address yet. – Joshua Nov 16 '22 at 03:27
-
Also should be noted, 0.0.0.0 in many networking APIs is used to specify "default network adaptor" when passed as a parameter. – Chuu Nov 16 '22 at 19:28
0.0.0.0/1 is not an IP address per-se, it's the combination of an IP address and a prefix length in CIDR notation. It represents the range of addresses from 0.0.0.0 to 127.255.255.255.
There are a few places it might crop-up.
- It's the CIDR notation for the block of addresses that were formerly known as class A (class B is 128.0.0.0/2, class C is 192.0.0.0/3 class D is 224.0.0.0/4 and class E is 240.0.0.0/4) .
- As Zac97 suggests it may be used as a crude approach to load balancing, with 0.0.0.0/1 pointed at one link and 128.0.0.0/1 pointed at another link to use each link for (very roughly) half of destinations.
- Some VPN software, notably openvpn, uses a pair of routes for 0.0.0.0/1 and 128.0.0.0/1 to effectively override the default gateway without modifying or removing it.
- 13,303
- 2
- 21
- 47