# How do you calculate mask from specific IP?

Member Posts: 5 ■□□□□□□□□□
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

• CCNA 200-120 Member Posts: 484 ■■■□□□□□□□
I dont get the question. Your IP address is Class B, therefore has a default mask of 255.
255.0.0
Cisco NetAcad Cuyamaca College
A.S. LAN Management 2010 Grossmont College
B.S. I.T. Management 2013 National University
• Member Posts: 1,740 ■■■■□□□□□□
Technically the subnet that IP belongs to is a Class B subnet, so it would have a mask of 255.255.0.0. What you need to do is become more familiar with binary bits. There used to be a really good subnetting thread on the CCNA forum, I believe. When I find it, I'll post a link.
2017 Certification Goals:
CCNP R/S
• Senior Member King City, CAMember Posts: 646 ■■■■■■□□□□
Subnet masks are not "calculated" from IP addresses. They are administratively given, along with its IP address, to signify which part of the address should be designated for the network, and the rest for the address. There are five "default" subnet masks as described in RFC 1918, based on the number in the FIRST octet of the address:

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 Business Administration in Information Technology Management - Western Governors University
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
• Member Posts: 579 ■■■■□□□□□□
PCTechLinc wrote: »
snip
A excellent and clear explanation. I think most people have trouble getting their head around certain parts of this topic because some of it is derived from the Math while other things are conventions dictated by the creators of IP. The problem arises when people try to apply mathematics principles to things which are just arbitrarily imposed conventions.
PCTechLinc wrote: »
There are five "default" subnet masks as described in RFC 1918, based on the number in the FIRST octet of the address:

RFC791/870 talk about Classful addressing RFC1918 is Private IP Networks might have got your RFCs mixed up

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.
• Senior Member King City, CAMember Posts: 646 ■■■■■■□□□□
dontstop wrote: »
RFC791/870 talk about Classful addressing RFC1918 is Private IP Networks might have got your RFCs mixed up

Oops... I've been known to mix things up once in my life.
Master of Business Administration in Information Technology Management - Western Governors University
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
• Member Posts: 5 ■□□□□□□□□□
But that's my question. Why does the calculator say 255.255.255.0 when you guys (and the classing scheme) sais 255.255.0.0?

Is the calculator wrong?
• Member Posts: 532 ■■■■□□□□□□
It looks like someone input the 24 into the field. Maybe based on the example that was above that field. Maybe you went to that same link and it was all ready there. Who knows. PCTechLinc did a great job breaking this down.
Completed: ITIL-F, A+, S+, CCENT, CCNA R|S
In Progress: Linux+/LPIC-1, Python, Bash
Upcoming: eJPT, C|EH, CSA+, CCNA-Sec, PA-ACE
• Member Posts: 579 ■■■■□□□□□□
PCTechLinc wrote: »
Oops... I've been known to mix things up once in my life.

I only picked it up because I also do the same! RFC1918 is always the first RFC on my brain
• Senior Member King City, CAMember Posts: 646 ■■■■■■□□□□
If you go to the website, it has the address 192.168.0.1 and 24 pre-filled in the fields. When you type in a new address and click Calculate, it does not update the mask for you.

Here is another website that helps with calculations: Online IP Subnet Calculator
Master of Business Administration in Information Technology Management - Western Governors University
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
• Member Posts: 579 ■■■■□□□□□□
But that's my question. Why does the calculator say 255.255.255.0 when you guys (and the classing scheme) sais 255.255.0.0?

Is the calculator wrong?

From the blurb above the calculator on: http://jodies.de/ipcalc
[FONT=&amp]Enter your netmask(s) in [/FONT]CIDR[FONT=&amp] notation (/25) or dotted decimals (255.255.255.0). Inverse netmasks are recognized. If you omit the netmask ipcalc uses the default netmask for the class of your network.[/FONT]

Try your calculations but this time clear out the netmask field to use the natural mask that /24 that shows up by default is just a default value the developer has set for the sake of explaining how the calculator itself works (what input it requires).

I personally use: http://www.solarwinds.com/free-tools/advanced-subnet-calculator for the old school charm.
• CCNA 200-120 Member Posts: 484 ■■■□□□□□□□
PCTechLinc wrote: »

Class A = 0-127
Class B = 128-191
Class C = 192-223

127 is NOT part of Class A. It's a loopback

The range should be 1-126 then 128-191
Cisco NetAcad Cuyamaca College
A.S. LAN Management 2010 Grossmont College
B.S. I.T. Management 2013 National University
• Senior Member King City, CAMember Posts: 646 ■■■■■■□□□□
When I teach IP addressing, I immediately start with the binary rules:

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 Business Administration in Information Technology Management - Western Governors University
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
• Member Posts: 5 ■□□□□□□□□□
Really? I thought 0.0.0.0 was universal gateway and not part of any class?

It's interesting (and confusing as F-word) to learn this stuff when people say different things
• Senior Member King City, CAMember Posts: 646 ■■■■■■□□□□
Really? I thought 0.0.0.0 was universal gateway and not part of any class?

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 Business Administration in Information Technology Management - Western Governors University
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
• Member Posts: 1 ■□□□□□□□□□
Really? I thought 0.0.0.0 was universal gateway and not part of any class?

It's interesting (and confusing as F-word) to learn this stuff when people say different things
As PCTechLinc alludes to, you bring up a great point of debate in the industry. I'm also a numbers-first guy, in that I always choose to list Class A's range as 0-127 because of the first-octet bit pattern. In other words, any first-octet starting with a binary 0 is Class A, so 0 and 127 in decimal apply.

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.
• MSIT InfoSec, CISSP, SSCP, GSEC, EnCE, C|EH, CySA+, PenTest+, CASP+, Security+ Surf City, USAAdmin Posts: 12,191 Admin
tskandier said:
...so the argument of Class A being restricted to first-octet decimal values of 1-126 is a valid one.

From RFC 997:
The class A network number 127 is assigned the "loopback"        function, that is, a datagram sent by a higher level protocol to a network 127 address should loop back inside the host.  No datagram "sent" to a network 127 address should ever appear on any network anywhere.