Calculating number of subnets and host in each subnet [duplicate]

Possible Duplicate:
How does Subnetting Work?

Hi all!
I need to determine the new subnet mask showing it in dotted decimal and as a binary field, calculate the actual numbers of subnets and host in each subnet, determine if the company can subnet as desired.

Example:Company ABC has a class C IP address. It wants to have 5 subnets with a max of 25 computers on each subnet.

My solution: The default mask for the class C IP address is 255.255.255.0
There are 8 bits in the host address field: 11111111
Company ABC wants 5 subnets. The nearest possible value is 2^3 – 2 = 6.
Therefore, we take 3 top bits for the subnet field and remaining 5 bits for the host address field: ssshhhhh.
The subnet mask in our case is: 11111111 11111111 11111111 11100000
The subnet mask in dotted-decimal: 255.255.255.224
(since the corresponding bit pattern, 11100000, equates to 2^7 + 2^6+ 2^5= 128 + 64 + 32 = 224)
Actual number of subnets = 2^((number of subnet bits taken from the host) ) – 2 = 2^3– 2 = 6.
Number of hosts in each subnet = 2^((number of remaining bits in the host) ) – 2 = 2^5– 2 = 30.

Company ABC can subnet as desired.

Is it correct?

-

marked as duplicate by Zypher♦, Chris S, Zoredache, John Gardeniers, WarnerAug 5 '10 at 13:12

This question was marked as an exact duplicate of an existing question.

You don't subtract the 2 in the subnet calculation. 3 bits of subnet gives you 8 subnets. You only do that for hosts because every subnet must have a broadcast and a network ID. Also, every network must have a gateway (to be accessible to other networks) so it's common to subtract 3. – Chris S Aug 5 '10 at 1:40
Isn't it true that network and broadcast addresses cannot be used for subnet and host addresses? – user50263 Aug 5 '10 at 1:50
You have A.B.C.0/27, A.B.C.32/27, A.B.C.64/27, A.B.C.96/27, A.B.C.128/27, A.B.C.160/27, A.B.C.192/27, A.B.C.224/27. Why wouldn't you be able use A.B.C.0/27 or A.B.C.224/27? (hint: You can; there is no reason not to) – Slartibartfast Aug 5 '10 at 7:02
The network and broadcast IDs are specific to each subnet, they will no longer apply to the original subnet you're pulling the smaller subsets from. For instance, you started with a /24 and divided it into 8 /27s; there is no network that uses the /24 anymore (except external routing tables, but we're not concerned with them here). – Chris S Aug 5 '10 at 12:28