An acquaintant posted the following question on an IRC channel earlier today:
How many IPv4 addresses are there?
The quick and simple answer is 232 = 4,294,967,296 addresses.
Is this an accurate answer? Yes, in a strict interpretation of the original question.
A far more interesting puzzle is if you want to account for all the IPv4 addresses usable on the public internet.
Let’s begin by summing all the available addresses from classes A, B, and C. After all, the multicast addresses in class D are limited to their specific usage. The same goes for the class E addresses, which are off-limits in most systems anyway.
Remember, class A addresses are distinguished by the most significant bit being set to 0 (zero), leaving 31 bits to play with. Class B addresses are distinguished by the two most significant bits being set to 10 (one-zero), leaving 30 bits to play with. And finally, class C addresses are distinguished by the three most significant bits being set to 110 (one-one-zero), leaving 29 bits to play with.
Here’s a fair approximation:
231 + 230 + 229 = 2,147,483,648 + 1,073,741,824 + 536,870,912 = 3,758,096,384.
What remain is to subtract all the subnets reserved for various purposes.
The Wikipedia article on Reserved IP addresses, as accessed on 2015-05-09T13:00:00+0200, marks these subnets within the classes A, B, and C, as reserved:
|CIDR||Number of Unique Addresses||Purpose|
|0.0.0.0/8||16,777,216||Used for broadcast messages to the current (“this”) network as specified by RFC 1700, page 4.|
|10.0.0.0/8||16,777,216||Used for local communications within a private network as specified by RFC 1918.|
|100.64.0.0/10||4,194,304||Used for communications between a Service Provider and its subscribers when using a Carrier-grade NAT (CGN), as specified by RFC 6598.|
|127.0.0.0/8||16,777,216||Used for lookback addresses to the local host, as specified by RFC 3330.|
|169.254.0.0/16||65,536||Used for autoconfiguration between two hosts on a single link when no IP address is otherwise specified, such as would have normally been retrieved from a DHCP server, as specified by RFC 3330.|
|172.16.0.0/12||1,048,576||Used for local communications within a private network as specified by RFC 1918.|
|192.0.0.0/24||256||Used for the IANA IPv4 Special Purpose Address Registry as specified by RFC 5736.|
|192.0.2.0/24||256||Assigned as “TEST-NET” in RFC 5737 for use solely in documentation and example source code and should not be used publicly.|
|184.108.40.206/24||256||Used by 6to4 anycast relays as specified by RFC 3068.|
|192.168.0.0/16||65,536||Used for local communications within a private network as specified by RFC 1918.|
|198.18.0.0/15||131,072||Used for testing of inter-network communications between two separate subnets as specified in RFC 2544.|
|198.51.100.0/24||256||Assigned as “TEST-NET-2” in RFC 5737 for use solely in documentation and example source code and should not be used publicly.|
|203.0.113.0/24||256||Assigned as “TEST-NET-3” in RFC 5737 for use solely in documentation and example source code and should not be used publicly.|
OK, let’s do some subtraction:
|3,758,096,384||231 + 230 + 229|
|=||3,702,258,432||The final number|
All in all, this leaves the world with 3,702,258,432 IPv4 addresses for public use. Subnetting will further diminish this number.
With roughly six billion people on the Earth, this is clearly inadequate. And CGN is only a temporarily measure. Forget it. When will the world finally embrace IPv6, or its successor? Geoff Huston’s automated IPv4 address exhaustion report doesn’t scare people as much as it probably should.
Acknowledgement: Many thanks to
MammaGutt@EFnet for spotting my overuse of the minus sign.