Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 :)

share|improve this question

migrated from stackoverflow.com Jun 11 '12 at 7:35

This question came from our site for professional and enthusiast programmers.

1  
This is not a c# question. –  Hans Z Jun 8 '12 at 13:23
1  
@RohitKandhal The question as it stands doesn't even belong on this site, IMO. Your follow up question might do, however. –  Adam Houldsworth Jun 8 '12 at 13:26
1  
@RohitKandhal You currently are not asking a programming question... I've voted to migrate it to Super User. –  Adam Houldsworth Jun 8 '12 at 13:27
1  
@All do you think still I should move it to super user?? –  Rohit Kandhal Jun 8 '12 at 13:30
1  
@RohitKandhal If enough people vote to close as off-topic and select super user, it migrates automatically. –  Adam Houldsworth Jun 8 '12 at 13:35

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.