Why subnet mask for IP 10.0.1.4 is 255.255.255.0?

3

Well I'm not sure whether I'm missing something here. But all I've read is that if first octet of IP is within 0 - 127 then it is categorized as Class A subnet and correspondingly Subnet Mask for this is 255.0.0.0 but when I connect my system to Apple airport then my system gets IP as 10.0.1.4 however subnet mask is 255.255.255.0 not 255.0.0.0. Please explain what I'm missing here.

Adapter Information

If there is something like for apple router subnet mask is calculated on some different flags then please let me know. This is what I'm doing currently in order to fetch subnet mask from an IP address.

if (ipAddress == null)
{
    return ClassCSubnetMask;
}
byte byteipAddressFirstOctet = ipAddress.GetAddressBytes()[0];
if (byteipAddressFirstOctet <= 127)
{
    return ClassASubnetMask;
}
else if (byteipAddressFirstOctet >= 128 && byteipAddressFirstOctet <= 191)
{
    return ClassBSubnetMask;
}
else if (byteipAddressFirstOctet >= 192 && byteipAddressFirstOctet <= 223)
{
    return ClassCSubnetMask;
}
return null;

For all those who are voting for closing this - I tried deleting this but did not work as it has answers. And in the mean while I've posted it on super user.

Thanks to everyone for waking me up on Subneting :)

Rohit

Posted 2012-06-08T13:21:14.283

Reputation: 217

2This is not a c# question. – Hans Z – 2012-06-08T13:23:32.097

Actually it will be once I found the answer to this. I need to pro grammatically fetch subnet mask. So either I can remove C# tag from here and post it another question but I thought to consolidate both things here. – Rohit – 2012-06-08T13:25:35.433

2@RohitKandhal The question as it stands doesn't even belong on this site, IMO. Your follow up question might do, however. – Adam Houldsworth – 2012-06-08T13:26:20.393

Okay. Maybe add the second part of your question to this one so people can answer them at the same time? – Hans Z – 2012-06-08T13:26:56.057

So should I post it on Programmers ? – Rohit – 2012-06-08T13:26:57.833

2@RohitKandhal You currently are not asking a programming question... I've voted to migrate it to Super User. – Adam Houldsworth – 2012-06-08T13:27:26.710

SuperUser is the site you need – Mihai Oprea – 2012-06-08T13:27:44.273

2@All do you think still I should move it to super user?? – Rohit – 2012-06-08T13:30:02.870

Is there someway I can directly move my question from stackoverflow to superuser? – Rohit – 2012-06-08T13:33:41.667

2@RohitKandhal If enough people vote to close as off-topic and select super user, it migrates automatically. – Adam Houldsworth – 2012-06-08T13:35:15.007

Close should be called Move really in many cases. People see "Closed" and think bah, unhelpful people. But if instead if said "Moved somewhere you're more likely to get help" it would be better. Anyway this is not a discussion for here :) – John Burton – 2012-06-08T14:38:46.540

1Google is your friend – mpontillo – 2012-06-10T08:08:07.893

Thanks Mike ... but I found that link when I searched for Inter-domain subnet routing.. – Rohit – 2012-06-10T12:05:15.267

Answers

3

There are certain classes of IPs that are considered private and "not routable", including all of 10.0.0.0 - 10.255.255.255, 192.168.0.0 - 192.168.255.255, and 172.16.0.0 - 172.31.255.255.

Often the subnet masks for these ranges will line up with old class boundaries, but they don't have to. Consumer equipment that you use in your home will often use a /24 (255.255.255.0) by default, even if they use an address in the 10.x.x.x range. Part of the reason for this is protection in case the device is brought into a larger network, with a larger subnet, where the device IP may conflict with something else. This give a kind of protection for that network.

Larger networks also often are divided up into smaller logical groups called vlans. These vlans may need to occupy the same large address space, but still have distinct network and broadcast addresses. So I might set up a vlan using 10.1.0.0 for the network address and set a broadcast address of 10.1.255.255 by using 255.255.0.0 for the subnet mask. Then I can have a different vlan starting 10.2.0.0 that will be separated from the first network. You can get specific about how much of an address is used for the network and how much is used for the host.

Aside from all that, with IPv4 space filling up, most of the large blocks have now been broken up, and we don't really talk about class A,B,C,D any more anyway.

Joel Coehoorn

Posted 2012-06-08T13:21:14.283

Reputation: 26 787

6

The world moved away from classful networks years ago. Now we use CIDR which allows us to allocate IP addresses more efficiently. You should request the subnet mask from the operating system.

resmon6

Posted 2012-06-08T13:21:14.283

Reputation: 491