Understanding IP Addressing

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.
Who is Participating?
Chris DentConnect With a Mentor PowerShell DeveloperCommented:

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.

Chris DentPowerShell DeveloperCommented:

> 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

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

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

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.
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.
DownsITAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.