Networking – Why subnet mask for IP 10.0.1.4 is 255.255.255.0

networking

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 🙂

Best Answer

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.

Related Question