Computing, IT, Networking & Security IP Addressing & Subnetting RFC 4632 (CIDR), RFC 950, RFC 1918

IPv4 Subnet Calculator (CIDR)

Give this calculator an IPv4 address and a prefix length and it resolves the address to the block it belongs to: the network number, the directed broadcast, the first and last usable host, the dotted-decimal and wildcard masks, and whether the range is private, public or reserved. It also splits the block into equal subnets when you need to carve a range into VLANs. The address you type does not have to be the network number — type any host in the block and the network address is derived for you, exactly the way a router does it.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
IPv4 addressAny address inside the block, in dotted-decimal form — the network number is derived, so you can paste a host address straight from a config.192.168.10.37
Prefix length (/n)The number after the slash. If you have a dotted-decimal mask instead, count its 1 bits — 255.255.255.192 is 26.26 /
Split this block intoCarves the block into equal-sized child subnets and lists each one; choose 1 to leave the block whole.Do not split

It returns

  • Network in CIDR notation — The block your address belongs to, written the way a routing table writes it.
  • Network address
  • Broadcast address
  • Usable host range
  • Usable hosts
  • Subnet mask
  • Wildcard mask (ACL)
  • Address scope

The formula

N=A232n232n
M=232232n

In plain text: network = ⌊A / 2^(32−n)⌋ × 2^(32−n); broadcast = network + 2^(32−n) − 1

  • AThe entered address as a 32-bit unsigned integer (—)
  • nPrefix length — the count of leading 1 bits in the mask (bits)
  • NNetwork number (the address with all host bits cleared) (—)
  • 2^(32−n)Block size — the number of addresses in the subnet (addresses)

The floor-and-multiply form is arithmetically identical to the bitwise AND of the address with the mask, and avoids 32-bit signed overflow in a language whose bitwise operators are signed.

Updated Category IP Addressing & Subnetting Verified against published test cases Reading time 10 min

What a subnet calculator actually resolves

A router does not store the address you configured on an interface. It stores the prefix — a network number and a length — and it derives that prefix by masking the host bits out of whatever address you typed. This calculator performs the same derivation, which is why you can paste any host address from a running configuration and get the block it belongs to.

Three facts drive every field on the page. First, a prefix of length n leaves 32 − n host bits, so the block holds 232−n addresses. Second, blocks are aligned: a block of size B always begins at an address that is an exact multiple of B. That is not a convention, it is forced by the definition — the network number is the address with its low bits zeroed, and zeroing the low bits is the same operation as rounding down to a multiple of the block size. Third, the lowest address in the block names the network and the highest is the directed broadcast, so neither goes on an interface.

Alignment is what surprises people. 192.168.1.130/26 does not create a subnet starting at .130. A /26 has a block size of 64, so the blocks in that /24 start at .0, .64, .128 and .192, and .130 falls in the third one. The network is 192.168.1.128, the broadcast is 192.168.1.191, and the usable range is .129 to .190.

The mask, the wildcard, and why AND is really division

The subnet mask is a 32-bit value with n leading ones followed by 32 − n zeros. Written as an integer it is 232 − 232−n. Written in dotted decimal it is one of just nine legal octet values — 0, 128, 192, 224, 240, 248, 252, 254, 255 — because a valid mask can never have a zero followed by a one.

To find the network you AND the address with the mask, which clears every host bit. AND with a mask of leading ones is exactly the same arithmetic as dividing by the block size, discarding the remainder and multiplying back — and that form is safer to implement, because JavaScript's bitwise operators work on signed 32-bit integers and turn any address above 127.255.255.255 negative. This page uses the division form for that reason.

The wildcard mask is the bitwise complement of the subnet mask, or equivalently the block size minus one. Cisco IOS access lists and OSPF network statements take wildcards rather than masks, so a /26 is 0.0.0.63 in an ACL and 255.255.255.192 on the interface. They are the same information written upside down; confusing them is one of the most common lab errors on the CCNA.

To split a block, add bits. Dividing a /24 into four subnets needs two extra bits, giving four /26s that start at the multiples of 64. Dividing into eight needs three bits and eight /27s. The rule is simply child prefix = parent prefix + log2(number of subnets), and the number of subnets must be a power of two because you can only add whole bits.

Worked example: 172.16.35.200/22 by hand

You find 172.16.35.200/22 on a firewall interface and need the block.

  1. Find the host bits. 32 − 22 = 10 host bits.
  2. Find the block size. 210 = 1,024 addresses. Since 1,024 = 4 × 256, the block spans four whole third-octet values, so the increment is 4 in the third octet.
  3. Find the mask. Twenty-two ones is 255.255.252.0 — the third octet holds 6 of the ones, and 256 − 28−6 = 256 − 4 = 252.
  4. Round the third octet down to a multiple of 4. 35 ÷ 4 = 8 remainder 3, so 8 × 4 = 32. The network is 172.16.32.0.
  5. Add the block and step back one. The block covers third octets 32, 33, 34 and 35, so the last address is 172.16.35.255 — the directed broadcast.
  6. Take the usable range. First host 172.16.32.1, last host 172.16.35.254, for 1,024 − 2 = 1,022 usable addresses.
  7. Write the wildcard. 1,024 − 1 = 1,023 = 0.0.3.255, which is what an ACL entry for this subnet uses.
  8. Classify it. 172.16.0.0/12 runs from 172.16.0.0 to 172.31.255.255, so this address is RFC 1918 private space.

The only step that needs thought is step 4, and the shortcut is always the same: divide the octet the mask lands in by the increment, discard the remainder, multiply back.

How to read the result

If the network address differs from the address you typed, that is normal and correct. It means you entered a host, not the block. Configure the host address on the interface and use the network address in routing statements, ACLs and documentation.

Check the scope field before you assume an address is routable. Anything in 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16 is private and needs NAT to reach the internet. 100.64.0.0/10 is carrier-grade NAT space that some ISPs hand to customers and that will collide with your internal plan if you also use it. 169.254.0.0/16 means DHCP failed. 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24 exist only for documentation and examples — if you find one in production, someone copied a book.

Address class is history, not policy. The A/B/C classification in the notes reflects the first octet only, and CIDR replaced classful routing in 1993. It still matters in exactly two places: a router's default classful boundary for automatic summarisation on some legacy platforms, and exam questions.

A split table with one row per child subnet is a VLAN plan. Read down the network column and you get the increment: /26s step by 64, /27s by 32, /28s by 16. Those numbers are worth memorising, because they let you sanity-check any subnet boundary in your head.

Mask octet values and what each one means

The only nine values a subnet mask octet can legally take, with the bits they contribute and the increment they create in that octet.
Octet valueBinaryNetwork bits in this octetIncrementExample prefix
0000000000256/16 (third octet)
128100000001128/25
19211000000264/26
22411100000332/27
24011110000416/28
2481111100058/29
2521111110064/30
2541111111072/31
2551111111181/32

Octet value = 256 − increment, and increment = 2^(8 − network bits in that octet). Any other value, such as 255.255.255.200, is not a valid contiguous mask.

Reserved ranges you should recognise on sight

0.0.0.0/8 is “this network” and 0.0.0.0/0 is the default route. 127.0.0.0/8 is loopback. 169.254.0.0/16 is link-local, assigned when DHCP fails. 100.64.0.0/10 is shared address space for carrier NAT under RFC 6598 — do not use it internally. 224.0.0.0/4 is multicast, and 240.0.0.0/4 is reserved and unroutable on the public internet. 255.255.255.255 is the limited broadcast, which never leaves the local link.

Errors this calculator is designed to catch

  • Assuming the address you typed is the network. 192.168.1.100/26 is a host in 192.168.1.64/26, not the start of a block at .100.
  • Using a non-contiguous mask. A mask must be leading ones then zeros. 255.255.255.200 is not a mask, even though every octet is a legal number on its own.
  • Swapping mask and wildcard. An ACL entry written with 255.255.255.192 instead of 0.0.0.63 matches almost nothing, and it does so silently.
  • Believing 172.32.0.0 is private. RFC 1918's middle block is 172.16.0.0/12, which stops at 172.31.255.255. Everything from 172.32.0.0 upwards is public space belonging to someone else.
  • Overlapping child subnets. Splitting a /24 into three subnets is not possible; you can only add whole bits, so the choices are 2, 4, 8, 16 and so on. Unequal sizes require VLSM, allocated largest-first from the parent.
  • Configuring a /31 on a shared LAN. RFC 3021 applies to point-to-point links only. On a broadcast segment a /31 leaves you with no broadcast address and, on some platforms, no working ARP.

Where this sits among the addressing tools

Three questions come up when you plan addresses, and each has its own tool. Which block does this address belong to? is this page. How big a block do I need? is the hosts per subnet calculator, which works backwards from a device count to a prefix. What is /26 in dotted decimal? is the subnet mask to CIDR converter, which is the fastest route when all you need is a notation change.

Beyond a single block, the design task is VLSM: taking one parent allocation and cutting it into segments of different sizes. The method is mechanical. List every segment with its host requirement, size each with the host-count tool, sort largest-first, then allocate consecutively from the top of the parent. Largest-first matters because of alignment — a /30 placed in the middle of a /24 destroys the ability to carve a /25 from it, while allocating in descending size order keeps every remaining boundary usable.

Summarisation is the inverse operation and is what keeps routing tables small: given a set of adjacent, aligned subnets, find the shortest prefix that covers exactly those and nothing else. It only works when the set is both contiguous and aligned, which is the real reason disciplined allocation pays off years later.

Finally, remember that address planning and capacity planning are different exercises. A /22 can hold a thousand hosts, but whether the link those hosts share can carry them is a bandwidth question — size that with the network bandwidth requirement calculator — and whether the segment stays up is a reliability question, which the MTBF and availability calculator covers.

Frequently asked questions

What is the network address for 192.168.1.100/26?

192.168.1.64. A /26 has a block size of 64 addresses, so the blocks inside that /24 start at .0, .64, .128 and .192. The address .100 falls in the second block, making the network 192.168.1.64, the broadcast 192.168.1.127, and the usable range 192.168.1.65 to 192.168.1.126.

Why can't I use the first and last address in a subnet?

The first address, with all host bits zero, is the subnet — it is the identifier that appears in routing tables. The last, with all host bits one, is the directed broadcast that reaches every host on the segment. Assigning either to an interface breaks routing or broadcast delivery. The exceptions are /31 point-to-point links under RFC 3021 and /32 host routes, neither of which reserves anything.

What is a wildcard mask and when do I need one?

A wildcard mask is the bit-inverse of a subnet mask, and it is what Cisco IOS access lists, OSPF network statements and route maps expect. Where the interface takes 255.255.255.192 for a /26, an ACL takes 0.0.0.63. Compute it as block size minus one. A wildcard also has a use a mask does not: because its bits need not be contiguous, it can match patterns such as every odd-numbered subnet.

How do I split a /24 into four subnets?

Add two bits, making four /26s. Set the split option on this page to 4 and it lists them: x.x.x.0/26, x.x.x.64/26, x.x.x.128/26 and x.x.x.192/26, each with 62 usable hosts. You can only split by powers of two, because you can only add whole bits to the prefix. For subnets of different sizes you need VLSM, allocated largest-first.

Is 172.20.5.1 a private address?

Yes. RFC 1918 reserves 172.16.0.0/12, which spans 172.16.0.0 through 172.31.255.255, so anything with a second octet from 16 to 31 is private. 172.15.x.x and 172.32.x.x are public. This calculator labels the scope for whatever address you enter, including loopback, link-local, CGNAT, multicast and documentation ranges.

Does the address class still matter?

Not for routing. CIDR replaced classful addressing in 1993, and every current protocol carries a prefix length with each route. Class survives in three places: the default masks some devices assume when you omit one, the classful boundary that older platforms use for automatic summarisation, and certification exams. Treat the class shown here as descriptive rather than as a constraint on how you subnet.

What happens if I enter a /0 or a /32?

A /0 is the entire IPv4 address space — network 0.0.0.0, broadcast 255.255.255.255, and 4,294,967,294 usable addresses. It is the default route, not a subnet you would configure. A /32 is a single address, used for loopbacks, virtual IPs and host routes; it has one usable address and no broadcast. Both are valid inputs and the calculator handles them.

How many hosts can I put on one subnet before it becomes a problem?

Address math allows 1,022 hosts on a /22 and 65,534 on a /16, but broadcast traffic is the real limit. Most enterprise designs cap a user VLAN at a /23 or /22 and many stay at /24, because ARP, DHCP, mDNS and neighbour discovery all flood the whole segment. If you need a larger population, split it into several VLANs and route between them rather than widening the prefix.

References