3

This question already has an answer here:

I was trying to do an exercise where we have a range of IPv4 addresses and we need to convert it both to "prefix notation", e.g. a.b.c.d/x, and to "address/mask".

Now, apparently, the following range 121.34.56.64–121.34.56.128 can neither expressed in prefix notation nor in address/mask. Why is that? I mean, they have the first 24 bits in common, so I would express the range as 121.34.56.64/24 in prefix notation.

Other ranges that I do not understand why they cannot be assigned a prefix notation and an address/mask notation:

  • 128.131.9.0–128.131.9.192
  • 93.20.10.0–93.20.11.0
  • 128.242.138.0–128.242.139.127

Maybe I am just confused about how these prefixes and masks are obtained. So, in general, which ranges cannot be expressed in prefix notation and prefix/mask notation? Is there a time where it is possible to express a range in prefix notation but not in prefix-mask (or vice-versa)?

marked as duplicate by Ron Maupin ip Mar 29 at 3:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide your own answer and accept it. – Ron Maupin Aug 13 '17 at 0:37
8

The issue is that you end up comparing unequal things when you say "I would express the range as 121.34.56.64/24 in prefix notation"

The range 121.34.56.64 to 121.34.56.128 is contained in 121.34.56.64/24 (which is actually the 256 IPs from 121.34.56.0 to .255), but the two are not equivalent.

The reason that 121.34.56.64-128 cannot be expressed as a single prefix is because of that last 128 IP. Up to 127, the 25th bit of the IP is a 0. At 128 it becomes a 1.

As a result, a single mask covering all those IPs can only be at most 24 bits long, and that results in a longer IP range than you are looking for. So the best you can do would be 121.34.56.64/26 (from .64 to .127) and then add a .32 to cover that last .128.

The other examples are similar. If you manage to find a single mask that covers all the IPs in the range, you will find that it also covers a bunch of other IPs before or after the ones you want. So to cover these ranges exactly, you need to assemble several smaller IP ranges.

  • You say that 121.34.56.64/24 actually covers more addresses than those that I am required to specify. Could you please give an example of an address that is included and should not be included? And why? Then you say that it covers actually from 121.34.54.0 to 121.34.54.255. I don't understand why. Why did you change the third octet? – nbro Jan 20 '16 at 13:41
  • Sorry, I mis-typed the 3d octet => I fixed that. – Jeremy Gibbons Jan 20 '16 at 14:12
  • 121.34.56.64/24 does not mean 256 IPs (/24 size) starting at .64. It means all IPs that have the same first 24 bits as 121.34.56.64. And if you write them out in binary, that comes to 121.34.56.0 to 121.34.56.255 – Jeremy Gibbons Jan 20 '16 at 14:14
1

representing the IPV4 by address MASK , prefix or wildcard mask all are equivalent but its depend on two things
1- if you follow classful or classless IPV4 presentation , for example if you follow classful style to present the IPV4 ,you can't present 121.34.56.X/24 OR 121.34.56.0 mask 255.255.255.0 because it is class A , as you know class A is 255.0.0.0 mask or /8 prefix .
2- the command on the IOS you will configure this IPV4 for it , for example you can't present IPV4 in form of IP/Prefix for certain interface in IOS but you can do so in NXOS , for EIGRP IPV4 configuration should occur in form of address and wildcard mask.

1

Now, apparently, the following range 121.34.56.64–121.34.56.128 can neither expressed in prefix notation nor in address/mask. Why is that? I mean, they have the first 24 bits in common, so I would express the range as 121.34.56.64/24 in prefix notation.

Because 121.34.56.64/24 includes the range 121.34.56.64–121.34.56.128 but ALSO includes OTHER addresses not belonging to the range 121.34.56.64–121.34.56.128.

Maybe I am just confused about how these prefixes and masks are obtained. So, in general, which ranges cannot be expressed in prefix notation and prefix/mask notation?

You can write a range A-B as prefix notation when:

  1. The first address A of the range has a sequence of H x 0's bits as least significant bits.
  2. The last address B of the range shares all the same (32-H) bits from A, AND has H x 1's for the least significant bits.

For instance:

A = 1.1.240.0 = 00000001.00000001.11110000.00000000
B = 1.1.243.255 = 00000001.00000001.11110011.11111111
H = 10 bits

So you can write A-B as A/(32-H): 1.1.240.0-1.1.243.255 as 1.1.240.0/22

Is there a time where it is possible to express a range in prefix notation but not in prefix-mask (or vice-versa)?

No.

  • Lets take as an example the following range: 93.20.10.0-93.20.11.0. 10 in binary is 00001010 and 11 is 00001011, they share the same prefix of 0000101, but these range cannot be expressed as prefix notation. Now, take this range 121.232.111.128–121.232.111.255 as example. 128 is represented as 10000000 and 255 is 11111111, they share the same prefix of 1, and this can be represented in prefix notation. Why wonder what's the difference? – nbro Jan 20 '16 at 13:12
  • 1
    @nbro In your example, 93.20.10.0-93.20.11.0 meets the requirement (1) , and half of requirement (2), but not the part of (2) about B having full H x 1's as least significant bits. – Everton Jan 20 '16 at 13:45
  • It seems that your two rules make the game. Although I still haven't understood them fully. – nbro Jan 20 '16 at 13:57
  • 1
    @nbro Here is the much simpler version: Given range A-B, can you find a cut point N, in bits, where the first N bits are perfectly shared by A and B, and the remaining bits (H=32-N) are all-0 in A and all-1 in B? If yes, A-B can be written as A/N. :-) – Everton Jan 20 '16 at 14:17
1

You must distinguish "ip range" and "ip network".

Those terms are commonly used for IP networks, but they are not equivalent.

An IP range is any number of contiguous IP addresses.

192.168.1.1-192.168.1.10 is a range. but it's not a network, so it cannot be written with neither a prefix or a subnet mask notation.

192.168.1.0/24 is a network (it contain the range of ip addresses 192.168.1.0 - 192.168.1.255)

121.34.56.64 - 121.34.56.128 is also a range and not a network. The nearest network is 121.34.56.64/26 which contains the range 121.34.56.64-121.34.56.127 (and not 128).

Or you could write it as the sum of 2 networks : 121.34.56.64/26 and 121.34.45.128/32 (this network contain only 1 IP address)

-edited- 93.20.10.0–93.20.11.0 is not a network

128.242.138.0–128.242.139.127 corresond to 2 networks : 128.242.138.0/24 and 128.242.139/25

If you use Windows, download the solarwinds subnet calculator (it's free) to easilly see networks boundaries. You can find other network calculators online.

  • Sorry, but from the solutions that I have, for the range 93.20.10.0–93.20.11.0 there should not exist a prefix notation...Indeed, according to the rules provided by @Everton, my solutions should be correct. – nbro Jan 20 '16 at 14:35
  • you're right sorry for the confusion. – JFL Jan 20 '16 at 14:44

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