IP Address – Is it OK to Leave Trailing 0’s Off in IPv4 CIDR Notation?

ipip addressipv4subnet

In IPv6, we can collapse 0's when talking about addresses.

In IPv4, can I write 192.168.1.0/24 as 192.168.1/24? Can I write 10.0.0.0/8 as 10/8?

I'm working on some software that takes CIDR's as arguments and some of my customers have provided these "short hand CIDRs". I want to know if they are valid or not.

Thanks!

Best Answer

Collapsing IPv4 addresses like that is not a standard the way it is with IPv6. There are some applications which can take addresses like that, but you will find that most do not. It is fine, and recommended, to leave off the leading zeros in each IPv4 octet (some things will misread leading zeros to mean octal notation), but you shouldn't collapse octets.