3

I have an IP address

12.23.34.22

I need to find the network prefix for this IP Address. For that I need to find the subnet mask and then count the number of contiguous 1s to get the network prefix.

How can we calculate the subnet mask (255.x.x.x) for this given IP ?

Ron Maupin
  • 102,040
  • 26
  • 123
  • 202
user544079
  • 133
  • 1
  • 1
  • 4

3 Answers3

10

How can we calculate the subnet mask (255.x.x.x) for this given IP ?

You can't. To find the prefix, you need the address and mask, or the address and prefix length.

See the answers to this question on how to calculate everything.

Ron Maupin
  • 102,040
  • 26
  • 123
  • 202
4

A subnet mask is a 32 bit value that allows the device that's receiving ip packets to distinguish the network ID portion of the IP address from the host ID portion of the IP address, so without a subnet mask that can be represented in form of a 32 value like (255.0.0.0) or slash-notation (/8) it is impossible to identify the network prefix of an IP address.

Ron Maupin
  • 102,040
  • 26
  • 123
  • 202
kenphor
  • 84
  • 2
0

I think you need to know if it's classful or not. if it's classful then you can use the default subnet mask of class A which is 255.0.0.0 and so the network address will be 12.0.0.0.

Ron Maupin
  • 102,040
  • 26
  • 123
  • 202
sammiie
  • 1
  • 1