Subnetting

Learn to Subnet

Pay attention to whether the examples excludes or includes Subnet Zero. Do not get into the habit of assuming the expected result is for the usable hosts. We always include subnet zero when determining the total number of addresses in the subnet. Never subtract 2, for the network and broadcast addresses, unless specifically asked for usable hosts.

Subnetting Practice

Practice make improvement!

Subnetting Cross-reference

Subnetting – Interesting Octet

  • This “interesting octet” is the last octet in the mask, from left to right, with bits turned on. i.e. 1
  • Example: With a mask of 255.255.240.0, the interesting octet is the 3rd octet, with a value of 240. 4 bits turned on.
  • Example: With a mask of 255.192.0.0, the interesting octet is the 2nd octet, with a value of 192. 2 bits turned on.
  • Example: With a mask of 255.255.0.0, the interesting octet is the 2nd octet, with a value of 255. 8 bits turned on.

Block Size / Subnet Increment

  • The block size is the increment from one subnet to the next.
  • The block size is not the number of addresses per subnet.
  • The block size must be a power of 2

Determine the Block Size: Method 1

  • The block size/subnet increment is determined by the bit position of the “interesting octet” of the mask.
  • e.g. If you have an interesting octet value of 192, you’re using 2 bits, and the value of the position of the 2nd bit, from the left is 64. So the block size is 64.
Bit position1 bit2 bits3 bits4 bits5 bits6 bits7 bits8 bits
Value of bit position/Block Size1286432168421

Determine the Block Size: Method 2

  • The block size/subnet increment is determined by subtracting the value of the “interesting octet” of the mask, from 256.

Examples of determining the Block Size

PrefixSubnet MaskInteresting OctetBit Value or (Calculation)Block Size
/26255.255.255.1924th octetvalue of the 2nd bit or (256 – 192) =64
/18255.255.192.03rd octetvalue of the 2nd bit or (256 – 192) =64
/24255.255.255.03rd octetvalue of the 8th bit or (256 – 255) =1

Using the AND function to determine the network address

  • Use the bitwise AND to determine the network address by comparing the binary of the subnet mask to the binary of an IP address.
    • If both bits in the column are 1, the bit in the resulting binary representation is 1, (1 × 1 = 1);
    • Otherwise, the result is 0 (1 × 0 = 0 or 0 × 0 = 0)
    • Example: (the interesting octet, is the 2nd octet)
      10010010.00101111.10000001.00001011 (146.47.129.11 IP Address)
      11111111.11111111.00000000.00000000 (255.255.0.0 Subnet Mask)
      10010010.00101111.00000000.00000000 (146.47.0.0 Network Address)
    • Same example, but using the just “interesting octet” of the IP address instead of the whole IP address. Note: All bits after the interesting octet will be zero.
      • x.00101111.x.x (146.47.129.11 IP Address)
        x.11111111.x.x (255.255.0.0 Subnet Mask)
        x.00101111.x.x (146.47.0.0 Network Address)

Broadcast Address

  • Add the Wildcard Mask to the network address to determine the broadcast address
  • Or subtract 1 from the next subnet address to determine the broadcast address of the previous subnet.

Wildcard Mask

Default Mask vs Mask

  • Default Mask is when there is no subnetting or supernetting.

Using the Wildcard mask to determine the last address (a.k.a. broadcast address) within a subnet.

  • For subnetting, the Wildcard mask is the inverse of the subnet mask
  • Each octet of the subnet mask, and its corresponding wildcard mask, must add up to 255.
  • Example:
    • If you have a /26 prefix, the dotted-decimal mask would be: 255.255.255.192, and then the Wildcard mask would be: 0.0.0.63. (As 192 + 63 = 255 in the 4th octet)

MicroNugget: Wildcard Masks by Keith Barker

Bits Borrowed and Host Bits

If you’re starting with the “Number of Needed Hosts“, then:

  1. Subtract the number of host bits from the 32 IPv4 bits. Leaving the (network bits used).
  2. Then subtract the number of (default mask network bits) from (network bits used), resulting in the (number of bits borrowed).

Subnet Calculators

Use the calculators to check your work, not to do the work for you.