/24 • Subnet Masking Tool

We created this web tool to explain subnetting and network masks in a way accessible to novices and learners. Apart from explaining each of the elements that goes into a calculating a subnet, the whole process is interactive. Fields with emphasised text can be edited to affect the results throughout the page.

IP address

An IP (Internet Protocol) address is similar to a real-world address. It allows other computers on a network to locate a device and direct traffic to it. IPv4 (IP version 4) uses a 32-bit number to represent the address. For human readibility it usually is split into four 8-bit integers called octets. As you will see, when it comes to subnet masking, it can be helpful to think of an IP address in binary terms.

IP octets in decimal: IP octets in binary:

Network mask

Sometimes it is useful to divide a network into further parts, called subnets. In order to enable data to be routed to different subnets, a mask is used. It splits the original IP address into two sections: one identifying the subnet and the other identifying the device within the subnet.

The mask is a 32-bit number, same as an IP address. It is composed of a consecutive number of 1s, followed by however many 0s it takes to make the total length 32. We usually write the mask as number between 0 and 32 (indicating how many 1s the mask begins with) and separated from the IP address by a slash. For example, the name of this site - /24 - indicates a mask of 24 ones and 8 zeroes.

Since subnet masks are 32 bits long, they can be represented using octets, just like and IP address.

Mask octets in decimal: Mask octets in binary:

Network prefix

The network prefix (also called the routing prefix or the network number) allows the identification of the specific subnet, allowing the correct routing of internet traffic. To find the network prefix, a bitwise AND operation is applied to the subnet mask and the IP address.

An AND operation (usually represented by the & character) takes two bits and returns a 1 if both inputs are 1; otherwise it returns a 0.

A B A & B
1 1 1
1 0 0
0 1 0
0 0 0

Bitwise simply indicates that this operation is performed bit-by-bit on both inputs. By using the IP address and mask above we get the following:

IP bits: Mask bits: Network prefix bits:

Similarly to how a decimal IP address can be displayed in binary, we can convert the network prefix from binary back to decimal:

Network prefix in decimal: Network prefix in binary:

Host identifier

The host identifier, sometimes also called a rest field identifies the specific device within the network. Similarly to the network prefix, it is obtained by performing a bitwise AND operation using the IP address. However, instead of using the network mask, it uses the complement of the mask. A complement simply inverts the bits - where the original bit is 1, the complement will have a 0, and vice versa.

Mask bits: Mask complement bits:

The actual operation is exactly the same as for the network prefix:

IP bits: Complement bits: Host identifier bits:

Again, like the IP address, network mask or network prefix, the host identifier can be written in a binary or decimal form:

Host identifier in decimal: Host identifier in binary: