IP Subnet Calculator

Calculate the subnet mask, network and broadcast address, usable host range and host count for any IPv4 address and CIDR prefix.

Built by Sabki SolutionsRules: IPv4 subnetting (RFC 950, RFC 1918, RFC 3021)Last updated

Network

192.168.1.0/24

Subnet Mask

255.255.255.0

Usable Host Range

192.168.1.1 – 192.168.1.254

Broadcast Address

192.168.1.255

Usable Hosts

254

Total Addresses

256

Wildcard Mask

0.0.0.255

Class / Type

C, private

Mask in Binary

11111111.11111111.11111111.00000000

IPv4 Subnetting: Mask, Network, Broadcast and Hosts

Enter an IPv4 address and choose the prefix length. The calculator returns the network in CIDR notation, the subnet and wildcard masks, the broadcast address, the first and last usable host addresses and the number of hosts, and says whether the address is private.

How it is calculated

  • Subnet mask = prefix ones followed by (32 − prefix) zeros
  • Network = IP AND mask; broadcast = network OR wildcard (inverted mask)
  • Usable range = network + 1 to broadcast − 1
  • Usable hosts = 2^(32 − prefix) − 2 (2 for /31, 1 for /32)

CIDR cheat sheet

PrefixSubnet maskUsable hosts
/8255.0.0.016,777,214
/16255.255.0.065,534
/20255.255.240.04,094
/22255.255.252.01,022
/23255.255.254.0510
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522

Worked examples

1. 192.168.1.10/24 (the defaults). Mask 255.255.255.0, network 192.168.1.0, broadcast 192.168.1.255, hosts 192.168.1.1 to 192.168.1.254: 254 usable. Private (RFC 1918).

2. 192.168.1.130/26. Mask 255.255.255.192 (block size 64). 130 falls in the block 128 to 191: network 192.168.1.128, broadcast 192.168.1.191, hosts .129 to .190, 62 usable.

3. 172.16.5.20/20. Mask 255.255.240.0. The third octet block size is 16, so the network is 172.16.0.0 and the broadcast 172.16.15.255: 4,094 hosts.

4. 192.168.10.1/30 for a router link. Network .0, hosts .1 and .2, broadcast .3. A /31 (RFC 3021) uses both addresses with no broadcast.

Block size shortcut: 256 minus the last non-255 octet of the mask gives the step between subnets (256 − 192 = 64 for /26).

Related tools

Frequently Asked Questions

How do I calculate a subnet mask from a CIDR prefix?

Write the prefix number of ones followed by zeros to make 32 bits, then convert each group of 8 bits to decimal. /26 is 11111111.11111111.11111111.11000000 = 255.255.255.192.

How do I find the network address?

Do a bitwise AND of the IP address with the subnet mask. 192.168.1.130 AND 255.255.255.192 = 192.168.1.128.

How do I find the broadcast address?

Set all host bits to 1: network address OR wildcard mask. For 192.168.1.128/26 the broadcast is 192.168.1.191.

How many usable hosts are in a subnet?

2^(32 − prefix) − 2, because the network and broadcast addresses cannot be assigned. /24 has 254 usable hosts, /26 has 62, /30 has 2. /31 links use both addresses (RFC 3021) and /32 is a single host.

What is CIDR notation?

Classless Inter-Domain Routing writes a network as address/prefix, such as 10.0.0.0/8, where the prefix is the number of network bits. It replaced the old fixed class A, B and C networks.

What are private IP addresses?

RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private networks. They are not routed on the internet and are translated (NAT) by your router.

What is a wildcard mask?

The inverse of the subnet mask (0s and 1s swapped), used in Cisco ACLs and OSPF. The wildcard for 255.255.255.0 is 0.0.0.255.

What are IP address classes?

Historic ranges by first octet: A 1 to 127, B 128 to 191, C 192 to 223, D 224 to 239 (multicast) and E 240 to 255 (reserved). Classes are no longer used for routing but are still taught.

Which subnet should I use for a home or office?

A /24 (254 hosts) suits most homes and small offices. Use /23 or /22 for larger networks, and /30 or /31 for point-to-point router links.

How do I split a network into subnets?

Each extra prefix bit halves the subnet: a /24 splits into two /25s (126 hosts each), four /26s (62 each) or eight /27s (30 each).

Related Calculators

More in Computer Science · Engineering calculators · All calculators A–Z