Network Masks


A 32-bit network mask is used to distinguish the network ID and host ID in an IPv4 address.

  • conceals the host ID portion of the IP address
  • reveals the network ID portion
  • mask and IP address are the same number of bits
  • where there is a 1 in the network mask, the corresponding binary digit in the IPv4 address is part of the network ID
  • 1s in the mask are always contiguous
    • E.g.,
      • valid mask: 11111111 11111111 11111111 00000000
      • invalid mask: 11111111 00000000 11111111 00000000
  • network ID portion of an IP is revealed by ANDing the mask to the IPv4 address
    • when two 1s are ANDed together, the result is 1
    • any other combo = 0

Determine the Network ID

host IPv4 address = 198.51.100.1 and mask = 255.255.255.0

  • first convert IP and mask to binary notation
  • then AND the two binary numbers
  • then convert back to dotted decimal notation

  • network can be identified using prefix or slash notation
    • prefix is the number of bits set to 1
    • E.g., 198.51.100.0/24
  • default masks align with octet boundaries
    • values in the dotted decimal mask will be 255 or 0
    • E.g., default 24-bit mask:
    • 8-bit mask = 255.0.0.0
    • 16-bit mask = 255.255.0.0
  • longer network portion allows for more network IDs but fewer host IDs
    • E.g., 255.255.255.0
    • /24 network has only 254 possible host addresses
    • /8 allows for millions of hosts but only 126 network addresses