In modern networking, understanding how IP addresses are structured, allocated, and routed is crucial for software engineers, systems administrators, and DevOps practitioners. This guide breaks down the core concepts of IP subnetting, Classless Inter-Domain Routing (CIDR), and the underlying mathematical operations that make networking tick.
Whether you are configuring cloud VPC security groups, troubleshooting router rules, or setting up host firewalls, these concepts form the foundation of secure and efficient infrastructure.
What is an IP Address?
An IPv4 address is a 32-bit numeric identifier assigned to every device connected to an IP network. For human readability, we express these 32 bits as four decimal numbers separated by dots (e.g., 192.168.1.1). Each of these four numbers is called an octet because it represents exactly 8 bits.
- Decimal Representation:
192.168.1.1 - Binary Representation:
11000000.10101000.00000001.00000001
An IP address consists of two distinct segments:
- Network ID: Identifies the specific network or subnetwork.
- Host ID: Identifies the unique device (or interface) on that network.
To divide these segments, networks use a subnet mask.
Subnet Masks Explained
A subnet mask is also a 32-bit sequence, composed of consecutive 1s followed by consecutive 0s. The 1s define the network portion of the address, while the 0s define the host portion.
For example, a subnet mask of 255.255.255.0 in binary is:
11111111.11111111.11111111.00000000 (24 ones and 8 zeros).
When paired with 192.168.1.50, this mask indicates:
- Network ID:
192.168.1.0 - Host ID:
.50
What is CIDR Notation?
Before CIDR (Classless Inter-Domain Routing) was introduced in 1993, IP addresses were allocated in rigid “classes” (Class A, B, and C), which led to massive inefficiencies. CIDR replaced classful networks with a flexible routing suffix system.
CIDR notation appends a slash (/) and a decimal number to the IP address. The number denotes the count of network-identifying bits (the number of leading 1s in the subnet mask).
192.168.1.0/24means the first 24 bits are the network ID, which corresponds to the mask255.255.255.0.10.0.0.0/16means the first 16 bits are the network ID, corresponding to255.255.0.0.10.0.0.0/8means the first 8 bits are the network ID, corresponding to255.0.0.0.
Calculating Subnet Details Mathematically
Let’s calculate the details of a subnet block: 192.168.10.34/26.
- Subnet Mask: A
/26prefix means 26 ones and 6 zeros.11111111.11111111.11111111.11000000=255.255.255.192 - Total Hosts: The formula is
2^(32 - prefix). Here,2^(32-26) = 2^6 = 64addresses. - Usable Hosts: We must subtract
2from the total hosts.- Network Address: The first address in the block (all host bits are
0). Used to represent the subnet itself. - Broadcast Address: The last address in the block (all host bits are
1). Used to send data to all hosts on the subnet. - Formula:
2^(32 - prefix) - 2. In our example,64 - 2 = 62usable hosts.
- Network Address: The first address in the block (all host bits are
- Network Address: Match the IP against the mask using a bitwise AND operation.
- IP
34in binary is00100010. - Mask
192in binary is11000000. 00100010AND11000000=00000000=0- Network Address:
192.168.10.0.
- IP
- Usable IP Range:
192.168.10.1to192.168.10.62. - Broadcast Address: Set all 6 host bits to
1.00000000OR00111111=00111111=63- Broadcast Address:
192.168.10.63.
Simplify with Interactive Calculators
Doing binary math by hand is useful for certifications, but in everyday cloud and infrastructure engineering, automation is preferred. We have developed two high-performance tools to run these calculations safely and instantly inside your browser:
- IP Subnet Calculator: Enter an IP address and a subnet mask to instantly inspect host counts, usable ranges, the broadcast address, and class indicators. Excellent for corporate segment divisions.
- CIDR Calculator: Input CIDR blocks to retrieve full CIDR allocation details, IP ranges, bitmask boundaries, and binary visualizations. Perfect for VPC and firewall rule planning.
By keeping these calculations local inside client-side memory, these tools ensure that your corporate IP schemas and internal networking plans are never uploaded to a remote server.