Understanding "/24" in "192.168.0.0/24"

By Liu Zuo LinLast updated
Understanding "/24" in "192.168.0.0/24"

I'm dealing with this at work right now, and it was really unintuitive for me at first.

So, I'm breaking it down as much as possible for those of you who might not be very familiar with IP addresses.

192.168.0.0

192.168.0.0 is just an ip address :)

Suffix with / and a number

  • 192.168.0.0/32 is a range of IP addresses
  • 192.168.0.0/31 is also a range of IP addresses
  • 192.168.0.0/30 is also a range of IP addresses
  • 192.168.0.0/29 is also a range of IP addresses
  • 192.168.0.0/28 is also a range of IP addresses
  • and so on

The number we put after the / ranges from 0 to 32

Finding the IPs inside this range

Let's first find the number of IP addresses inside this range.

Let's say we have 192.168.0.0/30:

number of ip addresses = 2 ^ (32–30)
which is 2 ^ 2 = 4
The ip addresses are thus 192.168.0.0, 192.168.0.1, 192.168.0.2 and 192.168.0.3

Let's say we have 192.168.0.0/29:

number of ip addresses = 2 ^ (32–29)
which is 2 ^ 3 = 8
The ip addresses are thus 192.168.0.0, 192.168.0.1, 192.168.0.2 … 192.168.0.7

Let's say we have 192.168.0.1/28:

number of ip address = 2 ^ (32–28)
which is 2 ^ 4 = 16
The ip addresses are thus 192.168.0.0, 192.168.0.1, 192.168.0.2 … 192.168.0.15

Note — I find this notation strange and unintuitive, but since it's widely used in the industry, I guess it's not my place to challenge it.

Finding the IP ranges using Python

We can automatically do this using the built-in ipaddress module

import ipaddress
from pprint import pprint

x = list(ipaddress.ip_network('192.168.0.0/30', False))

# there are 4 ip addresses in this range
pprint(x)

'''
[IPv4Address('192.168.0.0'),
IPv4Address('192.168.0.1'),
IPv4Address('192.168.0.2'),
IPv4Address('192.168.0.3')]
'''

^ the False argument turns off strict mode (which causes an error)

import ipaddress

x = list(ipaddress.ip_network('192.168.0.0/28', False))

from pprint import pprint

# there are 16 ip addresses in this range
pprint(x)

'''
[IPv4Address('192.168.0.0'),
 IPv4Address('192.168.0.1'),
 IPv4Address('192.168.0.2'),
 IPv4Address('192.168.0.3'),
 IPv4Address('192.168.0.4'),
 IPv4Address('192.168.0.5'),
 IPv4Address('192.168.0.6'),
 IPv4Address('192.168.0.7'),
 IPv4Address('192.168.0.8'),
 IPv4Address('192.168.0.9'),
 IPv4Address('192.168.0.10'),
 IPv4Address('192.168.0.11'),
 IPv4Address('192.168.0.12'),
 IPv4Address('192.168.0.13'),
 IPv4Address('192.168.0.14'),
 IPv4Address('192.168.0.15')]
'''

The "/24" in "192.168.0.0/24"

number of ip addresses = 2 ^ (32–24)
which is 2 ^ 8 = 256
import ipaddress

x = list(ipaddress.ip_network('192.168.0.0/24', False))

from pprint import pprint
pprint(x)

'''
[IPv4Address('192.168.0.0'),
 IPv4Address('192.168.0.1'),
 IPv4Address('192.168.0.2'),
 IPv4Address('192.168.0.3'),
 IPv4Address('192.168.0.4'),
 IPv4Address('192.168.0.5'),
 IPv4Address('192.168.0.6'),
 IPv4Address('192.168.0.7'),
 IPv4Address('192.168.0.8'),
 IPv4Address('192.168.0.9'),
 IPv4Address('192.168.0.10'),
 IPv4Address('192.168.0.11'),
 IPv4Address('192.168.0.12'),
 IPv4Address('192.168.0.13'),
 IPv4Address('192.168.0.14'),
 IPv4Address('192.168.0.15'),
 IPv4Address('192.168.0.16'),
 IPv4Address('192.168.0.17'),
 IPv4Address('192.168.0.18'),
 IPv4Address('192.168.0.19'),
 IPv4Address('192.168.0.20'),
 IPv4Address('192.168.0.21'),
 IPv4Address('192.168.0.22'),
 IPv4Address('192.168.0.23'),
 IPv4Address('192.168.0.24'),
 IPv4Address('192.168.0.25'),
 IPv4Address('192.168.0.26'),
 IPv4Address('192.168.0.27'),
 IPv4Address('192.168.0.28'),
 IPv4Address('192.168.0...,
 IPv4Address('192.168.0.224'),
 IPv4Address('192.168.0.225'),
 IPv4Address('192.168.0.226'),
 IPv4Address('192.168.0.227'),
 IPv4Address('192.168.0.228'),
 IPv4Address('192.168.0.229'),
 IPv4Address('192.168.0.230'),
 IPv4Address('192.168.0.231'),
 IPv4Address('192.168.0.232'),
 IPv4Address('192.168.0.233'),
 IPv4Address('192.168.0.234'),
 IPv4Address('192.168.0.235'),
 IPv4Address('192.168.0.236'),
 IPv4Address('192.168.0.237'),
 IPv4Address('192.168.0.238'),
 IPv4Address('192.168.0.239'),
 IPv4Address('192.168.0.240'),
 IPv4Address('192.168.0.241'),
 IPv4Address('192.168.0.242'),
 IPv4Address('192.168.0.243'),
 IPv4Address('192.168.0.244'),
 IPv4Address('192.168.0.245'),
 IPv4Address('192.168.0.246'),
 IPv4Address('192.168.0.247'),
 IPv4Address('192.168.0.248'),
 IPv4Address('192.168.0.249'),
 IPv4Address('192.168.0.250'),
 IPv4Address('192.168.0.251'),
 IPv4Address('192.168.0.252'),
 IPv4Address('192.168.0.253'),
 IPv4Address('192.168.0.254'),
 IPv4Address('192.168.0.255')]
'''

^ that's a lot of IP addresses

Conclusion

I won’t dive into the theory behind IP addresses and what they represent (that would take a few more articles), but I hope this was helpful and easy to understand.

Keep reading

More posts tagged “Community”.
Understanding the Format of Cron Job Schedules

Cron jobs are an essential tool for automating repetitive tasks on Unix-like operating systems. They enable users to schedule scripts or commands to run at specified times and intervals, making system maintenance, data backups, and other routine tasks more manageable. Understanding the format of a cron job schedule is crucial for effectively utilizing this powerful feature.

Tue, Jul 30, 2024
How to use cursor mcp servers for solo founder workflows in 2026

As a solo founder juggling product development, customer support, and growth, every hour counts. You're probably already using AI coding assistants like Cursor to ship faster, but are you leveraging the full power of Model Context Protocol (MCP) servers to automate your entire development workflow?

Sat, Feb 14, 2026
What is CORS?

There are millions of articles explaining how to fix the error above, but what exactly is this “Cross-Origin Resource Sharing” (CORS) thing, and why does it even exist?

Wed, Jul 17, 2024
Using JSON Web Token to authenticate users

How to use JWT with real-world examples

Tue, Jul 9, 2024
App secrets: 7 best practices for API key management in 2026

A practical guide to managing API keys, database passwords, and other credentials in production. Covers git hygiene, environment separation, secret managers, rotation strategies, least-privilege scoping, runtime injection, and monitoring — with a phased rollout plan for small teams.

Wed, May 6, 2026
Fixing "Cannot find module lightningcss.linux-x64-gnu.node" on Linux

Why generating package-lock.json on macOS silently breaks your Linux builds — and two ways to fix it.

Thu, Mar 19, 2026
Be first in line for updates
and special pricing
Get early access to new features and exclusive discounts delivered straight to your inbox