Subnetting without tears


Forget the bitwise operations. Here’s how I do subnets.  In my head!  Any subnet, any mask in 30 seconds or less.

1.    First – credit where it is due.  My method has been shamelessly stolen from Wendell Odom’s CCENT/CCNA ICND1 Official Exam Certification Guide. If you want to learn more, like how to use magic numbers to calculate the number of subnets for a given mask, read his books.
2.    The whole secret around subnets lies in:
a) the subnet mask
b) knowing your 2x, 4x, 8x, 16x, 32x, 64x and 128x times tables as far as 256
Most people can handle 2x, 4x and (at a pinch) 8x.  32x, 64x and 128x only have 8, 4 or 2 items before you hit 256, so that leaves you your 16x tables to learn.

Here’s the deal:

Look at the “interesting” number in the subnet mask.  That is, the number that is NOT 0 or 255.  In your case:
138.43.39.15
255.255.255.240
Your “interesting” octet is octet 4 ie 240.
Subtract this number from 256 – you’ll get 16 (256-240=16) in this case.

The key concept here is that your subnets will be in groups of size 16 

Back to 138.43.39.15 255.255.255.240

256-240=16.  Odom calls this the “magic number”.  I’ll stick with his definition.

The key to understanding subnet is this “magic number”.  Read the following carefully:

If the “magic number” is 16, then

  • ALL of your subnet numbers will be multiples of 16, starting at 0
  • The broadcast address on any subnet is simply the next subnet address minus 1 in the last octet
    • ie All of your broadcast addresses will be 1 less than a multiple of 16. (15, 31, 47…)
  • The first IP address on any subnet is simply the subnet address plus 1 in the last octet (1,17,33…)
  • The last IP address on any subnet is simply the broadcast address minus 1 in the last octet. (14,30,46…)

Now read that last section again until it sticks.

In your case, where the magic number is 16, the subnet MUST be one of the following:
0
16
32
48
64
80
96
112
128
144
160
176
192
208
224
240
(256)

There you go – that’s your 16x tables up to 256. Told you to learn this didn’t I?  By the way, your 32x tables is just every 2nd number from the above.,  64x tables every 4th number and 128x tables every 8th number.

Note that the last entry before 256 is the same as the subnet mask’s “interesting octet”.  This is ALWAYS the case.

Back to 138.43.39.15 255.255.255.240 again.

Now your “interesting octet” is the 4th octet, which for your IP address is 15.

  • Your subnet number MUST be less than 15, but one of the multiples of 16 listed above.  Clearly 0 is the only multiple of 16 less than 15.  So your subnet is
  • 138.43.39.0
  • The next subnet would be 138.43.39.16 ie the NEXT multiple of 16.
  • The first address on your subnet will be 138.43.39.0+1 = 138.43.39.1
  • The broadcast address will be the NEXT subnet minus 1 ie 138.43.39.16-1 = 138.43.39.15
  • The last address will be one less than the broadcast address: 138.43.39.15-1 = 138.43.39.14

So the address you started with is the broacast address for its subnet = 138.43.39.15

Here’s another example:

134.27.183.219 255.255.255.248
Magic number=256-248=8
The “interesting octet” is the last octet, so I focus on 219
Recalling my 8x tables around 219
0
8
..
208
216
224
etc

  • I can see that my subnet number must be .216 – the closest multiple of 8 to 219 that is not greater than 219.
  • The first address then would be .217 (216+1)
  • The broadcast address would be .223 (1 less than the next multiple of 8 224-1)
  • The last address would be .222 (223-1)

Or expressed fully:

  • Subnet: 134.27.183.216
  • 1st Address: 134.27.183.217
  • Last Address: 134.27.183.222
  • Broadcast: 134.27.183.223
  • Next Subnet: 134.27.183.224 (I list this because I actually figure this out then work backwards for the broadcast and last address)

This one is a bit harder – the interesting octet is the 3rd octet

22.19.178.234 255.255.224.0
Magic number=256-224=32
The interesting octet is the 3rd octet, so I focus on 178.
Recalling my 32x tables around 178
0
32
..
160
192
224

  • I see 160 is the closest multiple of 32 that is not greater than 178
  • This makes my subnet 22.19.160.0
  • The first address 22.19.160.0+1=22.19.160.1
  • The NEXT subnet (’cause I’m going to work backwards) is 22.19.192.0
  • So the broadcast address is 22.19.192.0-1=22.19.191.255
  • And the last address 1 less than the broadcast address: 22.19.191.255-1=22.19.191.254

Remember there are only 7 possible magic numbers (8 if you count 256-255=1), so they are not hard to learn.  Here they are
Mask Magic number
255    1 (just for completeness)
254    2
252    4 (this is a common one)
248    8
240   16
224   32
192   64
128  128

One more tricky one to finish:
12.34.56.78 255.255.252.0
Magic number=256-252=4
The interesting octet is the 3rd octet, so I focus on 56.
Recalling my 4x tables around 56
0
4
..
48
52
56
60

  • I can see that my subnet number must be 56 – the closest multiple of 4 to 56 that is not greater than56.  See why it is tricky?  The “interesting octet” value is a multiple of the magic number, so you stop there.
  • This makes my subnet 12.34.56.0
  • The first address 12.34.56.0+1=12.34.56.1
  • The NEXT subnet (’cause I’m going to work backwards) is 12.34.60.0
  • So the broadcast address is 12.34.60.0-1=12.34.59.255
  • And the last address 1 less than the broadcast address: 12.34.59.255-1=12.34.59.254

Finally, if you want to learn this stuff (like for CCNA exam) spend half an hour a night onhttp://www.subnettingquestions.com

About RedNectar Chris Welsh

Professional IT Instructor. All things TCP/IP, Cisco or Data Centre
This entry was posted in GNS3 WorkBench. Bookmark the permalink.

2 Responses to Subnetting without tears

  1. Sean says:

    That is a great way to subnet.You have a typo though. In your last example you say “Magic number=256-248=8” I think that should be “Magic number=256-252=4” Thanks for all your work!

Comments are closed.