IPv4 Variable Length Subnetting vs Fixed Length Subnetting? - ip

I'm trying to understand the difference between variable length subnetting and fixed length subnetting, from what I know variable length subnetting will create different subnet masks depending on the subnet.
But in fixed length subnetting, the supernet mask is calculated by 32 - (host_bits + subent_bits).
So if the host_bits are going to be changing depending on the subnet, then wouldn't the supernet mask change as well?

Subnets and supernets are just a matter of perspective.
Whether you split a network in four equal parts or in one half and two quarters, the technique is the same: you move the division between network part and host part further right and the bits you add to the network part let you address subnets.
E.g.
10.10.16.0/20 = 10.10.16.0 to 10.10.23.255
=>
10.10.16.0/22 = 10.10.16.0 to 10.10.19.255
&
10.10.20.0/23 = 10.10.20.0 to 10.10.21.255
&
10.10.22.0/23 = 10.10.22.0 to 10.10.23.255
Supernetting works the same, only in the opposite direction.

The difference between the variable mask and the fixed mask is the versatility, in the fixed mask you can only make subnets of a single size and this is a great restriction since you waste too many ips, instead with the variable mask it allows us to create the networks of the size that we want, thus being able to waste the least amount of ips possible, thus making network schemes more efficient.

Related

How does a CIDR range specify the IP addresses within it?

I have read a number of articles and posts about VPCs, CIDR and subnets but I still find the explanations confusing.
Many of the explanation can't help avoiding using domain knowledge or technical terms.
Is there a more basic explanation for someone who gets basic programming, binary, etc. ?
I am wondering in the context of aws VPCs.
How does a CIDR represent an IP address range ?
Start with an IP address:
xx.xx.xx.xx
This actually represents Four 8 bit numbers.
With a dot between each.
As they are 8 bit numbers, they can be from 0 up to 255 (decimal).
They are frequently shown as xx.xx.xx.xx because this is referring to them as four 8 bit numbers, shown in hexadecimal (base 16) format. In 'hex' format 255 (decimal) is written as FF
So the numbers range from 00.00.00.00 to FF.FF.FF.FF - in hex
Or 0.0.0.0 to 255.255.255.255 in decimal
For the purpose of considering how many IP 'addresses' this represents - i.e. how many individual IP addresses - you can do 255 * 255 * 255 * 255 which is 4228250625. Because you have used FOUR 8 bit numbers you multiply them together to produce that number. It is 2*32. You'll notice that the 32 is 8 + 8 + 8 + 8 and that is the four 8 bit numbers in xx.xx.xx.xx
OK, so now to CIDR. Where all the above 8 bit, base 16 and hexadecimal / binary information will be useful...
So a CIDR is a range of IP's.
For example you might want a range of 10.0.0.0 to 10.0.0.255 which is 255 IPs. You can write this using the above format, i.e. 10.0.0.1 to 10.0.0.255 but there is another way to do it and that is by using CIDR - Classless Inter Domain Routing. Lets stick with calling it CIDR. so with CIDR you refer to a range using a format like this:
10.0.0.0/24
and that means the range 10.0.0.0 to 10.0.0.255, i.e. 255 numbers.
So has does that work ? !
ok, first we are given which might be thought of as the starting address of the range - 10.0.0.1, although this is actually a bit misleading because the CIDR number is going to affect it.
So lets go piece by piece.
The "/24" refers to the number of bits on the left that stay fixed.
This is probably the hardest but also most essential piece to understand.
So taking "24". this means (conveniently with 24!) that you consider the first 24 bits, i.e. the 10.0.0 to be fixed (see bitmask). Only the last 8 bits of the xx.xx.xx.xx can change, i.e. you have a range and it is from 10.0.0.0 to 10.0.0.255
Here's one of the most surprising facts initially:
The larger the CIDR number, e.g. /28, /30, etc. the smaller the available range of IP addresses !!!
This is because the /nn CIDR number refers to how many bits are FIXED and the more bits are FIXED the less bits are can be changed to produce a range, and thus the smaller the range. This is why with /32 there is NO range because you are saying all 4 xx.xx.xx.xx numbers (8 + 8 + 8 + 8 = 32) are fixed. Whereas with 10.0.0.1/24 you can have from 10.0.0.0 to 10.0.0.255 because the 24 indicates the first three numbers (again 8 + 8 + 8 bits = first 3 numbers) are fixed) and only the last 8 bits, i.e the 'zz' in xx.aa.bb.zz can change for this range. One more example: 10.0.0.0/16 (so first two 8 bit numbers are fixed) means 10.0.0.0 to 10.0.255.255.
Because this behavior is due to a netmask 10.0.0.0/24, which produces the range 10.0.0.0 to 10.0.0.255 would produce the same result if you supplied 10.0.0.0/24, 10.0.0.73/24 or 10.0.99.17/24
See an online converter at https://ipaddressguide.com/cidr
With aws you are given 10.0.0.0/16 as your VPC which means the "10.0" part will stay fixed. so that means if you want a subnet within that you want something smaller such as 10.0.0.0/24 or 10.0.1.0/24 of which you will be able to have many.
The next thing that may be a bit unexpected is that within a VPC subnets must not overlap. However you can have multiple VPCs using that range. The second piece takes some explanation:
There are three IP ranges set aside as PRIVATE so they are never used 'publicly'. These lets each network use those as 'internal' addresses. They are the, probably familiar
10.0.0.0 to 10.255.255.255
172.16.0.0 to 172.31.255.255
192.168.0.0 to 192.168.255.255
So when you get a VPC that uses a 10.0.0.0/16 range you are getting ONE private network within "a' network. As if you were 'one' user at home using your single network. You can create another VPC because that uses another network (like having a second router in your house) and on that network 10.0.0.0./16 is available.
You currently have a default limit of 5 VPCs per region. As each VPC is using private subnet ranges, they can actually be the same for different ones as well as different, however if you ever want the VPCs to be able to communicate with each other (using VPC peering) this will be a problem because the subnets can't overlap when you do that (otherwise the router wouldn't know which subnet to pick for a given address that exists in both).
Any other corrections I am happy to incorporate wiki-style. I am not defending my knowledge, just trying to share what I think I know and help others understand this confusing concept!
Here's how you do it in aws:
Nope! You have to avoid within 10.0 - the existing public subet !
Result

CIDR / subnet mask

I am trying to understand how subnetting is involved in CIDR notation. As far as I understand, there is a network and host portion to every IP address. The netmask specifies how many leading bits should be used in this network portion, while the remaining bits become the possible hosts. Before CIDR was created, I understand that there were different classes A-D (0, 10, 110, 1111 leading bits) that had very specific netmasks, and that you could add a subnet mask by taking away some of the host bits.
What I am confused about is if you want subnets using CIDR notation, do you still need a separate subnet mask along with the CIDR notation? As far as I am aware, CIDR simply supports more flexible netmask length (so you don't end up having something like 65536 possible hosts when you only need like 400). But something like 174.43.8.0/23 still only has 1 single subnet, and 512 possible hosts. If you wanted subnets for this wouldn't you still need to add a subnet mask like 255.255.255.0 if you wanted 2 different subnets?
You're on the right track. CIDR provides a classless way of allocating subnets that is more versatile than the original Class A-C system. It is another way of specifying a subnet mark, but with a more compact notation than specifying a netmask like 255.255.255.0.
To understand CIDR, you have to first understand that that a subnet mask is four eight bit numbers (called octets) that form a 32 bit value. A CIDR of /24 or /8 is just a way of representing how many of the leftmost bits in that 32 bit value are 1's, with the 0's on the right side representing the size of the subnet (stay with me here...I'll make that clearer in a second).
If you want a subnet with 16 IP's, you need a netmask of 11111111 11111111 11111111 11110000. You'll notice that there are four zeros in that mask, and there are sixteen possible values that you can specify with four bits. Written in CIDR notation, this would be a /28 network (32 minus the four "zero" bits)
Similarly, if you want a subnet with 512 IP's, you need to set nine of the bits in your 32-bit subnet mask to zero (because a nine bit binary number has 512 possible values from 0-511). So that would be 32-9=23, or a /23.
Now one last thing you need to remember. For every CIDR, you will always have some IP addresses that can't be used for hosts (these are used for broadcast and gateway). You can find a nice cheat sheet showing the actual numbers here:
http://www.rjsmith.com/CIDR-Table.html
Hope that helps!

Subnet plan with efficient use of a range of ip adresses

Good morning, so basically I am working with Packet Tracer atm and have 3 subnet plans assigned(management(104users), staff(43 users) and admin(35 users)). I have an ip address range of:38.191.0.0 and subnet mask of 255.255.255.0. I want to produce that subnet plan but with the most efficient use of the ip address range provided above. Could anyone give me a brief idea of how to transform that range to the most efficient use of the IP addresses? Thank you very much. The diagram looks as follows:
(Answering in anticipation of this getting moved to a different SE site)
Given the size of your three groups (104, 43, 35) the only reasonable split is to allocate each of them to the next higher power of two, specifically (128, 64, 64) making that a /25 and two /26 blocks with nothing left over.
Note that this gives you 22 spare addresses in the first block, 19 in the second and 27 in the last.
p.s. is 38.191.0.0/24 really your netblock?

How to write in network address/netmask the following address space?

I'd like to ask how to write in network address/netmask the following address space:
63.39.191.192 - 63.40.192.223
On paper, I couldn't figure any way of doing it, so I tried using a network address calculator to figure it out.
I inputed the first IP address and started toying with the netmask.
What I couldn't understand is how the first and last usable address varied based on the netmask.
So, here I am, hoping that you might explain to me how the first and last IP address are determined based on the netmask and how to solve that problem.
There are two things that someone might mean by a address/netmask pair. One option is something that looks like 192.168.0.1/24. This means that the first 24 bits of an acceptable address must match the given address. This is a common way of expressing subnets, however it is not possible to express your range like this. This means that you will not be able to work out a solution in the calculator you linked, which uses this method as input.
The other way is as a pair of dotted quads. The subnet above would be expressed like this: 192.168.0.1/255.255.255.0. Everything which can be expressed in the first way can be expressed in the second way, but the converse is not true.
To understand how to solve your problem using the second format, you have to know something about binary numbers. Each part of the dotted quad is a number 0-255 and can be expressed as a binary number with eight digits (bits). Thus the whole address is a binary number made up of 32 bits, each of which is either 0 or 1.
A network specification is an address, followed by another 32-bit number, expressed as an address. What the second number means is this: each place in that number where the digit is 1, the first address has to match on that digit. Each place where the digit in the netmask is 0, no match is needed. So you see how matching the first 24 bits is the same as matching 255.255.255.0, which is a 32-bit number made up of 24 1's followed by 8 0's.
You can also see how some netmasks can't be expressed in the first type. Any netmask which isn't one string of repeated 1's followed by the rest 0's, can't be written like this. The reason for the first type is that most real-world networks do have netmasks of this form.
To construct a netmask of the second type, you can work with one byte at a time. The first byte of the address has to match exactly 63. So the address will be 63.x.x.x and the mask will be 255.x.x.x. As before 255, made up of all 1's, means match every bit. The second byte can be either 39 (00100111 in binary), or 40 (00101000). This one can't be expressed as any number plus a set of bits to match. Only the first four bits of the two numbers match, but if we try to do something like 63.39.x.x/255.224.x.x (224 is 11110000), we will match any second byte from 32 to 47. You should check your previous question to see if this is right, however, you should hopefully be able to figure some more out if you understand binary.
If you're not completely sure how binary works, please go away and make sure you really get it before looking into netmasks further. It really will help and it's a very good thing to know about anyway.

Query on class B private address range

This is the range for class B private address range.
172.16.0.0 - 176.31.255.255
prefix notation for this is 172.16.0.0/12
As per prefix notation, 8 bits of left most octet and left most 4 bits in second octet can only be used to derive network ID in the IP address.
So, I can derive network address using x in xxxxxxxx.xxxx0000.00000000.00000000
My question:
Using leftmost 12 bits, How can i derive 172.17.0.0 and 172.18.0.0 network address? In general, How can i derive 172.16-172.31 range using left most 12 bits(mentioned as x)?
I am not clear about what you ask: the notation /12 leads to the net mask
11111111.11110000.00000000.00000000
NNNNNNNN.NNNNHHHH.HHHHHHHH.HHHHHHHH (network part / host part)
which can be combined with 172.16.0.0:
10101100.0001HHHH.HHHHHHHH.HHHHHHHH (H = host part)
This means that every IPv4 address which starts with these 12 bits belongs to this network.
This counts for all IPv4 addresses whose first octet is 172 and second one is between 16 (00010000) and 31 (00011111).
And this range includes 172.17.* and 172.18.* as well.
What we have talked about here is how the network part of the address forms. Inside one network, each host gets assigned an address, making use of the host part.
These addresses can essentially be freely assigned (except that the host part may not be all 0s or all 1s).
How you use/divide up your 172.16/12 is up to you.
You can see 172.16/12 see as one big network where all hosts are in, but you can as wee split it up even further:
maybe into 172.16/13 and 172.24/13
or into 172.16/14, 172.20/14, 172.24/14 and 172.28/14
or into 172.16/15, 172.18/15, 172.20/15, 172.22/15, 172.24/15, 172.26/15, 172.28/15 and 172.30/15
or into 172.16/16, 172.17/16, 172.18/16, ..., 172.29/16, 172.30/16 and 172.31/16
...
You can even mix that: you can as well have e. g. 172.16/13, 172.24/14 and 172.28/14.
Commenting on your comment:
can i say that as per prefix notation /12, the possible networks here are 172.00010000.0.0, 172.00100000.0.0, 172.00110000.0.0, 172.01000000.0.0, 172.01010000.0.0 , 172.01100000.0.0, 172.01110000.0.0 etc...
No. As said, 172.16/12 means 172 is constant and the first bits of 16 are constant.
As mentioned, that means 10101100.0001... is fix and the rest is variable.

Resources