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:
- 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 Bits | Binary Octet | Decimal Equivalent | Usable Addresses |
|---|
| 1 | 10000000 | 128 | 128 |
| 2 | 11000000 | 192 | 64 |
| 3 | 11100000 | 224 | 32 |
| 4 | 11110000 | 240 | 16 |
| 5 | 11111000 | 248 | 8 |
| 6 | 11111100 | 252 | 4 |
| 7 | 11111110 | 254 | 2 |
| 8 | 11111111 | 255 | 0 |
- 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