Understanding IP Addressing

Posted on 2007-07-26
Last Modified: 2010-04-10
I'm teaching myself all about TCP/IP and have a question. If I have the IP address on a network of with the subnet mask and second IP address of with a subnet mask, obvisiously I can ping from

Okay, this is what I want to know, if I change to subnet mask why can I still ping it from Isn't it now on a different Network ID?

Lastly, if I change to subnet mask why can I then NOT ping it from

Bare in mind, this is a simple network with only a switch between the PC's (IP addresses), no routers etc.
Question by:DownsIT
    LVL 70

    Expert Comment

    by:Chris Dent

    > Okay, this is what I want to know, if I change to subnet mask
    > why can I still ping it from Isn't it now on a different Network ID?

    No, you're only masking 16 bits, the first two octets. That makes your network range run from: to

    Both IPs are within that range.

    > Lastly, if I change to subnet mask why can I then
    > NOT ping it from

    Something is going wrong there then. Both addresses are still on the same range. You're only changing the final octet, with everything else the same and a mask they remain in the range: to

    LVL 8

    Expert Comment

    Chris is correct, but read this for a deeper understanding:
    LVL 2

    Expert Comment

    You may have issues with your router trying to route that 6.x.x.x address on the internet.  If you are using a Linksys or D-link or some home office router that by default can only use NAT or PAT it will likely try to route that address out on to the internet.  If you are just plugging two computers in to a switch or together via a cross-over cable your original experiment should have worked.
    LVL 2

    Expert Comment

    Why not alter your experiment by using some RFC1918 Addresses like.  192.168.x.x 10.x.x.x 172.16.x.x that way no matter what kind of network equipment you are using you could still experiment with the masking and it will work as intended.

    Author Comment

    Thank you Chris-Dent, I think I understand I little better now. Is this a correct statement:

    All IP addresses are in the same Network ID (Class A,, the only change is the subnet they belong to which is depicted by the subnet mark. However, because there is no routing happening, all IP addresses are fooled into thinking they are on the same subnet because the 2nd and 3rd octet are the same.

    I believe the didn't work because I have an exterior router on the network, thank NickGT20, your comments made me think about that.
    LVL 70

    Accepted Solution


    You need to take a step back from that a little.

    Forget about the Router, you're only looking as traffic within a Subnet. There is no routing there, everything is directly connected. They're not fooled into being on the same network, they *are* on the same network.

    This subject gets quite involved, which makes it difficult to explain in short blocks.

    When you're looking at the Subnet Masks you're assigning you're speaking of Classless Subnets. In that case Class A has no place, it's irrelevant to the network in use. So don't worry about the fact that the network you've picked, is within the Class A Classful block doesn't have any bearing on routing and Network Address assignment.

    To see the effect of a Subnet Mask it helps to go back to Binary (well hopefully it'll be clearer). If we take a nice simple IP Address like we write that in Binary like this:


    Our Subnet Mask of is written like this:


    As the name suggests the Subnet Mask is hiding some of the bits setting up for a smaller range than just to This is just a practical way to split up the range, after all, we all want to share that so we need to ensure we can split it up into manageable blocks.

    If we apply that mask to the IP Address you've got you end up with:


    Where xxxxxxxx are all the bits we've Masked and so unavailable to the Network Range we've chosen. A little more binary, that makes the first IP Address in our range look like this:


    And the last like this:


    Putting that back into Decimal we have x.0.0.0 and x.255.255.255 respectively. As long as the first number, represented by x, is the same in each case then the addresses are part of the same network.

    Quickly applying the same principle to the smaller ranges you picked, you have a mask like this:


    Hopefully you'll see that it means you've only got the last two Octets (known as such because each of the four is made up of 8 Bits) available to your network range. Meaning the first two octets must be the same in each case for the IP Addresses to be in the same range.

    The same applies for your last range, except all of the first three must match for them to share a network range.

    Of course, it's not quite a clear-cut as that. You can have subnet masks other than the three mentioned above.

    I have a page on IP Maths on my website here:

    Which looks at a few more of the details of converting from and to the Binary forms, and why we'd want to do that anyway.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Some time ago I was asked to set up a web portal PC to put at our entrance. When customers arrive, they could see a webpage 'promoting' our company. So I tried to set up a windows 7 PC as a kiosk PC.......... I will spare you all the annoyances I…
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now