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!

Bit Patterns of Often Used Subnet Mask Values to Memorize

Bit(s)BinaryDecimal
110000000128
211000000192
311100000224
411110000240
511111000248
611111100252
711111110254
811111111255
Bit Patterns & Subnet Mask Values to Memorize

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 1: 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 2: 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 3: 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: 256 – {The interesting octet}
  • 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.
  • The block size is always less than 256.

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).

Subnetting Tips/Notes

  • If no mask/prefix is given, then borrow bits starting from the “Class” boundary of the IP address.
  • If a mask/prefix is given, then the given mask/prefix is the result of subnetting.  (Borrow bits from the “Class” boundary to the given mask/prefix.)
  • Never abbreviate IP addresses. Always write all four octets for every IP address, including the Broadcast address in a range.
  • Calculate the Block Size using the interesting octet, for all problems.
  • The total number of subnets must be a power of 2.
  • The total number of hosts must be a power of 2.
  • Is the question asking for “subnets” or “hosts”
    • If you’re asked for the # of hosts, then you must determine how many bits are needed to get that # of hosts, then subtract those bits from the 32 IPv4 bits, to determine the network bits / mask / prefix.
  • Determine the number of subnets: 2 [number of bits borrowed].
  • Determine the total number of addresses: 2 [the number of host bits].
  • Add the Wildcard mask to the network/subnet address to determine the broadcast/last address in the network/subnet.
  • Block Size:
    • The block size (256 – [The interesting octet]) is best used to determine the increment of the subnets.
    • The interesting octet is the last octet, from the left, that you borrowed bits from.
    • The “block size” is the increment from one subnet to the next, within the “interesting” octet.
    • The “block size” is not the number of addresses per subnet.
  • Determine how many addresses to add to the network address/subnet zero to get to the target subnet.
    • 1. Multiplying (Subnet “Number”) by the (number of addresses per subnet).
      (For the N nd, rd, th subnet, subtract 1 before multiplying by the number of addresses per subnet.)
    • 2. Convert the result to its Base-256 equivalent
    • 3. Add the Base-256 equivalent to the original network address of the block to get the network/subnet address of the target subnet.
  • The “subnet address” is an alternate term for the “network address” of a subnet.
  • Subnet using the methods that work for all subnets, large or small. Switching methods depending on the size of the subnet requires more effort than is necessary.
  • Practice makes improvement!

Subnet Calculators

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