0

I'd like some help understanding subnets (CIDR).

I'm using a tool to check if an IP is in an acceptable range given a CIDR address. When I input an IP address (12.245.105.190) and check it against the same address with a subnet mask (12.245.105.190/30), any value less than 31 shows "NOT IN SUBNET" but gives a range that would seem to include the IP address:

** NOT IN SUBNET **
IPV4 ADDRESS        12.245.105.190
IPV4 NETWORK        12.245.105.190
IPV4 CIDR PREFIX    30
IPV4 RANGE START    12.245.105.188 <-- seems smaller than my IP
IPV4 RANGE END      12.245.105.193 <-- seems larger

Can you help me understand what I'm missing?

3

The subnet mask is a bit mask. The appended /30 means the netmask spans the highest 30 bits (out of 32 bits):

       12 .       245 .       105 .       190 IPv4 address decimal
0000 1100 . 1111 0101 . 0110 1001 . 1011 1110 IPv4 address binary
1111 1111   1111 1111   1111 1111   1111 1100 netmask
0000 1100 . 1111 0101 . 0110 1001 . 1011 1100 network prefix

The 30 bits to the left are the network part/prefix. The final two bits at the right side comprise the host part. This means the host portion (the two lowest bits) can be

  • 0 0
  • 0 1
  • 1 0
  • 1 1

Which are, when put together with the network prefix (first 30 bits from above)

0000 1100 . 1111 0101 . 0110 1001 . 1011 1100  
       12 .       245 .       105 .       188
0000 1100 . 1111 0101 . 0110 1001 . 1011 1101
       12 .       245 .       105 .       189
0000 1100 . 1111 0101 . 0110 1001 . 1011 1110
       12 .       245 .       105 .       190
0000 1100 . 1111 0101 . 0110 1001 . 1011 1111
       12 .       245 .       105 .       191

So there are four addresses on this subnetwork, where the first 00 and last 11 are reserved for the network and broadcast respectively. This means .188, .189, .190, and .191 are part of the subnetwork, contrary to .188 - .193 claimed by the - seemingly broken - online tool.


See also Wikipedia - Subnetwork - Internet Protocol version 4 for more details on IPv4 subnetworks generally, and network prefixes particularly.

  • So - the tool is broken! – Isaac Lubow Feb 15 '18 at 22:02
  • If you edit this answer to answer the question clearly I'll gladly accept it. – Isaac Lubow Feb 15 '18 at 22:33
  • I was on the verge of deleting the question because it turns out the tool I was using is broken - but if you assert that that is the case and that my given IP address is indeed within the range the bitmask specifies, it may be helpful to others. – Isaac Lubow Feb 16 '18 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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