I wanted to understand TCP/IP so I bout a book called teach yourself TCP/IP in 24 hours . I am trying hard to understand subnetting wich is not explained well in that book. Any way in assigning subnet mask we use for class c for example but why 255 not 256 because 2**8 is 256.

Also if you know an easy way to understand subnetting please let me know thanks

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi nawaf,
 It's 255 because that is the largest value that you can fit into 8 bits. The calculation is actually 2**8 - 1.

Regards .. Alan
Dear nawaf,

Check if this makes any sense

Hi nawaf,
> Any way in assigning subnet mask we use for class c for example
> but why 255 not 256 because 2**8 is 256.

but you have only 8 bits and the biggest number you can represent using 8 bits is 1111 1111 which is 255
the range is 0-255 (total 256 different values)

SolarWinds® IP Control Bundle (IPCB)

Combines SolarWinds IP Address Manager and User Device Tracker to help detect IP conflicts, quickly identify affected systems, and help your team take near instantaneous action. Help improve visibility and enhance reliability with SolarWinds IP Control Bundle.

This because the net adress is 0. Since 0 is a valid number you have the highest number beeing 255. 0-255 = 256 numbers.
Not long ago the same question was posted. Look at this:
nawafAuthor Commented:
in the 

Somebody mentioned this formula to find the number of hosts.
But can some body please give me an example.
1. give an IP address
2.subnet mask
3.find number of hosts

Just apply this formula to find the number of hosts.
Please I increase points t0 200 to understand it


and I will double points
>The formula for figuring out the number of 'host' bits in a subnet mask is
         2^n=(number of nodes )          (2^n  means '2' to the power of 'n')
practically formula should be (2^n) - 2

you cannot use all 0s and 1s ... they are supposed to be reserved but theoretically, they do exist
A bit tricky but i'll try.

I would like to turn the question. First define how many hosts you want, then calculate the subnet mask. For example you want, for some peculiar reson, two hosts on your subnet.

You also need to reserve 2 addresses beside the hosts. The lowest address is always reserved for the "network" and the highest for broadcast. To have two possible hosts you need to reserve 2+2=4 addresses.

To be able to represent 4 in binary value you need to reserve three bits.
00000100 binary = 4 decimal
To reserve(enable) three bits in the subnet mask you set them to 0 giving you
11111000 binary = 252 decimal

Thus subnet mask will be
Hi nawaf,
You might find the free subnet calculators at these addresses useful for determining subnets, host counts and masks :

 .. Alan
OOPS sorry!
I lost brainpower there for a moment. Discard my last, its not qiute correct.
To represent 4 numbers you will need 0,1,2,3.
Thus 00000011 binary is the highest = 2 reserved bits
This gives subnet mask
11111100 = 252
Now i hope my brain is turned on again....
nawafAuthor Commented:

No calulator ! I want to understand it then do the calculation myself.

nawafAuthor Commented:

Thanks !


>To represent 4 numbers you will need 0,1,2,3.
>Thus 00000011 binary is the highest = 2 reserved bits

Step1 is ok no problem here but

Step 2
>This gives subnet mask
>11111100 = 252
How did you get from step1 1 to step 2

I cant see the relationship b/w step 1 and 2

If you split a class C ( net into subnets with two hosts in every subnet you would think thatyou would have the first subnet with X.X.X.0 as the network adress, X.X.X.1 and X.X.X.2 as host addresses and X.X.X.3 as the broadcast address for that subnet. The next subnet starting with X.X.X.4 as the network address and so on....

But here's a catch. Since X.X.X.0 is reserved as network adress for the class C net you cant use that in a subnet. Same for the X.X.X.255 that is reserved ass the class C net broadcast address so you cant use that either. That leads to the first subnetaddress being X.X.X.4 and the last subnetaddress being X.X.X.248 (with X.X.X.251 as the broadcast for that subnet).

You lose 8 adresses by doing the subnetting (or 6 host addresses if you dont count network and broadcast addresses)

What you get is 256/4 -2 = 62 subnets
From step 1 to step 2 you have to do a little mind bungling.

As said to represent 4 possible numbers (0 being a number) you need two bits.

When you set a subnet mask you reverse the thinking.
1 means this bit is "locked" 0 mens the bit is "free"

Having need of 2 bits to represent 4 possible numbers you need two set the two least significant bits free.
this gives you
Free in this case means free for the subnet to use as host addresses.
If you have a network address that is, say, with a subnet mask of that will make the first 30 bits in the IP address locked telling the computer that it has two bits that describes hosts on the network (since the total address is 32 bits long). That leaves the network looking like this: (Network) (Host 1) (Host 2) (Broadcast)
nawafAuthor Commented:

I really appreciate the help.

I got u but
Just to clarify.
So With is I am going to get 62 subnets and 4 hosts for each subnet? right ?

Thanks again
Yep. You got it!
Accept for that it will be two hosts (two possible network addresses) since 2 addresses in each 4 address subnet is reserved for that subnets network address and broadcast address.
nawafAuthor Commented:

In the site you mentioned :

In the "example of a class C subnet "

Why they got 30 hosts ? they should be 32 host 2**5 right?

and  how did they get 6 subnet from ?

111 gives 7 (decimal)
11100000 give 224 (decimal )

how the y get 6 please


>Why they got 30 hosts ? they should be 32 host 2**5 right?

Because the first address is reserved for the network and the last for broadcast as the following cut from the same site states:
Question: What happened to and why can't these be IP addresses ? - Is the subnet's Network Id which is revserved for the physical segment (00100000). - Is the subnet's Broadcast Address (00111111)

As stated above every network or subnet has a IP address for the Physical segment and a Broadcast Address.
nawafAuthor Commented:

MaB my friend

Why you divided 256 by 4 and why divide by 2 (these are the reserverd addresses)

What you get is 256/4 -2 = 62 subnets
>and  how did they get 6 subnet from ?

Same here as example with 4 addresses on subnet.
With 32 addresses on subnet (Leaving 30 for hosts since network and broadcast addresses are "taken") you will have 256/32=8 subnets.
But as with the other example the first address ( is reserved for the class C network address this cant be used. Same for which is the broadcast address for the class C network. This makes the first and last address space unuseable as subnet.(When subnetting the first and last subnet always disappears)
Thus 256/32=8-2=6
>Why you divided 256 by 4 and why divide by 2 (these are the reserverd addresses)

256 is all possible addresses (0-255) on a class C network. When subnetting to subnets with 4 addresses in each you get 256/4=64 possible subnets.

But since two subnets disappear because of the reserved class C network address and broadcast address you have two draw two subnets from the result. 64-2=62 subnets.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nawafAuthor Commented:
Thanks a lot. Ok 300 points u deserve

This isn't easy. Hope you've "seen the light".
nawafAuthor Commented:
just one last question in the example:

what was the question to that example?

I mean the question was find the number of hosts and number of subnets or the number ?

or the number  6 segments/subnets is given and they want to find the subnet mask ?


It all goes back to the binary code.  255 in binary is 11111111.  Since an IP address is a 32 bit binary address divided into 4 sets of 8 in base 10 instead of 2 for ease of use to people.  256 would be 100000000 not 11111111.  This probably confused everyone more,, but this is the mathmatically correct answer.  
>I mean the question was find the number of hosts and number of subnets or the number ?

>or the number  6 segments/subnets is given and they want to find the subnet mask ?

I believe the second assumption is right here. 6 subnets are given and the corresponding subnetmask is derived from that by using this method.
Determine the number of Physical segments required in your network and covert to binary format. In the example below 6 segments are required

Count the number of bits required to represent the number of physical segments in binary. With 6 required subnets (Binary value is 110). Representing 6 in binary requires 3 bits

Convert the required number of bits to decimal format in high order (left to right).

Configure the 3 required bits as the first bits of the host id. The decimal value for binary 11100000 is 224. Representing a subnet mask of
The key here is that 6 is represented by 110 binary i.e three bits is needed. You can obviously use this information to directly set the subnet mask by "locking" the highest three bits (leftmost) in the last 8 bit charachter of the subnetmask giving:
    255    .     255    .    255     .    224

This would mean that if you want 10 subnets you would use the binary value for 10 which is 1010 i.e four bits are requiered thus giving the subnet:
    255     .    255    .    255     .    240

If you look at the example you will see that this actually provides you with 14 subnets but the calculation persumes that you want AT LEAST 10 subnets. You will recieve the nearest higher number of subnets with this method. The next step down is 6 subnets and that is not enough for this last example. You will always need to accept the next larger number of subnets. Meaning if you want 18 subnets you would have to accept 30, wanting 40 gives you 62 and so on...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.