I was once watching a slideshow about the new IPv6, and it mentioned that it is large enough for every grain of sand on earth to be IP addressable.
Is there any grain of truth behind this? (no pun intended)
Estimating the number of grains of sand on Earth is difficult. This source suggests 7.5x1018 grains (7.5 quintillion), but only includes beaches (deserts, under-sea sand and other sources not included.) This source suggests 1020 to 1024 grains (up to septillion grains of sand).
The number of addresses IPv6 could possibly address is 2128 (excluding reserved addresses), or about 3.4x1038 (340 decillion). Even if you remove the reserved addresses you're still left with far more IPs than grains.
In fact, assuming the most number of grains of sand - around 1024 - 294 femtopercent (yes, femto, 10^-15) would be used if every grain were allocated an IP. You could allocate 340 billion planets with the same number of grains of sand before you even came close to filling up the address space. After all that, you'd still have 2.8x10^35 (280 decillion) addresses free.
IPv6 has 2^128 distinct adresses. As noted by Thomas O. this is more than enough for all grains of sand. Indeed, as one of the comments notes it's enough to give an IPv4 sized subnet to each grain of sand.
However that is not the complete story. IPv6 is not just IPv4 with a larger adress space. It's a different protocol intended to be used in a different way. The important point in this context is that it is designed to be essentially empty. This means that comparing grains of sands to individual addresses is not meaningful.
IPv6 subnets are indicated by CIDR notation. This means that a /64 subnet is one where the first 64 bits adresses the subnetwork and the remaining bits adresses the components inside the subnet.
The segments intended to represent a LAN segment in IPv6 is the /64 subnets. Each of these have 2^64 addresses, and there are potentially 2^64 such subnets. If you allocate the grains in these subnets, and assuming there are 10^22 grains of sand, you need to assure that each subnet has at least 10^22/2^64~=1000 grains of sand in them. Not an onerous requirement though, so we are still good.
However even this might be a bit to optimistic as far as utilization goes. ARIN tracks IPv6 utilization at the /56 subnet. Ie. it considers a segment fully utilized if in each /56 subnet there is at least one assigned adress. Documentation. At that level you need to insure at least 10^22/2^56~=140000 grains of sand in each subnet. Sand grains have a diameter of 0.0625mm - 2mm. So if we assume a diameter of 1mm and a packing density of 0.6 we need our /56 subnets to encompass at least 121cm^3. Since we would want much larger subnets than this anyway for administration purposes, the conclusion remains that IPv6 can easily adress each grain of sand on the planet.
Also an interesting coincident: A /56 network, ie. the smallest subnet that ARIN cares about as far as utilization goes, contains 2^72 addresses. 2^72=4.72*10^21, ie. depending on what estimate you choose for the number of grains on the planet there is enough adresses to give each grain an adress from a single such network.