# 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 – Interesting Octet

• This “interesting octet” is the last octet in the mask, from the left, with bits turned on.
• Example 1: With a mask of 255.255.240.0, the interesting octet is the 3rd octet, with a value of 240. With 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. With 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. With 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. Because the maximum value an octet can have is 255.

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

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

## 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)
• Same example, using just the “interesting octet” of the IP address instead of the whole IP address. Note: All bits after the interesting octet will be zero.

• Or subtract 1 from the next subnet address to determine the broadcast address of the previous subnet.

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

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

## 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.)
• 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].
• 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 st, 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.