IPv4 subnet

Type an address with /prefix, or pick the prefix from the list
e.g. 192.168.1.10/24

Try
Network address
192.168.1.0
Broadcast address
192.168.1.255
Usable host range
192.168.1.1 – 192.168.1.254
Usable hosts
254
Total addresses
256
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
CIDR notation
192.168.1.0/24
IP class
C
Address type
Private

In binary

The mask's 1 bits mark the network part of every address

24 network bits 8 host bits

ValueDecimalBinary
IP address192.168.1.1011000000.10101000.00000001.00001010
Subnet mask255.255.255.011111111.11111111.11111111.00000000
Network192.168.1.011000000.10101000.00000001.00000000
Broadcast192.168.1.25511000000.10101000.00000001.11111111
Guide

How to calculate a subnet

  1. Type an IPv4 address with its prefix, like 192.168.1.10/24, or type the address and choose the prefix from the list.
  2. The mask's 1 bits mark the network part. AND the address with the mask to get the network address, and set every host bit to 1 for the broadcast address.
  3. The addresses in between are the usable hosts: 2ⁿ − 2 of them, where n is the number of host bits. A /24 has 8 host bits, so 254 hosts.

Worked example

Working out 192.168.0.130/26. Only the last octet changes, so here it is in binary:

Last octetBinary
Address13010000010
Mask (/26)19211000000
Network (AND)12810000000
Broadcast19110111111

Network 192.168.0.128, hosts 192.168.0.129 – 192.168.0.190

  • /24 means the first 24 bits are the network, which is the mask 255.255.255.0.
  • A /31 is used for point-to-point links and has 2 usable addresses, and a /32 is a single host.
  • Want any number in binary? Use the decimal to binary converter.
Learn

How IPv4 subnetting works

IP addresses in binary, masks and CIDR, host counts and the ranges worth knowing.

A subnet calculator takes an IP address and a prefix length or subnet mask, and works out the network it belongs to: the network and broadcast addresses, the range of usable host addresses, the masks and the number of hosts. Type an address like 192.168.1.10/24 above to see all of it, along with every address in binary. Below is how IPv4 subnetting works bit by bit, with a cheat sheet of the common subnet sizes.

IP addresses in binary

An IPv4 address is a 32-bit number. It's written as four decimal numbers from 0 to 255, called octets, because each one is 8 bits. 192.168.1.10 in binary is 11000000.10101000.00000001.00001010. There are 2³², or 4,294,967,296, possible IPv4 addresses. Subnetting splits that 32-bit number into two parts: the first bits identify the network, and the rest identify a host on that network. The decimal to binary converter shows how each octet becomes 8 bits.

Subnet masks and CIDR notation

A subnet mask marks which bits belong to the network. It's a run of 1 bits followed by 0 bits, written like an address. 255.255.255.0 is twenty-four 1s followed by eight 0s, so the first 24 bits are the network. CIDR notation writes the same thing as a slash and the number of 1 bits: /24. The mask's 1s must always come first, which is why only 33 masks exist, from /0 to /32, and why a mask like 255.0.255.0 isn't valid.

Finding the network and broadcast address

The network address is the IP address with every host bit set to 0. In binary, that's a bitwise AND of the address and the mask: a bit stays 1 only where both have a 1. The broadcast address is the opposite end, with every host bit set to 1. For 192.168.0.130/26, the last octet 130 is 10000010 and the mask's last octet 192 is 11000000. ANDing them gives 10000000, or 128, so the network is 192.168.0.128. Setting the six host bits to 1 gives 10111111, or 191, so the broadcast is 192.168.0.191.

How many hosts a subnet has

With n host bits, a subnet has 2ⁿ addresses. Two of them are reserved, the network address and the broadcast address, so the usable host count is 2ⁿ − 2. A /24 has 8 host bits: 256 addresses and 254 hosts. A /26 has 6: 64 addresses and 62 hosts. There are two exceptions. A /31 has only 2 addresses, and point-to-point links use both as hosts (RFC 3021). A /32 is a single address, used for one host or a route to it.

Subnet mask cheat sheet

CIDRSubnet maskAddressesUsable hosts
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/20255.255.240.04,0964,094
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/31255.255.255.25422
/32255.255.255.25511

Splitting a network into subnets

Each extra bit of prefix halves the subnet. Borrowing 2 bits from a /24 turns it into four /26 networks of 62 hosts each:

  • 192.168.1.0/26: hosts 192.168.1.1 – 192.168.1.62
  • 192.168.1.64/26: hosts 192.168.1.65 – 192.168.1.126
  • 192.168.1.128/26: hosts 192.168.1.129 – 192.168.1.190
  • 192.168.1.192/26: hosts 192.168.1.193 – 192.168.1.254

Notice the networks step by 64, which is 2⁶, the number of addresses in each one. Network addresses always fall on a multiple of the subnet size, which makes it easy to check a subnet by hand.

Private and special addresses

Three ranges are reserved for private networks and never appear on the public internet: 10.0.0.0/8, 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16. Home routers almost always use 192.168. Other special ranges include loopback 127.0.0.0/8, link-local 169.254.0.0/16, which a device picks for itself when no DHCP server answers, and 100.64.0.0/10 for carrier-grade NAT. The calculator labels the type of every address you enter.

Wildcard masks

A wildcard mask is the subnet mask with every bit flipped, so /24 gives 0.0.0.255. Cisco access lists and OSPF use wildcard masks to say which bits of an address can vary. The calculator shows the wildcard for every prefix, ready to copy.

Input tips and limits

  • You can type a dotted mask instead of a prefix, as in 192.168.1.10 255.255.255.0.
  • Any address in a subnet gives the same network, so you don't need to start from the network address.
  • This calculator works with IPv4. IPv6 addresses are 128 bits and are usually split into /64 subnets.

To size a subnet in your head, subtract the prefix from 32 to get the host bits, then take 2 to that power and subtract 2. A /27 has 5 host bits, so it holds 30 hosts.

FAQ

Frequently asked questions

Quick answers about the subnet calculator and how it works.

How do I calculate a subnet?

Write the address and the mask in binary and AND them together to get the network address. Then set every host bit to 1 for the broadcast address. The usable hosts are everything in between. For 192.168.0.130/26, that's network 192.168.0.128, broadcast 192.168.0.191 and hosts .129 to .190.

What does /24 mean?

It's CIDR notation for the number of network bits: the first 24 of the 32 bits identify the network. That's the subnet mask 255.255.255.0, which leaves 8 bits for hosts, or 254 usable addresses.

How many usable hosts are in a subnet?

2ⁿ − 2, where n is the number of host bits (32 minus the prefix). A /24 has 254, a /25 has 126, a /26 has 62 and a /30 has 2. The network and broadcast addresses can't be assigned to hosts, except in a /31, where both are usable, and a /32, which is a single address.

What's the difference between a subnet mask and a wildcard mask?

A wildcard mask is the subnet mask with every bit flipped. 255.255.255.0 becomes 0.0.0.255. Subnet masks mark the network bits, while wildcard masks, used in Cisco access lists and OSPF, mark the bits that can vary.

What are the private IP address ranges?

10.0.0.0/8, 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) and 192.168.0.0/16. They're reserved for private networks and aren't routed on the public internet. The calculator shows the type of any address you enter.

Does the subnet calculator support IPv6?

Not yet. It works with IPv4 addresses, which are 32 bits long. IPv6 addresses are 128 bits, written in hex, and networks are usually divided into /64 subnets.

Still have a question?Contact us