Figuring inverted masks quickly?

Answered Question
Nov 11th, 2008

How do you do it?

If I have an inverted mask of, how would you figure out the slash notation of this? What's the easiest way?



Correct Answer by Jon Marshall about 8 years 3 months ago


Add 1 then minus it from 256 ie.

31 + 1 = 32

256 - 32 = 224

so =


  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Correct Answer
Jon Marshall Tue, 11/11/2008 - 07:10


Add 1 then minus it from 256 ie.

31 + 1 = 32

256 - 32 = 224

so =


Collin Clark Tue, 11/11/2008 - 07:14

Subtract 31 from 255,


That's your subnet mask, then count the number of bits.

255 (8 bits) + 255 (8 bits) + 255 (8 bits) + 224 (3 bits) = 27 bits or a /27

That's how I do it, others probably have a better way :-)

**Looks like Jon can still type faster than me!

John Blakley Tue, 11/11/2008 - 07:23

That brings up another question. I've always figured the slash notation the way that you do Collin, but is there a faster way?

If I see, what's the fastest way to figure out that mask?

And it may be a reverse of what Jon just showed me, but I'm HORRIBLE at math. (I know; wrong field to be in.) :-)


Collin Clark Tue, 11/11/2008 - 07:34

Here's how I do it if I don't know it off the top of my head (again memorize the table).


I know it's more than 16, so it's mask is at least 255.255.something. Since it's more than 16 and less than 24 (next classful boundary), I subtract 16 from the number. That leaves 2. 2 bits is what number, 128 + 64, which is 224. That's my mask

Sometime it's easier to subtract the bits instead of adding them all together (eg /23).

Jon Marshall Tue, 11/11/2008 - 08:46


I do exactly the same sort of calcuation although i have to point out that 128 + 64 = 192 and not 224 so the mask is :-)


Collin Clark Tue, 11/11/2008 - 13:59

I have pretty thick skin and messing up a simple math problem won't throw me into a tailspin! Pointing out your own mistakes (jokingly or not) deserves points! Good luck on that next star, 10K points is certainly something to be proud of.

Jon Marshall Tue, 11/11/2008 - 14:01

No it was in jest and i was pretty sure you would take it that way :-). I didn't for one minute think you were bothered about your maths in the same way i'm not.

Pointing out our mistakes is definitely a British thing :-)



You can memorize the tables but after awhile that may fade away unless you have a heck of a memory, whereas learning the math behind it is more of a long-term way to remember it (and quickly figure out the mask/imask on the spot).

Here's how I do it...

Step #1 - Convert inverse mask to binary: = 00000000.00000000.00000000.00011111

Step #2 - Replace the 0's with 1's - (this for some reason was the hardest part for me, yet the simplest when you think about basic 0's and 1's, on/off, etc):



Notice bits are flipped which then give you the standard subnet mask

11111111.11111111.11111111.11100000 = (/27)

Step #3 - Count the ones!

This part was so hard for me when I first started learning subnetting, but once I understood it, it was like a light bulb went off and i said to myself "i'm an idiot" haha...

11111111.11111111.11111111.11100000 = 27 ones (which is where /27 comes from)... Counting ones is very easy to give a / notation for a mask just have to picture the subnet in binary as there is no difference between standard numbering system vs. binary (its all about how that number is expressed).

This is just my personal opinion, but I think that memorizing a table is honestly too much (and I have a good memory)... knowing the math is much more solid, proveable, and its like riding a bike once you do it you probably won't forget it, whereas memorizing a table is good for short term.

Also one thing to consider is CCNA is an entry level exam. Theres a few tables to know in CCNA that you can choose to memorize or learn the right way, and as you progress through other Cisco exams you'll see theres a TON of tables ... I for one HATE memorizing tables (especially if its not something you don't do every day). Being able to remember a simple math function is much easier. You will see theres a few tables you have no choice but to memorize, and you will be trying to find ways/pneumonics (sp) just to get that table memorized (hence why the math portion is much much easier....)

Hope this helps,


[email protected]


Here is another nice subnetting trick I learned - "The binary AND function".

I was amazed to see this work maybe it'll be of interest to you:

The reason you would do the binary AND function is to determine the NetID of a given IP address and subnet mask.


Given the IP address of and a mask of, what is the network ID for the subnet (NetID).

Step 1 - Convert IP address and subnet mask to binary: = 11000000.10101000.11001000.11011000 = 11111111.11111111.11111111.11110000

Step 2 - Use the AND function downwards for each binary digit (in case you don't know, the way binary AND works is:

1 and 1 = 1

1 and 0 = 0

0 and 1 = 0

0 and 0 = 0

Only way to get a 1 with binary AND is to have two ones, so lets AND our IP against our mask (in binary), downards:

11000000.10101000.11001000.11011000 A ||

11111111.11111111.11111111.11110000 N ||

==================================== D \/


Step 3 - Convert the result of the binary AND function to normal decimal:

11000000.10101000.11001000.11010000 = (Network ID)

You might not have to do this too often however its nice to be able to do another binary trick to get you the NetID from a given IP/mask.

Aside from this being a subnet trick, I believe this one of the core principles behind how the IP protocol works in determining exactly where to send a broadcast on an interface. Knowing this subnet formula I think helps you have a better understanding for subnets overall and being able to work with all IP interfaces/Vlans/etc.

Hope this helps too!


[email protected]


This Discussion