How do you calculate mask from specific IP?

in CCNA & CCENT
I'm sorry if this has been asked, I've watched basicly every (well, almost) subnetting video on youtube and I still don't get the basics of IP addressing and masks. When I google "How do you calculate mask from IP" I can't find an actual answer to my question.
So if I have the made-up example of the IP:
145.10.0.7
How do I calculate what mask it has? According to this calculator the mask is: 255.255.255.0 = 24
What? Where did this number even come from? The default mask of a class B address is 255.255.0.0, and the number of bits that are on is 7 in total in the IP address. Shouldn't the mask be /7 or 255.255.7.0 = 23?
All I find is articles explaining subnetting. But how can I understand subnetting if I don't even know how to calculate the mask from a specific IP address. Thanks
So if I have the made-up example of the IP:
145.10.0.7
How do I calculate what mask it has? According to this calculator the mask is: 255.255.255.0 = 24
What? Where did this number even come from? The default mask of a class B address is 255.255.0.0, and the number of bits that are on is 7 in total in the IP address. Shouldn't the mask be /7 or 255.255.7.0 = 23?
All I find is articles explaining subnetting. But how can I understand subnetting if I don't even know how to calculate the mask from a specific IP address. Thanks
Comments
255.0.0
A.S. LAN Management 2010 Grossmont College
B.S. I.T. Management 2013 National University
CCNP R/S
Class A = 0-127
Class B = 128-191
Class C = 192-223
Class D (Multicasting) = 224-239
Class E (Government/Experimental) = 240-255
So in your example above, 145.10.0.7 has 145 in the first octet, therefore the default Class is B, which would be 255.255.0.0, or 145.10.0.7/16.
Subnetting comes into play when you have ownership over a network ID, and you want to "break it up" into smaller networks. That's the start of the basic understanding of IP addressing. When I teach my students about subnetting, I usually spend about 4 hours talking about addressing (what is an IP address and WHY are the Classes the way they are), and up to 20 hours talking about subnetting and working through examples.
Master of Science in Information Security and Assurance - Western Governors University
Bachelor of Science in Network Administration - Western Governors University
Associate of Applied Science x4 - Heald College
RFC791/870 talk about Classful addressing RFC1918 is Private IP Networks
Just to add to what PCTechLinc said; Some textbooks will also call these masks "Natural masks" or "Classful Masks". These are dictated by the standards in order to create the different sized networks, once upon a time the idea was to have the following:
- Mega companies: Class A
- Big companies: Class B
- Small companies: Class C
As such the masks were created in order to divvy up the address space in a way to reflect these size requirements. Unfortunately this was at a time when mainstream Internet access wasn't a thing and this structure wouldn't make sense for very long.Oops... I've been known to mix things up once in my life.
Master of Science in Information Security and Assurance - Western Governors University
Bachelor of Science in Network Administration - Western Governors University
Associate of Applied Science x4 - Heald College
Is the calculator wrong?
In Progress: Linux+/LPIC-1, Python, Bash
Upcoming: eJPT, C|EH, CSA+, CCNA-Sec, PA-ACE
Here is another website that helps with calculations: Online IP Subnet Calculator
Master of Science in Information Security and Assurance - Western Governors University
Bachelor of Science in Network Administration - Western Governors University
Associate of Applied Science x4 - Heald College
From the blurb above the calculator on: http://jodies.de/ipcalc
Try your calculations but this time clear out the netmask field to use the natural mask
I personally use: http://www.solarwinds.com/free-tools/advanced-subnet-calculator for the old school charm.
127 is NOT part of Class A. It's a loopback
The range should be 1-126 then 128-191
A.S. LAN Management 2010 Grossmont College
B.S. I.T. Management 2013 National University
Class A Addresses: The FIRST binary digit on the left must start with a 0, range being 00000000 to 01111111 = 0 - 127
Class B Addresses: The FIRST binary digits must start with 10, range being 10000000 to 10111111 = 128 - 191
Class C Addresses: The FIRST binary digits must start with 110, range being 11000000 to 11011111 = 192 - 223
Class D Addresses: The FIRST binary digits must start with 1110, range being 11100000 to 11101111 = 224 - 239
Class E Addresses: The FIRST binary digits must start with 1111, range being 11110000 to 11111111 = 240 - 255
The fact that 127 is a loopback range is unimportant. The math doesn't lie.
Master of Science in Information Security and Assurance - Western Governors University
Bachelor of Science in Network Administration - Western Governors University
Associate of Applied Science x4 - Heald College
It's interesting (and confusing as F-word) to learn this stuff when people say different things
For your first point, the categories only reference the very first octet, not the entire address. They way I look at it is just understanding the classifications of the numbers themselves. For Class A being 0 - 127, those are determined by the binary digits as I referenced by the rules, NOT their intended purpose. The intended purpose is just a label; it doesn't invalidate their being numbers.
For your second point, that is exactly true, since as an instructor, I need to make sure I do my very best to get the correct information to my students, especially when published information is different everywhere you look. RFC's, typos, remembering facts incorrectly; they are all difficult to keep straight. It's like I tell everyone: EVERYONE will get something wrong eventually, either on purpose to mislead you, or accidentally.
Master of Science in Information Security and Assurance - Western Governors University
Bachelor of Science in Network Administration - Western Governors University
Associate of Applied Science x4 - Heald College
Having said that, there's also a way of thinking of the five classes, in which the first three, A through C, are considered the unicast ranges, meaning you can configure those addresses on individual interfaces, making them useful as source or destination addresses. Certainly, 0 and 127 are not able to be used this way, so the argument of Class A being restricted to first-octet decimal values of 1-126 is a valid one.
For completeness, Class D addresses are used as multicast addresses, which, like broadcast addresses, are valid only for use as destination addresses, never source, making them invalid for assignment to network interfaces. Class E addresses represent an unfortunate waste of 256 mega-addresses, owing to early shortsightedness (and I still haven't seen a single "experiment" performed with them, so I don't buy that label) and can never be assigned to any network interface.
In fact, the only Class E address that can be considered usable, and then, only as a destination address, is 255.255.255.255, which is the local broadcast, used when communicating with all interfaces on the local link, including the sender's default router, and is used for such things as ARP requests and two or four of the four DHCP stages, depending upon how DHCP is implemented by the server.
When taking certification exams, any question can be written by any author, theoretically. Therefore, keep in mind that a portion of the technical world thinks of 0-127 as being the correct answer, while another part considers 1-126 to be the valid range. The good news is that I have never seen a certification question (and I've seen a lot!) that asks you to choose between the two, so pick your favorite and stick with it but also keep an open mind about the other option and its arguable validity.
From RFC 997:
Forum Admin at www.techexams.net
--
LinkedIn: www.linkedin.com/in/jamesdmurray
Twitter: www.twitter.com/jdmurray