Subnet Masks


  • relative size of the network and host portions of IPv4 address determines how many networks and hosts per network an addressing scheme can support
    • conventional scheme has IPv4 address with two hierarchical levels:
      • network ID
      • host ID
    • this scheme is inflexible
    • so system of dividing networks in to subnetworks was devised
  • subnet addressing has 3 hierarchical levels:
    • network ID
    • subnet ID
    • host ID
  • to create logical subnets:
    • bits from host portion of IP must be allocated as subnetwork address
      • rather than part of the host ID
      • means that subnet ID lies within an octet boundary
      • E.g., binary mask with 28 bits could use all the octets, with the network prefix boundary lying in the fourth octet:
        • leaves only 4 bits for host ID range
        • mask for the whole network is still 255.255.255.0
        • hosts within the network use the subnet mask 255.255.255.240
    • only one mask is ever applied to the IP address on each interface
    • mask containing the subnet information is only used within the IP network
    • External IP networks address the whole network by its network ID (198.51.100.0/255.255.255.0)
    • hosts within the network use the longer subnet mask to differentiate subnets
      • these are:
        • 198.51.100.0/255.255.255.240
        • 198.51.100.16/255.255.255.240
        • 198.51.100.32/255.255.255.240
        • 198.51.100.48/255.255.255.240
        • etc.
    • because 1s in mask are always contiguous, each octet in decimal in an IPv4 will always be one of these:
Octet Mask BitsBinary OctetDecimal EquivalentUsable Addresses
110000000128128
21100000019264
31110000022432
41111000024016
5111110002488
6111111002524
7111111102542
8111111112550
  • memorize these values to convert masks between binary and decimal
    • E.g.,
      • mask has 14 bits, then octet is 8 bits + 6 bits
      • so /14 network has the following mask:
      • 11111111 11111100 00000000 00000000 = 255.252.0.0