# CIDR

You use CIDR notation to get the # of IP addresses that are available in that block. It does not, however, specify where the range has to begin or end – the only requirement is that they be sequential.

Say, for example, that you wanted to assign 8 IP addresses for friends when coming to visit for a LAN party. You also want them to start at the 192.168.1.16 IP address. That means they'd get .16 through .23 as their own. Here's what the CIDR would look like:

192.168.1.16/29

The mathematical formula for determining the size of the **range** of IP addresses is:

2 ^ (32 - /$x)

where $x represents the /29 above.

Using that case, 32-29 is 3, so 2 to the power of 3 (or, 2x2x2) is 8.

See this table on Wikipedia for a better example.

You can move the starting around point all you want, but they are still going to be assigned the same number of IP addresses.

So, if you wanted them to have 75 through 82, here's the notation:

192.168.1.75/29

`192.168.1.75`

is the starting point, with the range extending to `2^(32-29)`

, or, `2^3`

, or, `2x2x2`

, or `8`

.

So here's the IP addresses they'd have:

192.168.1.75 192.168.1.76 192.168.1.77 192.168.1.78 192.168.1.79 192.168.1.80 192.168.1.81 192.168.1.82

Now, let's look at expanding past the `192.168.1`

subnet into `192.168.2`

as well. Since you have 256 IP addresses available on the first one (192.168.1.1 through 192.168.1.255), then the next range would start at `192.168.2.1`

. If you wanted to add those 256 as well, `192.168.2.1`

through `192.168.2.255`

, then you would use notation `/23`

, for `512`

.

So if you wrote `192.168.1.0/23`

, it would mean these IP addresses:

192.168.1.1 192.168.1.2 ... ... 192.168.2.254 192.168.2.255

Now, remember that everything is increased by the power of 2, so your options are always going to be doubled:

2^0 = 1 2^2 = 2 2^3 = 8 2^4 = 16 2^5 = 32 2^6 = 64 2^7 = 128 2^8 = 256 2^9 = 512 2^10 = 1024 2^11 = 2048 2^12 = 4096 2^13 = 8192 2^14 = 16384 2^15 = 32768 2^16 = 65536

With that in mind, you can easily know that whatever # of IP addresses available you have in your range, the next amount number available is going to be double what you currently have.

That is, if you have `192.168.1.0/21`

, which gives you `8`

, then if you go down one # – from `192.168.1.0/21`

to `192.168.1.0/20`

– 20 being the next possible range size, then your number `8`

is going to double to `16`

.

The opposite is also true, going from `192.168.1.0/21`

to `192.168.1.0/22`

is going to give you less addresess – 4.

The reason this can get confusing, trying to keep track of which numbers are higher or lower, remember that the higher the number on the CIDR, the lower the amount of possible IPs. Instinct may tell you that `/32`

is higher than `/24`

and so a `/32`

notation means more. The opposite is true. It's like a see-saw! Only one can be high.

192.168.1.0/32 - the notation is high, so the IPs is low 192.168.1.0/16 - the notation is low, so the IPs is high

The power of `2`

is also evident when crossing the first 256 # of IP addresses. If starting at `192.168.1.0`

, and extending to `512`

, then you're only adding one set of `256`

s. So `1.0`

would expand to `2.0`

. But what if you wanted to add more? The power of 2 applies, so you'd then have to jump by `4`

, next. `192.168.1.0`

now goes to `192.168.4.0`

. The next one would be `4`

times `2`

, so 8 is the next possible block. Going from `192.168.1.0`

to `192.168.8.0`

. And so on, and so on: `192.168.16.0`

, `192.168.32.0`

, `192.168.64.0`

, `192.168.128.0`

, etc.