[Math] Exponentiation and binary logarithm for network administrators

Well-known Google free DNS IPv4 address:

% whois 8.8.8.8

...
NetRange:       8.0.0.0 - 8.127.255.255
CIDR:           8.0.0.0/9
...

How many hosts in this network?

(Python)

>>> 2**(32-9)
8388608

Majority of networks has the prefix x.y.z.t/24

>>> 2**(32-24)
256

Yes, 256 hosts in the network. 'Class C network' in IPv4 lingo.

And otherwise. A network with 512 hosts.

>>> import math
>>> 32-math.log(512, 2)
23.0

So it will have a prefix x.y.z.t/23

(the post first published at 20220721.)


List of my other blog posts.

Subscribe to my news feed

Yes, I know about these lousy Disqus ads. Please use adblocker. I would consider to subscribe to 'pro' version of Disqus if the signal/noise ratio in comments would be good enough.