What's the correct way to get the subnet mask?

wasteoftimewasteoftime Member Posts: 2 ■□□□□□□□□□
edited November 2019 in CCNA & CCENT
They give me the IP address, number of hosts, and number of subnets.
So I've read somewhere that there are two methods:
 
Method A ) Using the number of subnets needed.
Method B ) Using the number of hosts needed.

Let's see an example:

IP is 10.253.113.0/25. We need 8 subnets with 10 hosts each one. 
Method A ) 3 bits are required for 8 subnets, so 25+3=28, so our subnet mask is /28.
Method B ) 4 bits are required for 10 hosts, so if an IPv4 address has 32 bits, and we only need 4 for hosts, we do 32-4 = 28, so our subnet mask is /28.
Great. Amazing. Awesome. So both methods are valid.

Let's see another example:

IP is 146.201.0.0/16. We need 126 subnets with 126 hosts each one.
Method A ) 7 bits are required for 126 subnets, so 16+7=23, so our subnet mask is /23.
Method B ) 7 bits are required for 126 hosts, so if an IPv4 address has 32 bits, and we only need 7 bits for hosts, we do 32-7 = 25, so our subnet mask is /25.

In this example the subnet mask doesn't match. So both methods aren't valid? Which method would you use if you get asked the second example in a multiple-choice question and the answers are: a) 23 b) 24 c) 25 d) 26? (edit: previously it was a) 24 b) 25 c) 26 d) 27)
Or just please explain what I'm doing wrong, if anything.
 

Best Answers

  • wasteoftimewasteoftime Member Posts: 2 ■□□□□□□□□□
    Answer ✓
    I would choose answer a.  My reason:  it allows me to fulfill both requirements.  Granted, 256 networks is considerably more than the needed 126, it would still allow me to have at least 126 hosts per network (254).  So it works for both, if not as elegantly as the first exam you gave. 
    Actually I made a mistake. I intended to include /23 also as a possible answer so the logical choice would be between /23 and /25. I edited my original message. My bad. Sorry.
    In any case, you surprised me with your pick, because the tests usually work in an "only what's required" basis, like: "get the netmask that allows at least this, but no more than this". So /23 fits for 126 subnets and /25 fits for 126 hosts. Note that I haven't actually seen this in a real question because the ones I've been practicing with always match (both method A and B give the same result). But I asked myself, what if they didn't?
    Maybe I'm just wasting my time because a question like this will never happen. I just wanted to be prepared for any scenario.
Sign In or Register to comment.