Loading learning content...
Understanding the concepts of contiguity and aggregation is essential, but network engineers need practical calculation skills to apply supernetting in real scenarios. When reviewing a routing table, configuring route summarization, or planning address allocations, you need to quickly determine:\n\n- What aggregate prefix covers a given set of networks?\n- How many addresses does the supernet include?\n- What are the first and last addresses in the summarized range?\n- Is this set of networks even aggregatable?\n\nThis page develops your supernet calculation skills from fundamentals to rapid mental computation. By the end, you'll be able to calculate supernets confidently—essential knowledge for network design, troubleshooting, and certification exams.
By the end of this page, you will master: (1) The complete step-by-step supernet calculation algorithm, (2) How to find the common prefix using binary AND operations, (3) Quick techniques for calculating supernets without full binary conversion, (4) Working with supernets of various sizes from /23 to /8, and (5) Validation methods to verify your calculations are correct. These are practical skills you'll use throughout your networking career.
Supernet calculation follows a systematic algorithm that works for any set of aggregatable networks. Here's the complete process:
SUPERNET CALCULATION ALGORITHM═══════════════════════════════════════════════════════════════════════════════ INPUT: A set of network addresses to aggregateOUTPUT: The supernet prefix that covers all input networks ALGORITHM:───────────────────────────────────────────────────────────────────────────── Step 1: VALIDATE CONTIGUITY • Sort all networks by their first address • Verify each network's last address + 1 equals the next network's first • If gaps exist → Cannot create single supernet (may need multiple) Step 2: COUNT TOTAL ADDRESSES • Sum the addresses in all networks • For each /n network: addresses = 2^(32-n) • Example: /24 = 256, /25 = 128, /26 = 64 addresses Step 3: VERIFY POWER OF TWO • Total must equal 2^k for some integer k • If not power of two → Cannot create single supernet • Quick check: (total) AND (total - 1) == 0 Step 4: CALCULATE SUPERNET PREFIX LENGTH • Supernet prefix = 32 - log₂(total addresses) • Alternatively: Supernet prefix = 32 - k (where total = 2^k) • Example: 1024 addresses = 2^10 → prefix = 32 - 10 = /22 Step 5: VERIFY ALIGNMENT • Convert first network address to decimal • Check: first_address MOD total_addresses == 0 • If not zero → First address not aligned, cannot aggregate Step 6: CONSTRUCT SUPERNET • Supernet address = first network address (already aligned) • Supernet mask = /prefix_length (from Step 4) • Result: address/prefix Step 7: VALIDATE (Optional but recommended) • Calculate supernet range (first and last address) • Verify all original networks fall within this range • Verify no non-owned addresses are includedSupernetting essentially works in reverse from subnetting. Where subnetting adds bits to the network portion (making it longer), supernetting removes bits from the network portion (making it shorter). Each bit removed doubles the address space covered.
Let's work through a complete supernet calculation with networks of equal size—the most common scenario in practice.\n\nProblem: Calculate the supernet for these eight /24 networks:\n- 10.50.8.0/24\n- 10.50.9.0/24\n- 10.50.10.0/24\n- 10.50.11.0/24\n- 10.50.12.0/24\n- 10.50.13.0/24\n- 10.50.14.0/24\n- 10.50.15.0/24
SUPERNET CALCULATION: Eight /24 Networks═══════════════════════════════════════════════════════════════════════════════ Step 1: VALIDATE CONTIGUITY─────────────────────────────────────────────────────────────────────────────Networks (already sorted by third octet): 10.50.8.0/24 → ends at 10.50.8.255 10.50.9.0/24 → ends at 10.50.9.255 10.50.10.0/24 → ends at 10.50.10.255 10.50.11.0/24 → ends at 10.50.11.255 10.50.12.0/24 → ends at 10.50.12.255 10.50.13.0/24 → ends at 10.50.13.255 10.50.14.0/24 → ends at 10.50.14.255 10.50.15.0/24 → ends at 10.50.15.255 Third octet sequence: 8, 9, 10, 11, 12, 13, 14, 15 ✓ CONTIGUOUS Step 2: COUNT TOTAL ADDRESSES───────────────────────────────────────────────────────────────────────────── 8 networks × 256 addresses each = 2,048 addresses Step 3: VERIFY POWER OF TWO───────────────────────────────────────────────────────────────────────────── 2,048 = 2^11 ✓ (Power of two) Binary check: 2048 = 100000000000 (binary) 2047 = 011111111111 (binary) 2048 AND 2047 = 0 ✓ Step 4: CALCULATE SUPERNET PREFIX LENGTH───────────────────────────────────────────────────────────────────────────── Prefix = 32 - log₂(2048) = 32 - 11 = 21 Supernet will be a /21 Step 5: VERIFY ALIGNMENT───────────────────────────────────────────────────────────────────────────── First address: 10.50.8.0 Quick alignment check for /21 (aggregating 8 /24s): Third octet (8) must be divisible by 8. 8 ÷ 8 = 1.0 ✓ (Whole number, aligned!) Full verification: 10.50.8.0 in decimal = 10×2^24 + 50×2^16 + 8×2^8 + 0 = 167,772,160 + 3,276,800 + 2,048 + 0 = 171,051,008 171,051,008 MOD 2,048 = 0 ✓ (Aligned!) Step 6: CONSTRUCT SUPERNET───────────────────────────────────────────────────────────────────────────── Supernet address: 10.50.8.0 Supernet prefix: /21 RESULT: 10.50.8.0/21 Step 7: VALIDATE───────────────────────────────────────────────────────────────────────────── /21 supernet range: • First address: 10.50.8.0 • Last address: 10.50.8.0 + 2047 = 10.50.15.255 Original networks covered: • 10.50.8.0/24 through 10.50.15.0/24 ✓ All within range No extra addresses included (only .8 through .15 in third octet) ═══════════════════════════════════════════════════════════════════════════════FINAL ANSWER: 10.50.8.0/21═══════════════════════════════════════════════════════════════════════════════When aggregating /24 networks: 2 /24s = /23, 4 /24s = /22, 8 /24s = /21, 16 /24s = /20, 32 /24s = /19, 64 /24s = /18, 128 /24s = /17, 256 /24s = /16. Each doubling of networks decreases the prefix by 1.
The most reliable method for finding a supernet is to identify the common prefix through binary analysis. This method works for any combination of networks, regardless of their original prefix lengths.\n\nThe Binary AND Method:\n\n1. Convert all network addresses to 32-bit binary\n2. Perform bitwise AND on all addresses\n3. Compare result with addresses to find where bits start differing\n4. The common prefix length is where the first difference occurs
FINDING COMMON PREFIX USING BINARY═══════════════════════════════════════════════════════════════════════════════ Example: Find supernet for 192.168.4.0/24, 192.168.5.0/24, 192.168.6.0/24, 192.168.7.0/24 Step 1: Convert to Binary─────────────────────────────────────────────────────────────────────────────192.168.4.0: 11000000.10101000.00000100.00000000192.168.5.0: 11000000.10101000.00000101.00000000192.168.6.0: 11000000.10101000.00000110.00000000192.168.7.0: 11000000.10101000.00000111.00000000 Step 2: Find Where Bits Match───────────────────────────────────────────────────────────────────────────── ↓↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓↓ ↓↓↓↓↓|←─ bits differ here192.168.4.0: 11000000.10101000.000001|00.00000000192.168.5.0: 11000000.10101000.000001|01.00000000192.168.6.0: 11000000.10101000.000001|10.00000000192.168.7.0: 11000000.10101000.000001|11.00000000 └───────────────────────┘ First 22 bits match Step 3: Count Matching Bits───────────────────────────────────────────────────────────────────────────── Octet 1: 8 bits match (total: 8) Octet 2: 8 bits match (total: 16) Octet 3: 6 bits match (total: 22) Common prefix length = 22 bits → /22 Step 4: Extract Supernet Address───────────────────────────────────────────────────────────────────────────── Keep the first 22 common bits, zero the rest: 11000000.10101000.000001|00.00000000 ↑ bit 23 and beyond are host bits (set to 0) = 192.168.4.0 RESULT: 192.168.4.0/22 ═══════════════════════════════════════════════════════════════════════════════ VERIFICATION: /22 covers: 192.168.4.0 through 192.168.7.255 (1024 addresses) Third octet range: 4, 5, 6, 7 (binary: 100, 101, 110, 111) These are exactly the 4 values where the upper 6 bits = 000001Alternative: XOR Method\n\nAnother approach uses XOR (exclusive OR) to find differing bits:
XOR METHOD FOR COMMON PREFIX═══════════════════════════════════════════════════════════════════════════════ XOR the first and last addresses (covers the full range) First: 192.168.4.0 = 11000000.10101000.00000100.00000000Last: 192.168.7.255 = 11000000.10101000.00000111.11111111 XOR: 00000000.00000000.00000011.11111111 └───────────────┘└────────────────┘ All zeros (22) Non-zero (10) The leftmost zero bits in the XOR result = common prefix lengthCount leading zeros: 22 RESULT: /22 prefix The supernet address is the first address with host bits zeroed:192.168.4.0/22Binary analysis is most useful when: (1) Networks have mixed prefix lengths, (2) You need to verify an aggregate is correct, (3) The relationship between networks isn't obvious, (4) You're solving exam problems where showing work is required. For routine equal-sized /24 aggregation, the quick methods in the next section are faster.
For common supernetting scenarios, especially aggregating equal-sized /24 networks, quick mental calculation techniques can dramatically speed up your work.\n\nTechnique 1: The Block Size Method\n\nWhen aggregating N /24 networks (where N is a power of 2):\n1. Supernet prefix = 24 - log₂(N)\n2. Starting third octet must be divisible by N
of /24s | Supernet Prefix | Third Octet Divisor | Block Size (Addresses) |
|---|---|---|---|
| 2 | /23 | 2 | 512 |
| 4 | /22 | 4 | 1,024 |
| 8 | /21 | 8 | 2,048 |
| 16 | /20 | 16 | 4,096 |
| 32 | /19 | 32 | 8,192 |
| 64 | /18 | 64 | 16,384 |
| 128 | /17 | 128 | 32,768 |
| 256 | /16 | 256 (next octet) | 65,536 |
Technique 2: Third Octet Block Boundaries\n\nFor /24 aggregation, memorize the natural boundaries for each supernet size:
NATURAL BLOCK BOUNDARIES FOR /24 AGGREGATION═══════════════════════════════════════════════════════════════════════════════ /23 Blocks (2 × /24): Valid third octets: 0-1, 2-3, 4-5, 6-7, 8-9, ..., 254-255 Pattern: Even numbers start blocks /22 Blocks (4 × /24): Valid third octets: 0-3, 4-7, 8-11, 12-15, 16-19, 20-23, 24-27, ... Pattern: Multiples of 4 start blocks /21 Blocks (8 × /24): Valid third octets: 0-7, 8-15, 16-23, 24-31, 32-39, ... Pattern: Multiples of 8 start blocks /20 Blocks (16 × /24): Valid third octets: 0-15, 16-31, 32-47, 48-63, 64-79, ... Pattern: Multiples of 16 start blocks /19 Blocks (32 × /24): Valid third octets: 0-31, 32-63, 64-95, 96-127, 128-159, 160-191, 192-223, 224-255 Pattern: Multiples of 32 start blocks /18 Blocks (64 × /24): Valid third octets: 0-63, 64-127, 128-191, 192-255 Pattern: Multiples of 64 start blocks /17 Blocks (128 × /24): Valid third octets: 0-127, 128-255 Pattern: 0 or 128 start blocks /16 Block (256 × /24): Entire third octet: 0-255 (single block per second octet)Technique 3: Quick Boundary Test\n\nTo test if networks can aggregate:\n1. Take the first network's third octet\n2. Divide by the number of networks\n3. If the result rounds down to a whole number, AND\n4. The last network's third octet = (whole number + 1) × count - 1\n5. Then aggregation is valid
QUICK BOUNDARY TEST EXAMPLES═══════════════════════════════════════════════════════════════════════════════ Example 1: Can 172.16.20.0/24 through 172.16.23.0/24 aggregate to /22?───────────────────────────────────────────────────────────────────────────── Count: 4 networks (20, 21, 22, 23) First octet: 20 Test: 20 ÷ 4 = 5.0 (whole number) ✓ Last octet should be: (5 + 1) × 4 - 1 = 24 - 1 = 23 ✓ RESULT: 172.16.20.0/22 ✓ Valid Example 2: Can 172.16.21.0/24 through 172.16.24.0/24 aggregate to /22?───────────────────────────────────────────────────────────────────────────── Count: 4 networks (21, 22, 23, 24) First octet: 21 Test: 21 ÷ 4 = 5.25 (not whole number) ✗ RESULT: Cannot aggregate to single /22 (misaligned) Must split: - 172.16.21.0/24 (individual) - 172.16.22.0/23 (covers .22 and .23) - 172.16.24.0/24 (individual, or start of new block) Example 3: Can 10.0.64.0/24 through 10.0.127.0/24 aggregate to /18?───────────────────────────────────────────────────────────────────────────── Count: 64 networks (64 through 127) First octet: 64 Test: 64 ÷ 64 = 1.0 (whole number) ✓ Last octet should be: (1 + 1) × 64 - 1 = 127 ✓ RESULT: 10.0.64.0/18 ✓ ValidThese quick techniques become second nature with practice. Start with the table for reference, but aim to internalize the patterns. After enough practice, you'll recognize /22 blocks (0-3, 4-7, 8-11...) and /21 blocks (0-7, 8-15...) instantly.
Real-world networks often have mixed prefix lengths. Aggregating these requires careful address counting and alignment verification.\n\nExample: Aggregating Mixed Prefixes
MIXED PREFIX LENGTH SUPERNET CALCULATION═══════════════════════════════════════════════════════════════════════════════ Given Networks: - 10.100.0.0/25 (128 addresses) - 10.100.0.128/26 (64 addresses) - 10.100.0.192/26 (64 addresses) - 10.100.1.0/24 (256 addresses) Step 1: VERIFY CONTIGUITY───────────────────────────────────────────────────────────────────────────── 10.100.0.0/25: First: 10.100.0.0 Last: 10.100.0.127 10.100.0.128/26: First: 10.100.0.128 Last: 10.100.0.191 10.100.0.192/26: First: 10.100.0.192 Last: 10.100.0.255 10.100.1.0/24: First: 10.100.1.0 Last: 10.100.1.255 Gap check: 10.100.0.127 + 1 = 10.100.0.128 ✓ 10.100.0.191 + 1 = 10.100.0.192 ✓ 10.100.0.255 + 1 = 10.100.1.0 ✓ CONTIGUOUS ✓ Step 2: COUNT TOTAL ADDRESSES───────────────────────────────────────────────────────────────────────────── 128 + 64 + 64 + 256 = 512 addresses Step 3: VERIFY POWER OF TWO───────────────────────────────────────────────────────────────────────────── 512 = 2^9 ✓ Step 4: CALCULATE SUPERNET PREFIX LENGTH───────────────────────────────────────────────────────────────────────────── Prefix = 32 - 9 = /23 Step 5: VERIFY ALIGNMENT───────────────────────────────────────────────────────────────────────────── First address: 10.100.0.0 For /23 (512 addresses), the starting address must be: - Third octet divisible by 2 (0, 2, 4, 6, ...) - Fourth octet = 0 10.100.0.0: Third octet 0 ÷ 2 = 0 ✓, Fourth octet = 0 ✓ ALIGNED ✓ Step 6: CONSTRUCT SUPERNET───────────────────────────────────────────────────────────────────────────── Supernet: 10.100.0.0/23 Range: 10.100.0.0 through 10.100.1.255 Step 7: VALIDATE───────────────────────────────────────────────────────────────────────────── /23 covers 512 addresses from 10.100.0.0 to 10.100.1.255 Original networks span: 10.100.0.0 to 10.100.1.255 ✓ Exact match! No extra addresses included ✓ ═══════════════════════════════════════════════════════════════════════════════FINAL ANSWER: 10.100.0.0/23═══════════════════════════════════════════════════════════════════════════════When Mixed Prefixes Don't Aggregate Cleanly:\n\nSometimes mixed prefixes result in a non-power-of-two total, preventing single-supernet aggregation.
MIXED PREFIXES: NON-AGGREGATABLE CASE═══════════════════════════════════════════════════════════════════════════════ Given Networks: - 172.31.100.0/24 (256 addresses) - 172.31.101.0/25 (128 addresses) - 172.31.101.128/26 (64 addresses) Step 1: VERIFY CONTIGUITY───────────────────────────────────────────────────────────────────────────── 172.31.100.255 + 1 = 172.31.101.0 ✓ 172.31.101.127 + 1 = 172.31.101.128 ✓ CONTIGUOUS ✓ Step 2: COUNT TOTAL ADDRESSES───────────────────────────────────────────────────────────────────────────── 256 + 128 + 64 = 448 addresses Step 3: VERIFY POWER OF TWO───────────────────────────────────────────────────────────────────────────── 448 = 256 + 128 + 64 = 2^8 + 2^7 + 2^6 448 is NOT a power of 2 ✗ Binary: 448 = 111000000 Check: 448 AND 447 = 111000000 AND 110111111 = 110000000 ≠ 0 RESULT: Cannot aggregate to single supernet ═══════════════════════════════════════════════════════════════════════════════BEST AGGREGATION POSSIBLE: 172.31.100.0/24 (256 addresses) - keep as is 172.31.101.0/25 (128 addresses) - keep as is 172.31.101.128/26 (64 addresses) - keep as is OR with partial aggregation: 172.31.100.0/23 would cover 172.31.100.0 - 172.31.101.255 (512 addresses) But we only own 172.31.100.0 - 172.31.101.191 (448 addresses) The range 172.31.101.192 - 172.31.101.255 (64 addresses) would be HIJACKED! DO NOT AGGREGATE - Advertise 3 separate routesWhen the mathematics don't work out, don't force aggregation. Advertising a larger prefix than you own means claiming addresses that belong to someone else. This causes routing problems and can be considered a security incident or policy violation by ISPs.
Given a supernet in CIDR notation, calculating its address range is essential for verification and planning. Here are the formulas and techniques.\n\nFormulas:
SUPERNET RANGE CALCULATION FORMULAS═══════════════════════════════════════════════════════════════════════════════ Given: Network address N and prefix length /P Total Addresses: count = 2^(32 - P) Usable Host Addresses: usable = 2^(32 - P) - 2 First Address (Network Address): first = N (by definition) Last Address (Broadcast Address): last = N + 2^(32 - P) - 1 Or in terms of subnet mask M: last = N OR (NOT M) Subnet Mask: mask = 2^32 - 2^(32 - P) Wildcard Mask (inverse of subnet mask): wildcard = 2^(32 - P) - 1Worked Examples:
RANGE CALCULATION EXAMPLES═══════════════════════════════════════════════════════════════════════════════ Example 1: 192.168.0.0/22───────────────────────────────────────────────────────────────────────────── Prefix: /22 Host bits: 32 - 22 = 10 Total addresses: 2^10 = 1,024 Usable hosts: 1,024 - 2 = 1,022 First address: 192.168.0.0 Last address: 192.168.0.0 + 1,023 = 192.168.3.255 Calculation breakdown for last address: Last octet: 0 + 255 = 255 (with carry) Third octet: 0 + 3 = 3 (1023 = 3×256 + 255) Subnet mask: 255.255.252.0 (252 = 256 - 4 = 256 - 2^2, and 2^2 comes from the 2 borrowed bits) Wildcard mask: 0.0.3.255 ═══════════════════════════════════════════════════════════════════════════════ Example 2: 10.50.8.0/21───────────────────────────────────────────────────────────────────────────── Prefix: /21 Host bits: 32 - 21 = 11 Total addresses: 2^11 = 2,048 Usable hosts: 2,048 - 2 = 2,046 First address: 10.50.8.0 Last address: 10.50.8.0 + 2,047 = 10.50.15.255 Calculation breakdown: 2,047 = 7×256 + 255 Third octet: 8 + 7 = 15 Fourth octet: 0 + 255 = 255 Subnet mask: 255.255.248.0 (248 = 256 - 8) Wildcard mask: 0.0.7.255 ═══════════════════════════════════════════════════════════════════════════════ Example 3: 172.16.64.0/18───────────────────────────────────────────────────────────────────────────── Prefix: /18 Host bits: 32 - 18 = 14 Total addresses: 2^14 = 16,384 Usable hosts: 16,384 - 2 = 16,382 First address: 172.16.64.0 Last address: 172.16.64.0 + 16,383 = 172.16.127.255 Calculation breakdown: 16,383 = 63×256 + 255 Third octet: 64 + 63 = 127 Fourth octet: 0 + 255 = 255 Subnet mask: 255.255.192.0 (192 = 256 - 64) Wildcard mask: 0.0.63.255| Prefix | Total Addresses | Subnet Mask | Third Octet Range |
|---|---|---|---|
| /23 | 512 | 255.255.254.0 | 2 octets (0-1, 2-3, ...) |
| /22 | 1,024 | 255.255.252.0 | 4 octets (0-3, 4-7, ...) |
| /21 | 2,048 | 255.255.248.0 | 8 octets (0-7, 8-15, ...) |
| /20 | 4,096 | 255.255.240.0 | 16 octets (0-15, 16-31, ...) |
| /19 | 8,192 | 255.255.224.0 | 32 octets (0-31, 32-63, ...) |
| /18 | 16,384 | 255.255.192.0 | 64 octets (0-63, 64-127, ...) |
| /17 | 32,768 | 255.255.128.0 | 128 octets (0-127, 128-255) |
| /16 | 65,536 | 255.255.0.0 | 256 octets (full third octet) |
The third-octet subnet mask value = 256 - (number of third-octet values in the range). For /22 (4 third-octet values): 256 - 4 = 252. For /21 (8 values): 256 - 8 = 248. For /20 (16 values): 256 - 16 = 240.
We've developed comprehensive supernet calculation skills—from the formal algorithm to quick mental techniques. Let's consolidate the key takeaways:
What's Next:\n\nNow that we can calculate supernets, the next page explores routing efficiency—how supernetting impacts router performance, memory utilization, and convergence times. We'll see the quantitative benefits of aggregation in real network scenarios.
You now have the mathematical skills to calculate supernets for any aggregatable set of networks. These calculations are fundamental to network design, address planning, and routing configuration. Practice with various examples until the patterns become automatic. Next, we'll quantify the benefits of these calculations in terms of routing efficiency.