Subnet Mask

Match first set of octets in network ID. In other words, tells devices on the network, how many groupings in the IP address to compare, before determining if an IP is local or not.

  • An IPv4 subnet mask consists of 32 bits:
    • It is a sequence of ones (1) followed by a block of zeros (0).
    • The ones indicate bits in the address used for the network prefix and the trailing block of zeros designates that part as being the host identifier. Source

The following example shows the network prefix and host ID for 192.168.5.23 and it’s associated /24 subnet mask 255.255.255.0.

Dotted Decimal Binary
IP address 192.168.5.23 11000000.10101000.00000101.00010111
Subnet mask 255.255.255.0 11111111.11111111.11111111.00000000
Network ID 192.168.5.0 11000000.10101000.00000101.x
(network prefix)
Host ID x.x.x.23 x.x.x.00010111
(rest field)

The result of the bitwise AND operation of IP address and the subnet mask is the network prefix 192.0.2.0. The host part which is 130, is derived by the bitwise AND operation of the address and the one’s complement of the subnet mask.

  • By definition all devices on the same network have the same subnet mask and network ID

Shorthand #

IP address followed by / and number of 1s in the subnet mask.

  • 201.23.45.123/24 has subnet mask 255.255.255.0

Class IDs #

Calculating hosts #

2^x - 2 = number of hosts. Where x is number of digits after subnet mask.

Backlinks #