Subnet Mask Bit Calculator

Subnet Mask Bit Calculator

Enter an IPv4 address with a CIDR prefix from /0 to /32, or type a dotted subnet mask, to instantly compute the subnet mask, wildcard mask, network and broadcast addresses, the usable host range, and the number of usable hosts, all with a full bitwise and binary breakdown.

🌐Real Subnet Presets

📝IP & Mask Inputs

Each octet is 8 bits, so the full IPv4 address is 32 bits. Use the network base (host bits zero) for the cleanest read-out.

/24

The prefix sets how many leading bits belong to the network. Moving the slider rewrites the dotted mask below.

Dropdown mirrors the slider for exact keyboard selection.

Pick a dotted mask and the calculator converts it back to the matching /n prefix.

Enter usable hosts per subnet; the tool suggests the smallest prefix that fits. Leave 0 to ignore.

Enter how many equal subnets you must carve from this block; the tool suggests borrow bits. Leave 0 to ignore.

Subnet mask 255.255.255.0 /24 prefix
Usable hosts 254 2^8 − 2
Network address 192.168.1.0 first address in block
Broadcast address 192.168.1.255 last address in block

🔢Formula Snapshot

32Total IP bits
32 − nHost bits
2^hBlock size
− 2Net + broadcast

Bitwise Formula Breakdown

Mask from prefixmask = (0xFFFFFFFF << (32 − n)) >>> 0. For /24 this is 11111111.11111111.11111111.00000000 = 255.255.255.0.
Network addressnetwork = ip & mask. Bitwise AND clears every host bit, leaving the base of the block.
Wildcard maskwildcard = ~mask (bitwise NOT). It is the inverse of the subnet mask, e.g. 0.0.0.255 for /24.
Broadcast addressbroadcast = network | ~mask. Bitwise OR sets every host bit to one, the last address in the block.
Host bitsh = 32 − n. These bits are free to number hosts inside the subnet.
Total addressesblock size = 2^h. A /26 has 2^6 = 64 addresses in the range.
Usable hostsusable = 2^h − 2, subtracting the network and broadcast. /31 and /32 are special cases with 2 and 1.
Host rangefirst = network + 1, last = broadcast − 1, the addresses you can assign to devices.

📊Full CIDR /0–/32 Reference

CIDRSubnet MaskWildcardTotal Addr.Usable Hosts
/8255.0.0.00.255.255.25516,777,21616,777,214
/16255.255.0.00.0.255.25565,53665,534
/20255.255.240.00.0.15.2554,0964,094
/22255.255.252.00.0.3.2551,0241,022
/23255.255.254.00.0.1.255512510
/24255.255.255.00.0.0.255256254
/25255.255.255.1280.0.0.127128126
/26255.255.255.1920.0.0.636462
/27255.255.255.2240.0.0.313230
/28255.255.255.2400.0.0.151614
/29255.255.255.2480.0.0.786
/30255.255.255.2520.0.0.342
/31255.255.255.2540.0.0.122 (RFC 3021)
/32255.255.255.2550.0.0.011 (host route)

Usable hosts = 2^(32 − n) − 2. A /31 carries 2 usable point-to-point hosts under RFC 3021; a /32 is a single host route.

🏷IPv4 Class Ranges (A / B / C)

ClassFirst OctetRangeDefault MaskDefault Prefix
Class A1–1261.0.0.0 – 126.255.255.255255.0.0.0/8
Loopback127127.0.0.0 – 127.255.255.255255.0.0.0/8
Class B128–191128.0.0.0 – 191.255.255.255255.255.0.0/16
Class C192–223192.0.0.0 – 223.255.255.255255.255.255.0/24
Class D224–239224.0.0.0 – 239.255.255.255Multicastn/a
Class E240–255240.0.0.0 – 255.255.255.255Reservedn/a

Classful defaults are legacy; modern networks use classless CIDR prefixes, but the class still hints at the historic default mask.

🔒Private Ranges (RFC 1918)

BlockCIDRAddress RangeTotal AddressesTypical Use
24-bit block10.0.0.0/810.0.0.0 – 10.255.255.25516,777,216Large enterprise
20-bit block172.16.0.0/12172.16.0.0 – 172.31.255.2551,048,576Mid-size campus
16-bit block192.168.0.0/16192.168.0.0 – 192.168.255.25565,536Home & small office
Link-local169.254.0.0/16169.254.0.0 – 169.254.255.25565,536APIPA auto-config
Shared (CGNAT)100.64.0.0/10100.64.0.0 – 100.127.255.2554,194,304Carrier-grade NAT

RFC 1918 addresses are not routed on the public internet and are reused behind NAT on countless private networks.

📏Subnet Size Comparison Grid

CIDRSubnet MaskSubnets per /24Hosts EachWildcardBlock Size
/24255.255.255.012540.0.0.255256
/25255.255.255.12821260.0.0.127128
/26255.255.255.1924620.0.0.6364
/27255.255.255.2248300.0.0.3132
/28255.255.255.24016140.0.0.1516
/29255.255.255.2483260.0.0.78
/30255.255.255.2526420.0.0.34
/31255.255.255.25412820.0.0.12

Each extra network bit borrowed doubles the subnet count and roughly halves the hosts per subnet.

💡Subnetting Tips

VLSM tip: Variable Length Subnet Masking lets you size each subnet to real demand instead of one fixed mask. Assign the largest subnets first, then carve smaller /29 and /30 blocks for links and point-to-point pairs so you never waste a whole /24 on two routers.
Shortcut tip: Memorize the mask octet values 128, 192, 224, 240, 248, 252, 254, 255. The block size in the interesting octet is 256 minus that value, so a /26 mask 192 means blocks of 64: networks land on .0, .64, .128, and .192.

If you’re assigning an IP address to each device in a network, things get dicey when boundaries is off. If you don’t know subnetting, you’ll give out addresses that make no sense because certain spaces won’t be viewable. Once you’ve entered your prefix and IP, the subnet mask bit calculator runs all the math for you. No more manual binary conversions for you, just design. Instead of seeing abstract bits, it display concrete ranges. Where is the network starting? When does it end? How many device will fit here?

IPv4 addresses are a total of thirty-two bits long, expressed commonly in dotted-decimal notation (e.g., 192.168.1.10). The subnet mask divide these bits into network and host portions. Bits marked with a one represent the network side; bits marked with a zero represents the host side. This results in the CIDR prefix which is just the number of initial ones, e.g., /24. So /24 indicates that the first twenty-four bits correspond to the network, while the last eight bits corresponds to the hosts.

How Subnetting Works

That is why it is flexible and has capacity. CIDR prefixes and dotted masks differ in appearance but do not represents different languages. A /24 and 255.255.255.0 both refers to the same boundary. One is expressed as a bit count; the other as decimal notation. There’s only a list of thirty-three legal masks since the mask bits has to run contiguously from the left. The tool will convert back and forth for you right away. Type in /26 and it displays 255.255.255.192. Pick the dotted mask, and it tells you /26.

After learning the eight non-trivial octet values, you’ll be able to convert any prefix in your head. That’s why people often get this wrong, they learn the table instead of understanding the bit shift. Just as your router does, the engine employs straightforward bitwise operations. To calculate the mask, it shifts bits left. To compute the network address, it performs a bitwise AND operation. This sets all the host bits to zero, which is base of the block. And the broadcast address? It is a bitwise OR between the wildcard mask and 1s set for each host bit. All those calculations take place in microseconds, yet that’s the essence of how IP works. So if you grasp them, you’ll stop guessing and begin computing.

The number of usable hosts are not so simple. To calculate them, raise two to the power of the number of host bits in your prefix, then subtract two. You must of subtracted two because those are the two reserved addresses: the broadcast address and the network identifier. In case of a /24 you have 8 host bits which gives you 254 usable hosts. With a /30 you have two usable hosts, which is perfect for point-to-point links between routers.

There are two exceptions that kind of break the rule. RFC 3021 defines certain kinds of links that use a /31 and carry two usable addresses. Then there’s the /32, a single host route. These exceptions will save you from misconfiguration if you’re dealing with tight limits.

Now a requirement is typically given, and then you choose a prefix. For example, let’s say your department requires two hundred hosts. That goes into the “hosts-needed” field. The calculator will recommend smallest block that will accommodate this. In our case that is a /24. A /25 will only support 126. And therefore you are left short.

This is where we get into Variable Length Subnet Masking (VLSM). Instead of applying the same mask everywhere, you will now apply each subnet based on actual need. You will no longer waste network addresses in overly large subnets, and you will have enough for growing needs. On this page you can see the idea presented in a binary way. The IP address, mask and broadcast is rendered as thirty-two bits grouped into octets. You get to see the host bits change from an all-zero network address to an all-one broadcast address in real terms. Drag the prefix over by one position and suddenly we have another subnet, but half the space. By giving up capacity you gain detail. This helps to understand how borrowing bits works visually.

Before CIDR, IP addresses were grouped into classes based on the first octet of the address. The first octet ranged from 1 through 126 (default /8), then from 128 to 191 was reserved, followed by 192 to 223 (default /24). These default values are old, but they also provide clues as to historical masks. Today, the private address ranges defined in RFC 1918 are more helpful. These include 10.0.0.0/8 and 192.168.0.0/16. Note that these never get routed over the public internet and are re-used behind NAT on just about any network you’ll encounter. That allows you to have your own safe sandbox where you can play around without exposing your devices out on the wild web.

When you get to subnetting, seeing those bits line up ends the rote learning. This is what divides an engineer from a user: he knows why the output looks like that. He understands where the boundaries are, and he can assign addresses accordingly with confidence. It is not performing advanced mental arithmetic; it is understanding the structure of the network itself. The zeros and ones create the space, and once you recognize their pattern, the entire model is one you can reason through instead of reference.

Subnet Mask Bit Calculator