Omni Calculator logo

IP Subnet Calculator

Created by Steven Wooding
Reviewed by Dominik Czernia, PhD and Jack Bowater
Last updated: Apr 02, 2024


This IP subnet calculator displays comprehensive information about IPv4 networks (e.g., the number of usable hosts, IP ranges, etc.) and IP addresses (e.g., private or public, class, etc.). It's useful for designing networks, troubleshooting, and helping you pass your CompTIA Network+ exam.

In the following article, you can read more about CIDR notation and find out what a subnet mask is. Are you interested in administrating networks? You might find our chmod calculator useful, as it helps you understand and solve file permissions issues!

What is a subnet?

In an Internet Protocol (IP) network, part of the IP address represents the network, while the remainder represents the host (or computer on the network). The act of dividing the IP address is called subnetting. Routers use the network part to exchange data between subnets, and the host part to send data to an individual host. You can estimate how long it will take using the bandwidth calculator.

Note, that this IP subnet calculator is applicable to IPv4 networks, though it also shows the IPv4-mapped IPv6 address, and the 6to4 prefix address, used for transitioning to IPv6.

What is a subnet mask?

When designing a network, it's good practice to balance the network and host parts of the IP address, so as not to have too many (limits the number of networks you can route to) or too few hosts (limits the number of computers on the network). A subnet mask is used to create a subnet by allocating several bits in the 32-bit IP address to represent the network. The remaining bits of the IP address represent the host address.

The following table shows an example of an IP address (192.0.2.130) being subnetted into a network address (192.0.2.128) and a host address (0.0.0.2), using a subnet mask of 255.255.255.192. The calculation requires converting the quad-dotted decimal notation to binary form. A logical AND operation is performed between the IP address and the subnet mask to get the network prefix. You find the host part by flipping the bits of the subnet mask and performing the logical AND operation again with the IP address.

Binary form

IP address

11000000.00000000.00000010.10000010

Subnet mask

11111111.11111111.11111111.11000000

Network prefix

11000000.00000000.00000010.10000000

Host part

00000000.00000000.00000000.00000010

You may find the binary calculator useful if you're unfamiliar with binary operations or need a refresher.

CIDR notation

In the early days of the Internet, there were three different main subnet masks, using multiples of 8 bits of ones in the mask. They were named Class A, Class B, and Class C networks, as we show in this table:

Subnet mask

Number of usable hosts

Class A

255.0.0.0

16,777,214

Class B

255.255.0.0

65,534

Class C

255.255.255.0

254

The problem with this scheme is that the choice of the number of hosts per network is rather coarse, with large jumps in the number of hosts per network. The solution is Classless Inter-Domain Routing (CIDR), which eliminates the class model, and lets the network designer assign any number of bits to the network prefix, opening up a more extensive choice of the number of hosts per network.

The notation to indicate the number of bits in the network prefix is a forward-slash, followed by the number of bits. So, a Class A network would be written as /8, as it uses the first 8 bits in the network mask. This table shows the CIDR notation and the number of usable hosts per subnet:

CIDR

Subnet mask

Number of usable hosts

/1

128.0.0.0

2,147,483,646

/2

192.0.0.0

1,073,741,822

/3

224.0.0.0

536,870,910

/4

240.0.0.0

268,435,454

/5

248.0.0.0

134,217,726

/6

252.0.0.0

67,108,862

/7

254.0.0.0

33,554,430

/8

255.0.0.0

16,777,214

/9

255.128.0.0

8,388,606

/10

255.192.0.0

4,194,302

/11

255.224.0.0

2,097,150

/12

255.240.0.0

1,048,574

/13

255.248.0.0

524,286

/14

255.252.0.0

262,142

/15

255.254.0.0

131,070

/16

255.255.0.0

65,534

/17

255.255.128.0

32,766

/18

255.255.192.0

16,382

/19

255.255.224.0

8,190

/20

255.255.240.0

4,094

/21

255.255.248.0

2,046

/22

255.255.252.0

1,022

/23

255.255.254.0

510

/24

255.255.255.0

254

/25

255.255.255.128

126

/26

255.255.255.192

62

/27

255.255.255.224

30

/28

255.255.255.240

14

/29

255.255.255.248

6

/30

255.255.255.252

2

/31

255.255.255.254

0

/32

255.255.255.255

0

Rather than looking up network properties in a table, use this IP address subnet calculator as a CIDR calculator to display the associated network properties.

How to calculate network and IP properties?

This IP subnet calculator shows you a multitude of network and IP address properties. Let's go through each one to briefly explain how to manually calculate them, linking to further resources for further information.

IP type – public or private?

There are two main types of IP address, public and private. Servers on the public Internet use public addresses, while local networks of computers (e.g., your home network) use private addresses. The following IP address ranges are private addresses:

  • 10.0.0.0 – 10.255.255.255
  • 172.16.0.0 – 172.31.255.255
  • 192.168.0.0 – 192.168.255.255

IP class

As well as the network class, IP addresses also historically belonged to classes. The range of IP addresses belonging to each class is defined as:

  • Class A: 0.0.0.0 - 127.255.255.255
  • Class B: 128.0.0.0 - 191.255.255.255
  • Class C: 192.0.0.0 - 223.255.255.255
  • Class D: 224.0.0.0 - 239.255.255.255
  • Class E: 240.0.0.0 - 255.255.255.255

Class D addresses are reserved for multicast traffic (one host sending the same data to many receiving hosts). Class E is reserved, meaning those addresses will not work on the public Internet.

Network address

The network IP address is the first address of the subnet. You calculate it by converting the IP address and subnet mask to binary and performing a bitwise AND logical operation. A router uses this address to forward traffic to the correct network. It isn't possible to assign the network address to a host.

🙋 If you're curious how switching between number systems works, visit our binary converter!

Broadcast address

A host can use the broadcast address to send data to all the other hosts on the subnet. It's the last address on the subnet. We can calculate it by using the network address and adding the total number of addresses (minus one) in the subnet.

First and last host addresses

The next address after the network address is the first address available to be assigned to a host. The address just before the broadcast address is the last address that you can allocate to a host.

Wildcard mask

The wildcard mask is the subnet mask with the bits inverted, therefore selecting the host part of the IP address.

Total number of addresses

We can calculate the total number of addresses in a subnet from the CIDR using the following formula:

total numberof addresses=2(32CIDR)\qquad \small {\text{total number} \atop \text{of addresses}} = 2^{(32 - \text{CIDR})}

Usable number of hosts

The network and broadcast addresses are not available to be assigned to hosts on the network. So, the number of available addresses that you can assign to hosts is the total number of addresses minus two.

Binary subnet mask and IP address

These outputs are the subnet mask and IP address converted to binary format. These are helpful when manually subnetting networks.

CIDR notation

This result is the IP address in quad-dotted notation, followed by a forward-slash and the CIDR number.

IP address in integer and hexadecimal form

An IP address is just a number, so you can represent it as an integer (base 10), hexadecimal (base 16), or any other base you like.

in-addr.arpa

This property is a special domain name, used for reverse DNS (Domain Name System) lookups (going from an IP address to a domain name). The IP address (in quad-dotted format) is reversed and prepended to the domain in-addr.arpa. For example, for the IP address 8.8.4.4, the PTR (pointer) record for the domain name 4.4.8.8.in-addr.arpa would be looked up and found to point to dns.google.

IPv4-mapped IPv6 address

The Internet is currently upgrading IP addresses from version 4 (represented by 32 bits) to version 6 (represented by 128 bits). To help with this transition, hybrid dual-stack IPv6/IPv4 implementations use a 96-bit prefix of 80 bits of zeros and 16 bits of ones, followed by the 32 bit IP address. For example, the IPv4 address 169.291.13.133 maps to an IPv6 address of ::ffff:a9db:0d85 (converting the IP address to hexadecimal). It's also common to use the usual IPv4 quad-dotted decimal notation in the mapped address, like this: ::ffff:169.219.13.133.

6to4 prefix

Another IPv4 to IPv6 transition strategy is called 6to4 and allows IPv6 data to travel over IPv4 networks. A 6to4 IPv6 address always starts with 2002 and then is followed by the IPv4 address, split into two 16-bit parts, written in hexadecimal, making for a 48-bit long prefix. For example, the 6to4 prefix for the IPv4 address 192.0.2.4 is 2002:c000:0204::/48. There is then room for an IPv6 16-bit subnet field and 64 bits for hosts.

How to use the IP subnet calculator?

This subnet calculator is straightforward to use. First select the subnet mask you are interested in exploring. You can reduce the list of subnet masks to choose from by setting the network class option.

Next, enter the IP address, one octet at a time, in the four rows. You will then see all of the network and IP address properties.

Example of calculating network and IP properties

Taking an example IP address of 192.168.86.42, and a subnet mask of 255.255.255.0 (a /24 subnet), let's manually calculate the network and IP properties for this IP address.

IP type

Check if the IP address is within any of the ranges of private IP addresses. If it is, then it is a private address. Otherwise, it is a public address. Looking at the ranges, we see that 192.168.86.42 is in the range 192.168.0.0 – 192.168.255.255 - a private address.

IP class

Looking through the ranges of each class in the previous section, we see that the IP address 192.168.86.42 is in the range 192.0.0.0 - 223.255.255.255, so it is a Class C IP address.

Network address

Let's go through the calculation of the network address, step-by-step.

  1. Convert both the IP address and subnet mask to binary, and write them down, one above the other.
    11000000101010000101011000101010
    11111111111111111111111100000000

  2. Perform a bitwise logical AND operation by reading down a column at a time. If there are two ones, write a one as the result. Otherwise, write a zero.
    11000000101010000101011000000000

  3. Divide up the binary number into 8-bit blocks and convert it back to decimal.
    11000000.10101000.01010110.00000000
    192.168.86.0

So, 192.168.86.0 is the network address.

Total number of addresses

Next, we'll calculate the total number of addresses, as we need that to work out the broadcast address. Use the equation for the total number of addresses, given that the CIDR is 24.

  • 2(32CIDR)2^{(32 - \text{CIDR})}
  • 2(3224)2^{(32 - 24)}
  • 282^8
  • 256256

So, the total number of addresses is 256.

Broadcast address

Now, we can calculate the broadcast address. Convert the network address from binary to decimal, which gives 3,232,257,536. Add 256 - 1 to get 3,232,257,791. Then convert this back to binary, separate it into 8-bit blocks, and convert to decimal.

3,232,257,791
11000000101010000101011011111111
11000000.10101000.01010110.11111111
192.168.86.255

So, the broadcast address for our example is 192.168.86.255.

First and last host addresses

For the first usable host address, we add one to the network address. While you can do all of the converting to a decimal number, adding one, and switching back to the quad-dotted decimal format, usually, it's easy to work directly with the quad-dotted decimal. Adding one to the network address 192.168.86.0 is simply a matter of adding one to the last octet. Therefore it's 192.168.86.1 for the first usable host address.

The same can be said when calculating the last usable host address, which is the broadcast address minus one. That gives a result of 192.168.86.254.

Wildcard mask

To calculate the wildcard mask, convert the subnet mask to binary and flip all the bits. Then switch back to the quad-dotted decimal format.

  • 11111111111111111111111100000000 – binary subnet mask
  • 00000000000000000000000011111111 – bits are flipped
  • 0.0.0.255 – convert back to quad-dotted decimal format

The wildcard mask for our example is 0.0.0.255.

IP address in integer and hexadecimal

Using the binary form of the IP address, we can convert the binary number to integer (base 10) and hexadecimal (base 16).

  • 11000000101010000101011000101010 – example IP address as a binary number
  • 3232257578 – integer number
  • 0xc0a8562a – hexadecimal number

in-addr.arpa

Reverse the example IP address 192.168.86.42 to get 42.86.168.192 and put it in front of in-addr.arpa to get 42.86.168.192.in-addr.arpa.

IPv4-mapped IPv6 address

IPv4-mapped IPv6 addresses consist of the prefix ::ffff: followed by the IPv4 address, either displayed in hexadecimal (IPv6 native) format or the IPv4 quad-dotted decimal format. The results for our example IP address is:

  • ::ffff:c0a8:562a
  • ::ffff:192.168.86.42

6to4 prefix

The 6to4 prefix consists of 2002: followed by the IP address in hexadecimal format. You can convert each octet to hexadecimal individually and write them out in the IPv6 form.

  • 192.168.86.42 is c0.a8.56.2a in hexadecimal
  • 2002:c0a8:562a::/48 is the 6to4 prefix

That's a lot of work here, isn't it? Thanks to our IP address subnet calculator, you can obtain all of this information in a minute!

FAQ

How do I calculate IP range from subnet mask?

To calculate the starting address of the subnet:

  1. Perform a binary AND operation between the IP address and the subnet mask.

Then to calculate the last address in the subnet range:

  1. Bitwise, invert the subnet mask.
  2. Do a binary OR operation with the first IP address in the subnet.

How do I calculate the broadcast address of a subnet?

The broadcast address is the last IP address within a subnet. You can calculate it by taking the network address (the 1st address within the subnet), adding the number of addresses in the subnet, and then subtracting one.

How do I calculate the total number of addresses in a subnet?

Using the Classless Inter-Domain Routing (CIDR) number of the subnet:

  1. Raise two to the power of 32 minus the CIDR number.
  2. For example, a /24 subnet has 2³²⁻²⁴ or 256 addresses in total (minus two for the total number of usable IP addresses).

How do I calculate an IPv4 mapped IPv6 address?

To calculate the IPv6 version of an IPv4 address:

  1. Set the first 80 bits of the IPv6 address to zero.
  2. Set the next 16 bits to 1.
  3. Add the 32 bits of the IPv4 address converted to hexadecimal format.
  4. For example, 169.291.13.133 maps to an IPv6 address of ::ffff:a9db:0d85.
Steven Wooding
Network class
Any/CIDR
Subnet mask
255.255.255.0 /24
IP address
1st octet
2nd octet
3rd octet
4th octet
IP address192.168.86.42
IP typePrivate
IP classClass C
Network address192.168.86.0
Broadcast address192.168.86.255
First host address192.168.86.1
Last host address192.168.86.254
Subnet mask255.255.255.0
Wildcard mask0.0.0.255
Total number of addresses256
Usable number of hosts254
Binary subnet mask
11111111111111111111111100000000
Binary IP address
11000000101010000101011000101010
CIDR notation192.168.86.42 /24
IP address - integer3232257578
IP address - hexadecimal0xc0a8562a
in-addr.arpa42.86.168.192.in-addr.arpa
IPv4-mapped IPv6 address::ffff:c0a8:562a or ::ffff:192.168.86.42
6to4 prefix2002:c0a8:562a::/48
Check out 7 similar internet and network calculators 📡
BandwidthBaud rateData transfer… 4 more
People also viewed…

Books vs e-books

Discover the ultimate paper books vs. e-books calculator. Make an informed choice with our handy tool. Find out which is best for the environment!

Day of the week

This day of the week calculator is a safe bet if you want to check out what was the day of the week when you were born - or any other past or future date you imagine.

Duty cycle

Learn how to calculate the duty cycle of a periodic system with Omni's duty cycle calculator: insert what you know, and we'll do the math!

Schwarzschild radius

Calculate the gravitational acceleration at the event horizon of a black hole of a given mass using the Schwarzschild radius calculator.