Skip to main content
CertLighthouse

Free study tool

IPv4 subnet calculator

Enter an IPv4 address and prefix length to get the network and broadcast addresses, the usable host range, and the host count, with every step of the working shown.

Useful for CompTIA Network+ and CompTIA A+ Core 1

Address and prefix

You can paste CIDR notation, like 10.0.12.200/22.

Network 192.168.10.0, 62 usable hosts.

Network address
192.168.10.0/26
Broadcast address
192.168.10.63
First usable
192.168.10.1
Last usable
192.168.10.62
Usable hosts
62
Total addresses
64
Subnet mask
255.255.255.192
Wildcard mask
0.0.0.63

This subnet is private address space, inside 192.168.0.0/16 (RFC 1918).

Worked steps

  1. 1
    A /26 mask is 26 ones followed by 6 zeros.Mask11111111.11111111.11111111.11000000255.255.255.192Address11000000.10101000.00001010.00100101192.168.10.37
  2. 2
    The last network bit falls in the fourth octet, where the mask is 192. The block size is 256 − 192 = 64.
  3. 3
    In that octet, 37 falls in the block starting at 0, the largest multiple of 64 that isn't above it. Later octets become 0, so the network address is 192.168.10.0.
  4. 4
    The broadcast address is the block's last address: 0 + 64 − 1 = 63, with later octets set to 255. That gives 192.168.10.63.
  5. 5
    Usable hosts run from the address after the network to the one before the broadcast: 192.168.10.1 to 192.168.10.62.
  6. 6
    6 host bits give 26 = 64 addresses. Leaving out the network and broadcast addresses, 62 are usable.

Sources

Smallest subnet for a number of hosts

Use a /26, with 62 usable hosts.

Prefix
/26
Subnet mask
255.255.255.192
Usable hosts
62
Spare addresses
12
  1. 1
    You need 50 host addresses.
  2. 2
    Add 2 for the network and broadcast addresses: 52 addresses.
  3. 3
    The smallest power of two that holds them is 26 = 64 (25 = 32 is too few), so you need 6 host bits.
  4. 4
    32 − 6 = 26, so the prefix is /26, mask 255.255.255.192.
  5. 5
    That subnet has 62 usable addresses, 12 more than you need.

The block-size method

The working above uses the block-size method, which is quick enough to do on paper during an exam. It needs only the prefix length and one octet of the address.

  1. Find the octet where the network bits end. For a /26, the first three octets are all network bits and the fourth holds the last two, so the mask there is 192.
  2. The block size is 256 minus that mask octet: 256 − 192 = 64. Subnets start at 0, 64, 128, and 192 in that octet.
  3. The network address is the block start at or below the address's octet. For .37, that's .0.
  4. The broadcast address is one less than the next block start: .63. Any octets after the one you worked on become 0 in the network address and 255 in the broadcast address.
  5. Usable hosts sit between the two. With 6 host bits there are 26 = 64 addresses, and 62 are usable once the network and broadcast addresses are left out.

Two prefixes break the pattern. A /31 has no broadcast address, and on a point-to-point link both of its addresses are usable (RFC 3021). A /32 is a single address, a host route.

Common questions

How many usable hosts are in a /24?
254. A /24 has 8 host bits, which is 256 addresses, and the network and broadcast addresses can't be assigned to hosts.
Why do you subtract 2 from the number of addresses?
The address with all host bits set to 0 names the network, and the one with all host bits set to 1 is the broadcast address. Neither can be given to a host, except on a /31 point-to-point link or a /32 host route.
What is a wildcard mask?
The bitwise inverse of the subnet mask, so 255.255.255.192 becomes 0.0.0.63. Router access lists and some routing protocols use wildcard masks to say which address bits must match.
What subnet do I need for 50 hosts?
A /26. You need 52 addresses including the network and broadcast addresses, and the smallest power of two that holds 52 is 64, which leaves 6 host bits and a prefix of 32 − 6 = 26.

Practice that remembers where you left off

The CertLighthouse app will have these generators built in, with your progress saved and questions aimed at what you miss most. It's in development now.