How do you calculate mask from specific IP?

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

Comments

  • mikeybinecmikeybinec Senior Member Posts: 482Member ■■■□□□□□□□
    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
  • MAC_AddyMAC_Addy Posts: 1,740Member ■■■■□□□□□□
    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
  • PCTechLincPCTechLinc Senior Member King City, CAPosts: 600Member ■■■■■□□□□□
    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
  • dontstopdontstop Posts: 566Member ■■■■□□□□□□
    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.
  • PCTechLincPCTechLinc Senior Member King City, CAPosts: 600Member ■■■■■□□□□□
    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. icon_razz.gif
    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
  • SwedishTechSwedishTech Posts: 5Member ■□□□□□□□□□
    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?
  • 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
  • dontstopdontstop Posts: 566Member ■■■■□□□□□□
    PCTechLinc wrote: »
    Oops... I've been known to mix things up once in my life. icon_razz.gif

    icon_lol.gif I only picked it up because I also do the same! RFC1918 is always the first RFC on my brain
  • PCTechLincPCTechLinc Senior Member King City, CAPosts: 600Member ■■■■■□□□□□
    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
  • dontstopdontstop Posts: 566Member ■■■■□□□□□□
    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.
  • mikeybinecmikeybinec Senior Member Posts: 482Member ■■■□□□□□□□
    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
  • PCTechLincPCTechLinc Senior Member King City, CAPosts: 600Member ■■■■■□□□□□
    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
  • SwedishTechSwedishTech Posts: 5Member ■□□□□□□□□□
    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 :)
  • PCTechLincPCTechLinc Senior Member King City, CAPosts: 600Member ■■■■■□□□□□
    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
Sign In or Register to comment.