CalcOpenly
English

Subnet calculator (IPv4 and IPv6 CIDR)

Find the network address, broadcast, usable host range and host count of any IPv4 or IPv6 CIDR block, with netmask, wildcard and equal subnets.

Drafted with AI writing toolsUpdated Checked examples: 7

IPv4 as 10.1.2.3/24 or with a netmask (10.1.2.3 255.255.255.0); IPv6 as 2001:db8::1/64.
Rounded up to a power of two; 1 keeps the network whole.
Try
Network
192.168.10.64/26
Network: 192.168.10.64/26
Netmask
255.255.255.192
Wildcard mask
0.0.0.63
Prefix length
26
First usable address
192.168.10.65
Last usable address
192.168.10.126
Broadcast address
192.168.10.127
Usable addresses
62
Total addresses
64
Historical class
C
Address type
Private (RFC 1918)
Prefix of each subnet
28
Addresses in each subnet
16

192.168.10.77 sits inside 192.168.10.64/26, which has 64 addresses (62 usable, 192.168.10.65 to 192.168.10.126). Private (RFC 1918). Splitting it gives 4 × /28 of 16 addresses each.

/26 in binary

Address 192.168.10.77
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
1
1
0
1
Mask 255.255.255.192
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
0
0
Network 192.168.10.64
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
0
0
0
Broadcast 192.168.10.127
1
1
0
0
0
0
0
0
1
0
1
0
1
0
0
0
0
0
0
0
1
0
1
0
0
1
1
1
1
1
1
1

Where the address sits in the block

/28 #1: 0 to 16/28 #1/28 #2: 16 to 32/28 #2/28 #3: 32 to 48/28 #3/28 #4: 48 to 64/28 #4Your address: offset 13Your addressoffset 13
4 subnets of /28, 14 usable addresses each Rows: 4
#SubnetFirst usableLast usableBroadcast
1192.168.10.64/28192.168.10.65192.168.10.78192.168.10.79
2192.168.10.80/28192.168.10.81192.168.10.94192.168.10.95
3192.168.10.96/28192.168.10.97192.168.10.110192.168.10.111
4192.168.10.112/28192.168.10.113192.168.10.126192.168.10.127
How it's calculated S
  1. Address and mask in binary

    A=11000000.10101000.00001010.01001101M/26=11111111.11111111.11111111.11000000\begin{aligned}A &= \texttt{11000000.10101000.00001010.01001101} \\ M /26 &= \texttt{11111111.11111111.11111111.11000000}\end{aligned}

    The first 26 bits name the network; the other 6 number the addresses inside it.

  2. Network address: AND with the mask

    11000000.10101000.00001010.01000000=192.168.10.64\texttt{11000000.10101000.00001010.01000000} = 192.168.10.64
  3. Last address: OR with the wildcard

    192.168.10.64∨0.0.0.63=192.168.10.127192.168.10.64 \lor 0.0.0.63 = 192.168.10.127
  4. Count the usable addresses

    232−26−2=64−2=622^{32-26} - 2 = 64 - 2 = 62

    The all-zeros host is the network itself and the all-ones host is the broadcast, so neither is assigned.

  5. Split into equal subnets

    22≥4⇒/26+2=/28232−28=16\begin{aligned} 2^{2} &\ge 4 \Rightarrow /26 + 2 = /28 \\ 2^{32-28} &= 16\end{aligned}

    The new prefix adds the borrowed bits; the second line counts addresses in each subnet.

About the subnet calculator

In the formula, A is the address, M the mask, N the network, L the last address and H the conventional IPv4 host count (prefixes /0–/30). A prefix length p keeps the first p bits of an address as the network and leaves the rest to number hosts. The calculator ANDs the address with the netmask to find the network address, ORs that with the wildcard mask (the inverted netmask) to find the last address, and counts 2^(32 − p) addresses for IPv4 or 2^(128 − p) for IPv6.

Engineers use it to plan VLANs, firewall rules and cloud VPC ranges. The default, 192.168.10.77/26, belongs to 192.168.10.64/26: 64 addresses, 62 of them usable from .65 to .126, with .127 as the broadcast. Splitting it 4 ways gives four /28 subnets of 16 addresses.

IPv4 counts leave out the network and broadcast addresses except on /31 point-to-point links (RFC 3021) and /32 host routes. IPv6 has no broadcast. This calculator leaves out the subnet-router anycast address except for /127 point-to-point links and /128 single addresses; actual assignment also depends on address scope, other reservations and platform rules. Splits are always into a power of two equal subnets; for a VLSM plan, split one of the results again.

How to calculate hosts in a CIDR subnet

An IPv4 block written /p has 2^(32 − p) addresses and 2^(32 − p) − 2 usable hosts, because the first address names the network and the last is the broadcast. A /26 has 2⁶ = 64 addresses and 62 hosts: 192.168.10.77/26 sits in 192.168.10.64/26, with hosts .65 to .126.

The rule covers /0 to /30. A /31 point-to-point link uses both of its addresses, and a /32 is a single host.

How to find the network and broadcast address

Work out the block size: find the first mask octet that isn't 255 and subtract it from 256. A /26 mask is 255.255.255.192, so blocks are 256 − 192 = 64 addresses long and start at .0, .64, .128 and .192.

  1. Find the block that holds the address. 77 falls in 64–127, so the network is 192.168.10.64.
  2. The broadcast is the last address in the block, 192.168.10.127.
  3. The usable hosts lie between them, 192.168.10.65 to 192.168.10.126.

The same method works in any octet. For 172.16.5.4 with mask 255.255.240.0 (/20), third-octet blocks are 256 − 240 = 16 wide. The network is 172.16.0.0 and the broadcast 172.16.15.255, leaving 4,094 hosts.

In binary, the network address is the address ANDed with the mask, and the broadcast is the network with every host bit set to 1.

Prefix, netmask and host count

  • /24: 255.255.255.0, 256 addresses, 254 hosts
  • /25: 255.255.255.128, 128 addresses, 126 hosts
  • /26: 255.255.255.192, 64 addresses, 62 hosts
  • /27: 255.255.255.224, 32 addresses, 30 hosts
  • /28: 255.255.255.240, 16 addresses, 14 hosts
  • /29: 255.255.255.248, 8 addresses, 6 hosts
  • /30: 255.255.255.252, 4 addresses, 2 hosts

Each extra prefix bit halves the block. A netmask must be a run of ones followed by zeros, so 255.0.255.0 is not a valid mask.

The wildcard mask used in Cisco access lists and OSPF is the inverse: subtract each octet from 255. A /26 has wildcard 0.0.0.63.

IPv4 subnet examples

Address and prefixNetworkNetmaskUsableUsable range
192.168.10.77/26192.168.10.64/26255.255.255.19262192.168.10.65 – 192.168.10.126
172.16.5.4/255.255.240.0172.16.0.0/20255.255.240.04094172.16.0.1 – 172.16.15.254
10.0.0.0/3110.0.0.0/31255.255.255.254210.0.0.0 – 10.0.0.1
203.0.113.5/32203.0.113.5/32255.255.255.2551203.0.113.5 – 203.0.113.5
0.0.0.0/00.0.0.0/00.0.0.042949672940.0.0.1 – 255.255.255.254

The /31 row follows RFC 3021 for point-to-point links, and the /32 row is a single host route. 0.0.0.0/0 covers the whole IPv4 space, which is how a default route is written.

The first three rows are private addresses. RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for internal networks. The /32 example, 203.0.113.5, comes from a separate block that RFC 5737 sets aside for documentation.

Splitting a network into equal subnets

Borrowing k host bits makes 2ᵏ equal subnets, each with a prefix k bits longer. Splitting 192.168.10.64/26 four ways borrows 2 bits and gives four /28s of 16 addresses and 14 hosts each, starting at .64, .80, .96 and .112.

A request for 3 subnets rounds up to 4, because binary splits come in powers of two. For subnets of different sizes (VLSM), split one of the results again, for example one /28 into two /29s.

IPv6 prefixes

IPv6 has no broadcast address. A /64, the standard size for one LAN, holds 2⁶⁴ = 18,446,744,073,709,551,616 addresses. A /48 contains 65,536 of those /64s, and a /56 contains 256.

The first address of an IPv6 subnet is the subnet-router anycast address and isn't given to a host, which leaves 2⁶⁴ − 1 in a /64. A /127 point-to-point link (RFC 6164) uses both of its addresses, and a /128 is a single address.

Cloud subnets reserve more addresses

AWS and Azure reserve 5 addresses in every ordinary IPv4 subnet: the network address, the next three and the last. A /24 there has 251 assignable addresses, not 254.

The smallest AWS subnet, a /28, leaves 11 addresses, and Azure's smallest, a /29, leaves 3. Plan cloud capacity with 2^(32 − p) − 5.

Common mistakes

  • Using the wildcard as the mask. 0.0.0.63 and 255.255.255.192 describe the same /26 from opposite sides, and a netmask field needs the leading ones.
  • Treating a host address as the network. 192.168.10.77/26 is a host inside 192.168.10.64/26, not a network of its own.
  • Counting a /31 as zero hosts. Both addresses of a /31 point-to-point link are usable.
  • Thinking in classes. A 10.x.x.x address doesn't imply /8. CIDR replaced the class A, B and C boundaries in 1993, and RFC 4632 allows any prefix from /0 to /32.

Entering addresses

  • IPv4 as 10.1.2.3/24, or with a dotted mask: 10.1.2.3 255.255.255.0.
  • IPv6 with a prefix length, such as 2001:db8::1/64.
  • Any address inside the block works; the network is worked out from it.

To see the same addresses as bits or hex, use the binary and hex converter.

Worked examples

Host in a /26

Address and prefix
192.168.10.77/26
Split into this many subnets
1
Network
192.168.10.64/26
Netmask
255.255.255.192
Wildcard mask
0.0.0.63
Broadcast address
192.168.10.127
First usable address
192.168.10.65
Last usable address
192.168.10.126
Usable addresses
62
Total addresses
64
Historical class
C
Address type
Private (RFC 1918)

Checked against: Independent calculation

Point-to-point /31 (edge)

Address and prefix
10.0.0.0/31
Split into this many subnets
1
First usable address
10.0.0.0
Last usable address
10.0.0.1
Usable addresses
2
Total addresses
2

Checked against: RFC 3021 §2

Single host /32 (edge)

Address and prefix
203.0.113.5/32
Split into this many subnets
1
Network
203.0.113.5/32
First usable address
203.0.113.5
Last usable address
203.0.113.5
Usable addresses
1
Address type
Documentation, TEST-NET-3 (RFC 5737)

Checked against: List = [203.0.113.5]; RFC 5737 §3

Netmask instead of a prefix

Address and prefix
172.16.5.4 255.255.240.0
Split into this many subnets
1
Network
172.16.0.0/20
Prefix length
20
Broadcast address
172.16.15.255
Total addresses
4,096
Historical class
B

Checked against: Independent calculation

Questions

How many usable hosts are in a /24 subnet?

A /24 has 256 addresses and 254 usable hosts, because the all-zeros address names the network and the all-ones address is the broadcast. The IPv4 rule is 2^(32 − prefix) − 2: a /25 gives 126, a /26 62, a /27 30, a /28 14, a /29 6 and a /30 2. The exceptions are /31, where RFC 3021 lets a point-to-point link use both addresses, and /32, a single host.

What is the difference between a subnet mask and CIDR notation?

They say the same thing in two ways. CIDR notation writes the number of network bits after a slash, as in /26; a subnet mask writes those bits as a dotted address with that many leading ones, so /26 is 255.255.255.192 and /20 is 255.255.240.0. CIDR, introduced in 1993 and now defined in RFC 4632, replaced the fixed class A, B and C boundaries, so any prefix from /0 to /32 is valid.

What is a wildcard mask?

A wildcard mask is the subnet mask with every bit inverted, so 255.255.255.192 becomes 0.0.0.63. Cisco IOS access lists and OSPF network statements use it: a 0 bit must match and a 1 bit is ignored. To get it, subtract each octet of the netmask from 255. For a /26 the last octet is 63, one less than the block's 64 addresses.

Why do AWS and Azure subnets have 5 fewer usable addresses?

For ordinary IPv4 subnets, both clouds reserve 5 addresses: the network address, the next three (for the router and DNS, or held for future use) and the last address. A /24 in an AWS VPC or Azure virtual network therefore has 251 assignable addresses instead of the 254 shown here. The smallest subnet AWS allows is a /28, which leaves 11; Azure's smallest is a /29, which leaves 3. AWS BYOIP ranges are an exception: all addresses in the range can be used. This calculator reports conventional IP host counts, not provider-specific assignable capacity.

How many addresses are in an IPv6 /64?

A /64 holds 2^64 = 18,446,744,073,709,551,616 addresses. It is the standard size for one IPv6 LAN because RFC 4291 requires 64-bit interface identifiers for most unicast addresses, and stateless autoconfiguration (SLAAC) builds addresses from them. A /48 contains 65,536 of those /64 subnets, and a /56 contains 256.

About this calculator

N=A∧ML=N∨¬MH=232−p−2\begin{aligned}N &= A \land M \\ L &= N \lor \lnot M \\ H &= 2^{32-p} - 2\end{aligned}

Sources

  1. AWS VPC subnet CIDR sizing and reserved addresses
  2. Azure Virtual Network FAQ: reserved addresses and subnet sizes
  3. RFC 4632 — Classless Inter-domain Routing (CIDR)
  4. RFC 3021 — Using 31-bit prefixes on IPv4 point-to-point links
  5. RFC 1918 — Address allocation for private internets
  6. RFC 4291 — IPv6 addressing architecture; RFC 5952 — IPv6 text representation
  7. IANA IPv4 and IPv6 special-purpose address registries (RFC 6890)

Checked against references

This calculator includes 7 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.

Put this calculator on your site

Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.

Height
Preview the embed

Keep the credit line. It is the only condition, and it is what keeps these calculators free.