20 February 2013
Ken Long - kenglong@gmail.com

# A subnetting problem using all I’ve learned so far.

## 29 . 99 . 37 . 88   /17

We know this is a class A and we know the default mask for a class A is 255 . 0 . 0 . 0

First, write out your binary charts for easy reference while you work on the problem.

### 1. Find the subnet mask in binary and decimal.

First, write out the mask using 255 for the default portion, 1’s for all the borrowed bits and zeros for all the host bits.

 255 . 1 1 1 1 1 1 1 1 . 1 0 0 0 0 0 0 0 . 0 n . s s s s s s s s . s h h h h h h h . h

Converting from binary to decimal, the mask is 255.255.128.0. The magic number is 128.

### 2. Find the subnetwork number.

The magic number is in the third octet so we need to convert that octet in the IP, 37, to decimal. Write out your conversion table then do the conversion.

128 64 32 16 8 4 2 1

37 in decimal = 0 0 1 0 0 1 0 1 in binary. Now perform a bit-wise AND with the binary number you just found and the binary version of the third octet in the mask.

1 0 0 0 0 0 0 0
0 0 1 0 0 1 0 1
---------------
0 0 0 0 0 0 0 0

That gives us the network number for the given IP and mask.

29 . 99 . 0 . 0

Note that we simply brought down the 99 from the second octet because that octet in the mask was all ones. This example can be extra confusing because the borrowed bits cross an octet boundary. That’s why I used it here.

### 3. Find the first useable host address.

The first host address is always the subnetwork number plus 1.

29 . 99 . 0 . 1

### 4. Find the next subnetwork number.

This is always the current network number plus the magic number. In this case it is:

29 . 99 . 128 . 0

Note that the 128 is in the 3rd octet because that’s where the magic number is.

The BC is always the next subnetwork number minus one and is always odd.

29 . 99 . 127 . 255

### 6. Find the last useable host address.

The last host address is always the BC minus one and is always even.

29 . 99 . 127 . 254

The total number of bits is 32. The mask is using 17. That leaves 15 for the host portion. Now raise 2 to the 15th power to get the total number of IPs.

215 = 32768

### 8. Find the total number of valid host addresses.

This is always the total number of IPs minus 2.

32768 - 2 = 32766

### 9. Find the total number of subnetworks.

Take the difference between the default mask, /8, and this mask, /17, to get 9. Now raise 2 to the power of 9.

29 = 512

### 10. Find the first two subnetwork addresses.

The first subnetwork number will have all the borrowed bits set to zero *and* all the host bits set to zero. Looking back at the binary mask in #1 above, we can see that if we set all the borrowed bits to zero we get the following:

First subnetwork number:

29 . 0 . 0 . 0 (Magic# = 128; 128 x 1 – 128)

Now we add the magic number to that, in the correct octet, to get the second subnetwork number:

29 . 0 . 128 . 0 (aka: Magic number x 1)

And so on…

 29 . 1 . 0 . 0 29 . 1 . 128 . 0 29 . 2 . 0 . 0

### 11. Find the last two subnetwork addresses.

Here’s a trick. The very last subnetwork number will be the mask! Here’s how that works. Keep the first octet of the IP because it’s a class A. If it were a class B, you would keep the first two and for a class C, the first three. Then fill in the rest of the octets from the mask.

29 . 255 . 128 . 0

Next to last subnetwork:

29 . 255 . 0 . 0

And so on…

 29 . 254 . 128 . 0 29 . 254 . 0 . 0 29 . 253 . 128 . 0

### In summary.. .

 Given IP address and CIDR: 29 . 99 . 37 . 88      /17 Subnet mask: 255 . 255 . 128 . 0 Subnetwork address: 29 . 99 . 0 . 0 Valid host address range: 29.0.0.1 to 29.99.127.254 Broadcast address: 29 . 99 .127 . 255 Total number of IPs: 32768 Total number of valid host addresses: 32766 Subnets: 29 . 0 . 0 . 0 to 29 . 255 . 128 . 0, incrementing by 128 Total number of subnetworks: 512

## Next:

Now, let's apply all of this to a practical subnetting problem.

Thanks to Mr. Hart and Mr. Clauss at Central New Mexico Community College for taking me this far. I'm sure I'll refine this as more of the steps become second nature and I more fully understand the underlying mechanics of it all.