How do you calculate what the subnet mask is from just an I.P. address?

Mark May 10, 2013
Pinterest Stumbleupon Whatsapp

How do you calculate what the subnet mask is from just an I.P. address?

  1. Rajaa Chowdhury
    May 11, 2013 at 12:32 am

    I think Jan Fritsch & Bruce Epper has summed it up pretty effectively. :) Good explanations.

    • Rajaa Chowdhury
      May 11, 2013 at 12:33 am

      Also the link given by Alan Wade is so very educative. All the above are great advice and resource.

  2. Bruce Epper
    May 10, 2013 at 9:11 pm

    For unicast addressing:

    Class A networks which can have up to 128 networks of 16.7 million hosts each will normally have a netmask of 255.0.0.0 and an IP range of 0.0.0.0 - 127.255.255.255

    Class B networks which can have up to 16,384 networks with up to 65,534 hosts each generally will have a netmask of 255.255.0.0 and an IP range of 128.0.0.0 - 191.255.255.255.

    Class C networks can have up to a bit more than 2 million networks of 254 hosts each with a netmask of 255.255.255.0 and and IP range of 192.0.0.0 - 223.255.255.255

    As far as "calculating" a mask from an IP address, in general, it can't be done. The IP address and subnet mask are two halves of a whole which is used to determine what part of the IP address is the network address and what part is the host address. This is done by design by the network engineers/architects in order to optimize resources (number of networks required and number of expected hosts per network) for each particular situation and will be a predetermined pairing, not a calculated value.

    If a network is set up as a general class A, B, or C network, in most cases you can assume that the default subnet masks listed above were used. For example, most home networks will be using the private address range of the class C network (192.168.x.x) and will thus have the default subnet mask of 255.255.255.0.

  3. Jan Fritsch
    May 10, 2013 at 8:40 pm

    You can't calculate the subnet mask from a single IP-Address. You get the default subnet mask via the class.

    Class A (0 - 126.255.255.255) = 255.0.0.0
    Class B (128 - 191.255.255.255) = 255.255.0.0
    Class C (192 - 223.255.255.255) = 255.255.255.0

    For subnets you'd need more data like the network id, broadcast address or CIDR in addition to determine the subnet mask

  4. Alan Wade
    May 10, 2013 at 8:23 pm

    This pretty much answer your question but maybe in reverse: http://www.pointz.com/spudpage/subnets.html