Calculate subnet masks, network addresses, broadcast addresses, and usable host ranges for IPv4 and IPv6. CIDR notation support.
Subnetting divides large networks into smaller, manageable segments. Benefits include:
Reduced broadcast traffic (better performance)
Improved security (segment isolation)
Simplified troubleshooting
Efficient IP address allocation
Better network organization
/30 — 4 IPs (2 usable) - Point-to-point
/29 — 8 IPs (6 usable) - Tiny network
/28 — 16 IPs - Very small network
/27 — 32 IPs - Small department
/24 — 256 IPs - Standard LAN
/16 — 65K IPs - Large enterprise
VLSM allows using different subnet masks within the same network to optimize IP address usage. Instead of using one /24 for all subnets, you can allocate /28 for small departments and /25 for large ones. Learn why VLSM is better than fixed-length subnetting.
Example: Company with 200 Employees
Main office (150 users): 192.168.1.0/24 (254 hosts)
Branch 1 (25 users): 192.168.2.0/27 (30 hosts)
Branch 2 (15 users): 192.168.2.32/28 (14 hosts)
Point-to-point links: 192.168.2.48/30, 192.168.2.52/30
VLSM saves IP addresses by right-sizing subnets to actual needs instead of allocating /24 everywhere.
Plan IP addressing for new networks. Calculate required subnet sizes for different departments, VLANs, or locations. Ensure no overlap and efficient use of address space. Document IP allocation for future reference.
Use CIDR notation in firewall rules and ACLs. The Range Merger helps consolidate rules to reduce rule count, improve performance, and simplify management. Fewer rules = easier troubleshooting.
Summarize multiple routes into fewer routing table entries. This reduces router memory usage, speeds up routing lookups, and minimizes BGP update traffic. Essential for large networks and ISPs.
Plan VPC/VNet subnets in AWS, Azure, or GCP. Allocate CIDR blocks for different environments (dev, staging, prod), availability zones, and service tiers. Avoid overlaps for VPC peering or VPNs.
Subnet calculation divides an IP network into smaller, more manageable sub-networks (subnets) by manipulating the subnet mask. Subnetting is fundamental to IP network design, allowing administrators to control broadcast domains, improve security through segmentation, and efficiently allocate IP addresses. Every network engineer, system administrator, and cloud architect needs to understand subnetting.
An IP address has two parts: the network portion (identifying the subnet) and the host portion (identifying the device within that subnet). The subnet mask determines where this boundary falls. A larger network prefix means more subnets with fewer hosts each; a smaller prefix means fewer subnets with more hosts. Getting this calculation right is essential for preventing IP conflicts, optimizing routing, and meeting security requirements.
IPv4 addresses are 32 bits long, written as four octets in dotted decimal notation. The subnet mask (also expressed in CIDR notation) defines the network boundary:
| CIDR | Subnet Mask | Network Bits | Host Bits | Usable Hosts |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 24 | 8 | 254 |
| /25 | 255.255.255.128 | 25 | 7 | 126 |
| /26 | 255.255.255.192 | 26 | 6 | 62 |
| /27 | 255.255.255.224 | 27 | 5 | 30 |
| /28 | 255.255.255.240 | 28 | 4 | 14 |
| /29 | 255.255.255.248 | 29 | 3 | 6 |
| /30 | 255.255.255.252 | 30 | 2 | 2 |
| /16 | 255.255.0.0 | 16 | 16 | 65,534 |
Key formulas:
Example: Splitting 192.168.1.0/24 into four subnets requires borrowing 2 bits (2^2 = 4 subnets), creating /26 subnets with 62 usable hosts each:
Subnetting is the practice of dividing a network into smaller sub-networks (subnets) for better management, security, and efficiency. Key benefits: (1) Efficient IP allocation - Reduces IP waste by sizing subnets to actual needs. (2) Network segmentation - Separates departments, devices, or security zones. (3) Improved performance - Reduces broadcast traffic within smaller networks. (4) Enhanced security - Isolates sensitive systems, limits attack surface. (5) Organized management - Logical network structure mirrors organizational structure. Example: A /24 network (192.168.1.0/24) with 254 hosts can be split into 4 /26 subnets (62 hosts each), allowing separate networks for Sales, Engineering, HR, and Guest WiFi. Modern networks use CIDR (Classless Inter-Domain Routing) instead of the old class-based system (Class A, B, C).
CIDR (Classless Inter-Domain Routing) notation is a compact way to represent IP addresses and their routing prefix. Format: IP_ADDRESS/PREFIX_LENGTH. The prefix length (number after /) indicates how many bits are used for the network portion. Examples: 192.168.1.0/24 - /24 means first 24 bits are network (192.168.1), last 8 bits are hosts (0-255), 254 usable hosts. 10.0.0.0/8 - /8 means first 8 bits are network (10), last 24 bits are hosts, 16,777,214 usable hosts (Class A). 172.16.0.0/12 - /12 means first 12 bits are network, 1,048,574 usable hosts. Common Subnet Sizes: /32 - Single host (1 IP), /30 - Point-to-point links (2 usable), /29 - Small subnet (6 usable), /24 - Standard subnet (254 usable), /16 - Large subnet (65,534 usable). The smaller the prefix length, the larger the subnet. /24 is smaller than /16, but /25 is smaller than /24.
Subnet masks define the network and host portions of an IP address. Manual calculation: Step 1: Convert prefix to subnet mask - /24 → 255.255.255.0 (24 ones, 8 zeros in binary). Step 2: Binary representation - /26 = 11111111.11111111.11111111.11000000 = 255.255.255.192. Step 3: Calculate usable hosts - 2^(host bits) - 2 (subtract network and broadcast addresses). Step 4: Find network boundaries - Network address: IP AND subnet mask, Broadcast: All host bits set to 1, First usable: Network + 1, Last usable: Broadcast - 1. Common Subnet Masks: /30 = 255.255.255.252 (2 usable), /29 = 255.255.255.248 (6 usable), /28 = 255.255.255.240 (14 usable), /27 = 255.255.255.224 (30 usable), /26 = 255.255.255.192 (62 usable), /25 = 255.255.255.128 (126 usable), /24 = 255.255.255.0 (254 usable). Pro tip: Learn common masks by memory for faster network planning.
Private IP address ranges are reserved for internal networks and cannot be routed on the public Internet. Defined in RFC 1918: 10.0.0.0/8 (Class A) - 10.0.0.0 to 10.255.255.255, 16,777,216 addresses, used by large enterprises. 172.16.0.0/12 (Class B) - 172.16.0.0 to 172.31.255.255, 1,048,576 addresses, common in medium organizations. 192.168.0.0/16 (Class C) - 192.168.0.0 to 192.168.255.255, 65,536 addresses, typical for home/small office. When to use: Internal company networks, Home networks, Development/testing environments, Private cloud infrastructure. Connectivity: Devices use NAT (Network Address Translation) to access Internet through a public IP, Multiple devices share one public IP, Provides basic security (not directly accessible from Internet). IPv6 equivalent: fc00::/7 (Unique Local Addresses), but IPv6's massive address space reduces need for private ranges. Always use private IPs internally and reserve public IPs only for Internet-facing services.
Every subnet contains special-purpose addresses: Network Address - First IP in subnet, identifies the network itself (e.g., 192.168.1.0/24 → 192.168.1.0), cannot be assigned to hosts, all host bits are 0, used in routing tables. Broadcast Address - Last IP in subnet, sends packets to all hosts in subnet (e.g., 192.168.1.0/24 → 192.168.1.255), cannot be assigned to hosts, all host bits are 1, used for network-wide announcements. Usable IP Range - All IPs between network and broadcast, can be assigned to hosts/devices (e.g., 192.168.1.0/24 → 192.168.1.1 to 192.168.1.254), total usable = 2^(host bits) - 2. Example: 192.168.1.0/26 - Network: 192.168.1.0, First usable: 192.168.1.1, Last usable: 192.168.1.62, Broadcast: 192.168.1.63, Total usable: 62 hosts. Special case /31 and /32: /32 (single host) - Only one IP, used for loopback or specific host routes. /31 (point-to-point links) - RFC 3021 allows 2 usable IPs without network/broadcast for router links.
When subnetting for departmentsor VLANs, follow this planning process: Step 1: Determine requirements - How many subnets needed?, Hosts per subnet?, Future growth (add 30-50% capacity). Step 2: Choose subnet size - Sales: 40 users → /26 (62 hosts), Engineering: 100 users → /25 (126 hosts), HR: 15 users → /27 (30 hosts), Guest WiFi: 50 devices → /26 (62 hosts). Step 3: Assign non-overlapping ranges - Sales: 192.168.1.0/26 (192.168.1.1-62), Engineering: 192.168.1.64/25 (192.168.1.65-190), HR: 192.168.1.192/27 (192.168.1.193-222), Guest: 192.168.2.0/26 (192.168.2.1-62). Step 4: Document and implement - Create IP allocation spreadsheet, Configure VLANs on switches, Set up DHCP scopes, Implement inter-VLAN routing, Apply security policies (ACLs). Best practices: Align subnets with VLANs 1:1, Use meaningful VLAN IDs (Sales=VLAN 10), Leave room for growth, Keep documentation updated.
VLSM (Variable Length Subnet Masking) allows using different subnet sizes within the same network, unlike fixed-length subnetting where all subnets are the same size. Traditional Fixed-Length (wasteful): Divide 192.168.1.0/24 into 4 equal /26 subnets (62 hosts each), Small HR department (10 users) wastes 52 IPs, Large Engineering (100 users) doesn't fit. VLSM (efficient): Engineering: 192.168.1.0/25 (126 hosts) - perfect fit, Sales: 192.168.1.128/26 (62 hosts), HR: 192.168.1.192/27 (30 hosts), Management: 192.168.1.224/28 (14 hosts), Point-to-point links: 192.168.1.240/30 (2 hosts each). Benefits: Reduces IP waste, Right-sizes subnets to actual needs, Maximizes address utilization, Essential for ISPs and large organizations. VLSM Rules: Assign largest subnets first, Ensure no overlap, Align subnet boundaries properly (network addresses must fall on subnet boundaries). VLSM requires careful planning but dramatically improves IP efficiency in complex networks.
IPv6 subnetting is simpler but fundamentally different from IPv4 due to the massive address space: Address Space: IPv4: 32 bits (4.3 billion addresses), IPv6: 128 bits (340 undecillion addresses - effectively unlimited). Standard Allocation: IPv4: Organizations receive /8 to /24, conserve carefully, use VLSM and NAT. IPv6: Organizations receive /32 or /48, allocate /64 to every subnet (18 quintillion addresses per subnet!). Subnet Structure: IPv4: Variable subnet sizes (/30 to /8), carefully calculated. IPv6: Almost always /64 for end networks (SLAAC requirement), /48 for organizations (65,536 /64 subnets), /56 for small sites (256 /64 subnets). Key Differences: No broadcast addresses in IPv6 (uses multicast), No NAT needed (every device gets public IP), No need for private ranges (ample public addresses), Simpler subnetting (just assign /64s). Example IPv6 Allocation: ISP gives company 2001:db8:1234::/48, IT creates subnets: Sales: 2001:db8:1234:10::/64, Engineering: 2001:db8:1234:20::/64, WiFi: 2001:db8:1234:30::/64. The simplification comes from abundance - stop conserving and use /64 everywhere.