1

Let's assume I don't know what my IP range is, or my default gateway, but I know my IP address is 192.168.5.38 and my CIDR Range is /23.

How do I know what my IP range is?

Is my range

192.168.4.0-192.168.5.255

or

192.168.5.0-192.168.6.255

Can we only work out this if we know the default gateway?

Please note I'm not asking what tools can provide this information, this is a thought exercise. I'm trying to understand how you would know the range when faced with a situation like this.

Thanks!

Answer:

thanks to @g_bor down below - they helped me understand how you work out the range. You do it by ANDing the binary outputs of both IP address and Subnet mask.

IP address: 192.168.5.38

Binary

11000000.10101000.00000101.00100110

Subnet Mask: /23 (255.255.254.0)

Binary:

11000000.10101000.00000100.00000000

If we AND them together (1 AND 1 = 1, 0 AND 0 = 0, 1 AND 0 = 0) we get

11000000.10101000.00000100.00000000

which is IP Range:

192.168.4.0
Chris S
  • 113
  • 5

3 Answers3

4

192.168.5.38 is in binary: 11000000.10101000.00000101.00100110. The netmask is: 11111111.11111111.11111110.00000000. (starts with 23 1-s) The network portion of this address is: 11000000.10101000.00000100.00000000. This is: 192.168.4.0, the first address in the range. The last is: 192.168.5.255, as we have to set all places to ones, where the netmask has 0-s. So the range is: 192.168.4.0-192.168.5.255.

g_bor
  • 276
  • 1
  • 9
  • Thanks @g_bor this makes sense now. I was not thinking in terms of binary values, and therefore forgot the 2^x power values dictate where the range starts. Marked as correct. – Chris S Sep 10 '19 at 12:56
2

You don't even need the default gateway, the latter range isn't valid, simple as that. Valid /23's are 192.168.0.0/23, 192.168.2.0/23, 192.168.4.0/23, 192.168.6.0/23, etc.

bodgit
  • 4,661
  • 13
  • 26
2

How do I know what my IP range is?

Simple math.

All the first 23 bits are identical.

I generally use http://jodies.de/ipcalc? for doing that fast and it returns...

HostMin: 192.168.4.1 11000000.10101000.0000010 0.00000001 HostMax: 192.168.5.254 11000000.10101000.0000010 1.11111110

Simple like that. It is 4-5 because 6 would have a different bit in the 23 that have to be identical.

TomTom
  • 50,857
  • 7
  • 52
  • 134