Loading network utility...
Loading network utility...
Calculating IPv4 subnet masks, network identifiers, broadcast boundaries, and usable host scopes by hand is a foundational skill for network engineers, sysadmins, and certification candidates. The Magic Number method transforms complex binary conversions into simple decimal mental arithmetic.
Run live checks and calculations directly on LotsofNetwork.
Every IPv4 address consists of four 8-bit octets. When subnetting, three of the four octets in a subnet mask are almost always either binary all-ones (decimal 255) or binary all-zeros (decimal 0).
The 'Interesting Octet' is the single octet in the subnet mask where the boundary between network bits and host bits actually occurs — the octet containing a value other than 255 or 0 (such as 128, 192, 224, 240, 248, 252, 254).
All subnet calculations (discovering the Network ID, Broadcast Address, and Host Range) take place exclusively inside this Interesting Octet. The other octets remain completely unchanged.
The Magic Number represents the block size — the exact increment by which subnets advance across the address space within the interesting octet.
The mathematical formula is: Magic Number = 256 - (Subnet Mask Value in the Interesting Octet).
For example, in a /27 subnet, the subnet mask is 255.255.255.224. The 4th octet contains 224. The Magic Number is: 256 - 224 = 32. Therefore, subnets in this network step in increments of 32 (.0, .32, .64, .96, .128, .160, .192, .224).
| CIDR Prefix | Subnet Mask Octet | Borrowed Bits | Magic Number (Block Size) | Subnets per /24 | Usable Hosts |
|---|---|---|---|---|---|
| /25 | 128 | 1 bit | 128 | 2 subnets | 126 hosts |
| /26 | 192 | 2 bits | 64 | 4 subnets | 62 hosts |
| /27 | 224 | 3 bits | 32 | 8 subnets | 30 hosts |
| /28 | 240 | 4 bits | 16 | 16 subnets | 14 hosts |
| /29 | 248 | 5 bits | 8 | 32 subnets | 6 hosts |
| /30 | 252 | 6 bits | 4 | 64 subnets | 2 hosts |
Let us calculate the Network Address, Usable Host Range, and Broadcast Address for 172.16.45.100/20 completely by hand:
Step 1: Locate the interesting octet. A /20 prefix means 20 network bits. The first 16 bits cover octets 1 and 2 (255.255). The remaining 4 bits fall into the 3rd octet. The subnet mask is 255.255.240.0. The 3rd octet (240) is the interesting octet.
Step 2: Calculate the Magic Number: 256 - 240 = 16. Subnets increment by 16 in the 3rd octet.
Step 3: Count multiples of 16 in the 3rd octet until reaching the target value (45): 0, 16, 32, 48. Since 45 falls between 32 and 47, the Network ID is 172.16.32.0.
Step 4: The next subnet starts at 172.16.48.0. One IP before that is the broadcast address: 172.16.47.255.
Step 5: Usable hosts reside strictly between the Network ID and Broadcast Address: 172.16.32.1 through 172.16.47.254 (4,094 usable endpoints).
Target Host IP: 172.16.45.100/20 Subnet Mask: 255.255.240.0 Interesting Octet: 3rd Octet (Value: 45, Mask: 240) Magic Number: 256 - 240 = 16 Subnet Boundaries: Network ID: 172.16.32.0 (First IP, reserved) First Usable Host: 172.16.32.1 Last Usable Host: 172.16.47.254 Broadcast Address: 172.16.47.255 (Last IP, reserved) Total Addresses: 4,096 | Usable: 4,094 hosts
In production enterprise and cloud design, Variable Length Subnet Masking (VLSM) allows architects to assign different subnet masks to different subnets within the same overall address space.
Best Practice Rule: Always allocate your largest subnets first, ordered from largest capacity to smallest capacity. For example, if you have a /24 block and need subnets of 60 hosts, 25 hosts, and 2 point-to-point links, allocate the /26 (62 hosts) at the beginning, followed by the /27 (30 hosts), and finally the /30 or /31 links at the end to prevent fragmentation.
AI Mobile App Developer & Full-Stack Systems Engineer•Dhaka, Bangladesh
Bayajit Islam is an AI Mobile App Developer and Full-Stack Systems Engineer based in Dhaka, Bangladesh. With 2+ years of hands-on production experience building cross-platform apps for iOS, Android & Desktop with Flutter & Dart, asynchronous backends with FastAPI & Python, and modern web applications with Next.js, TypeScript, and Docker, he engineered LotsofNetwork as a zero-latency, privacy-first diagnostic platform for developers and network administrators.
Quick answers to common questions on this topic.
High-speed, zero-cost engineering tools built for network diagnostics and developer workflows.
Detect IP, GeoIP, ISP, ASN & PTR
Reverse IP to PTR hostname & verify FCrDNS
Query A, AAAA, MX, TXT & NS records
Domain registrar & expiry info
Audit SPF, DKIM & DMARC records
Check global DNS record propagation across Anycast resolvers