IP Subnet Calculator

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(32−CIDR)2^{(32 – \text{CIDR})}

    2

    (

    32

    CIDR

    )

  • 2(32−24)2^{(32 – 24)}

    2

    (

    32

    24

    )

  • 282^8

    2

    8

  • 256256

    256

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!