CalcDuck

Subnet Calculator

Subnet Calculator

Network address
192.168.1.128
Broadcast address
192.168.1.191
First usable host
192.168.1.129
Last usable host
192.168.1.190
Usable host addresses
62
Subnet mask
255.255.255.192
Wildcard mask
0.0.0.63

For 192.168.1.130/26, the network address is 192.168.1.128, the broadcast address is 192.168.1.191, and there are 62 usable host addresses (2^6 − 2) from 192.168.1.129 through 192.168.1.190, with subnet mask 255.255.255.192.

Tip: “Copy with settings” shares a link that opens this calculator with your numbers already filled in.

How this calculator works

This calculator takes any IPv4 address and CIDR prefix length and works out the full subnet: the network address, the broadcast address, the range of usable host addresses, and the dotted-decimal subnet mask and wildcard mask. It uses plain 32-bit integer arithmetic on the address, the same math a router performs.

Prefixes from /8 to /30 follow the standard rule: the number of usable hosts is 2 raised to the number of remaining host bits, minus 2 for the reserved network and broadcast addresses. /31 and /32 are edge cases with their own conventions, covered below and handled explicitly by this calculator.

The formulas

Subnet mask = 32 one-bits, prefix length of them from the left (e.g. /26 = 11111111.11111111.11111111.11000000 = 255.255.255.192)Network address = IP address AND subnet maskBroadcast address = network address OR wildcard mask (wildcard mask = NOT subnet mask)Usable hosts (for /8 through /30) = 2^(32 − prefix) − 2Common prefixes: /8 = 255.0.0.0 (16,777,214 hosts) — /16 = 255.255.0.0 (65,534 hosts) — /24 = 255.255.255.0 (254 hosts)/25 = 255.255.255.128 (126 hosts) — /26 = 255.255.255.192 (62 hosts) — /27 = 255.255.255.224 (30 hosts)/28 = 255.255.255.240 (14 hosts) — /29 = 255.255.255.248 (6 hosts) — /30 = 255.255.255.252 (2 hosts)

The −2 removes the network address (all host bits 0) and the broadcast address (all host bits 1). /31 links have no address to spare for either, so RFC 3021 makes both of its two addresses usable; /32 is a single host address with no network or broadcast concept at all.

Worked example: 192.168.1.130/26

  1. The /26 prefix means 26 network bits and 6 host bits, so the mask is 255.255.255.192.
  2. 192.168.1.130 in the last octet is 10000010; ANDed with the mask's 11000000 gives 10000000 = 128, so the network address is 192.168.1.128.
  3. The wildcard mask is 0.0.0.63; ORed with the network gives the broadcast address 192.168.1.191.
  4. Usable hosts run from 192.168.1.129 to 192.168.1.190: 62 addresses, matching 2^6 − 2 = 62.

Frequently asked questions

Why subtract 2 from the usable host count?

Every subnet from /8 to /30 reserves its first address (all host bits zero) as the network address and its last address (all host bits one) as the broadcast address, so neither can be assigned to a device.

What makes /31 and /32 special?

A /32 has zero host bits, so it identifies exactly one address with no room for a separate network or broadcast address. A /31 has just one host bit; RFC 3021 defines both of its two addresses as usable, which is common on point-to-point router links where a network/broadcast address would waste half the block.

What is a wildcard mask used for?

It is the bitwise complement of the subnet mask and shows up in access control lists and routing configuration (notably on Cisco devices), where it marks which address bits are allowed to vary.

How is the subnet mask related to the CIDR prefix?

The prefix number is simply the count of leading 1-bits in the 32-bit mask. /24 is 24 ones followed by 8 zeros, which is 255.255.255.0; /26 is 26 ones followed by 6 zeros, which is 255.255.255.192.

Does this work for IPv6?

No, this calculator is IPv4-only. IPv6 uses 128-bit addresses and a different, much larger addressing convention.

Sources

Related calculators