# Class B subnetting and subnet mask

i have the following class B : 172.16.0.0 /16

as in the image :

i want someone to confirm that the solution is correct for the first 3 sub-networks :

we will take 4 bits to have 16 networks that can fit the request , so my new subnet mask is : 255.255.240 .0

now , the first three networks are (the magic number is 16 ):

First network : 172.16.0.0

first valid IP : 172.16.0.1

Last Valid IP: 172.16.15.254

==========================

Second network : 172.16.16.0

first valid IP : 172.16.16.1

Last Valid IP: 172.16.31.254

==========================

Third network : 172.16.32.0

first valid IP : 172.16.32.1

Last Valid IP: 172.16.47.254

==========================

so is this solution is correct for the first three subnets ?!

i have another question which : What is the full subnet mask for address 172.16.5.10/28?

but i have this friend that told this is not correct because class B can't have such subnet mask that goes with 28 bits for network !!!!

my answer was it's ok we can take up to 30 bits for the network and at least 2 bits for the host for every class(A,B,C) of the IPs because taking more than 30 bits (example: if take 31 bit for networks would resulting for the law 2^h-2 (so we have one bit left for the hosts h=1 ) ---> 2^1-2=2-2=0 and that's not possible to have 0 hosts per network !!! )

so please correct me again if i'm wrong or there is something i'm missing in the subnetting thing

thank you all , Kind regards

• Ask your friend this question: A large university has a class B network. Yay, lots of space. They have 12 Ethernet networks in different departments they want to connect to the Internet. That's not a lot, pretty reasonable. What does he think they do? No CIDR doesn't mean no VLSM. VLSM came long before CIDR. – David Schwartz Jan 23 '17 at 12:27
• thanks for the replay my friend , hhhh , sure i will ask him that , but what do you think of my solution above in both examples ?! is it correct ?! – Wissam A Jackal Jan 23 '17 at 12:32
• The C in CIDR stands for "Class-less", and is effectively the same as variable length subnet masks. While we still refer to classes when talking about /8 /16 /24 networks, it is just convention. So you can split your allocated address space up however you want. I haven't checked your math but your approach is sound. – Paul Jan 23 '17 at 12:32
• I didn't look at it all that closely, but it looked correct on a quick skim. – David Schwartz Jan 23 '17 at 12:32
• @Paul And the "IDR" stands for inter-domain routing, which this subnet exercise has nothing to do with. So whether we do or don't have CIDR is not relevant. That's the mistake his friend made. (His friend likely reasoned that because we're saying this is a class B address, that means we don't have CIDR. But so what? The question is about subnetting, not inter-domain routing.) – David Schwartz Jan 23 '17 at 12:33

so is this solution is correct for the first three subnets ?!

Yes, that looks right.

Regardless of the address, `/28` always translates to `255.255.255.240`.

``````       8↓         16↓         24↓    28↓
1111'1111 . 1111'1111 . 1111'1111 . 1111'0000
``````

but i have this friend that told this is not correct because class B can't have such subnet mask that goes with 28 bits for network !!!!

Your friend is wrong on several counts.

First, it does not matter if it was class B ­twenty years ago. Now it's a `/28` network, nothing more.

Second, when subnetting was introduced in 1983, the whole point was that you could have a 'network' length longer than what the class imposes. With subnetting, you could take a "class B" (16 network bits) and divide it into several smaller networks with whatever amount of bits you wanted — 17, 20, 24, and so on.

That's why you have subnet masks in the first place ­— because they, not the class number, define the network bits and host bits. The subnet mask for a `/28` (IPv4) is `255.255.255.240`, always.

(example: if take 31 bit for networks would resulting for the law 2^h-2 (so we have one bit left for the hosts h=1 ) ---> 2^1-2=2-2=0 and that's not possible to have 0 hosts per network !!! )

`/31` is special: it's used for peer-to-peer links, where broadcast is unnecessary. (Not all software supports it though. It's taking Mikrotik 17 years to implement it...)