Sunny Subnetting Playlist:
Note: In varaiable length subnetting subnet mask will change but in fixed length subnetting it will remain same.
Nice blogs:
Practical examples(Best video): link
Fixed length subnet mask vs Variable length subnet mask: link
Variable length subnet masking with example: here
More explanaion of same example
Question:given IP is 192.168.1.0/24, and we need to accomadte ips for
Sales and Purchase: 120
Development: 50
Accounts: 26
Management: 5
Answer: As per given ip and subnet,we can accomodate 2^8=256 IP addresses
Step1: Sort the requirements in descending order and find the numbers of IP addresses required(narest power of 2 ) for each subnet
Sales and Purchase: 120 -> Ips req = 128
Development: 50 > Ips req = 64
Accounts: 26 > Ips req = 32
Management: 5 > Ips req = 8
Step2:Divide the given ip,so into sub nets,so we should accomadate 128 Ips or 126 valid hosts addresses
If we use subdivide like this,then we can have 2 networks with 128 ip's each
1.192.168.1.0/25
2.192.168.1.128/25
We can use first network 192.168.1.0/25,for sales and purchase department as it has 126 valid host address,
The subnet details of Sales and Purchase department:
Network Id: 192.168.1.0/25
BroadCast Id: 192.168.1.127/25
Valid host ip's range: 192.168.1.1 to 92.168.1.126 =126 in total
Subnet mask: /25 or 225.225.225.128
Step 3: Take the 192.168.1.128/25 network and we will sub divide into further networks, thisis the reason why we call VLSM(Variable length subnet masking) as subnetting a subnet.
For development team,we need to have 64 IPs,so subdivide 192.168.1.128/25 to 192.168.1.128/26, then we will have 2 networks of 64 hosts each
1.192.168.1.128/26
2.192.168.1.192/26
We can use first network 192.168.1.128/26,for development department as it has 62 valid host address,
The subnet details of development department:
Network Id: 192.168.1.128/26
BroadCast Id: 192.168.1.127/26
Valid host ip's range: 192.168.1.129 to 92.168.1.191 =62 in total
Subnet mask: /26 or 225.225.225.192
Step 4: Take the 192.168.1.192/26, and we will sub divide it
For Accounts department we need 32 ips,so we divide this network as below
1. 192.168.1.192/27
2. 192.168.1.224/27
We can use first network 192.168.1.192/27,for accounts department as it has 30 valid host address,
The subnet details of accounts department:
Network Id: 192.168.1.192/27
BroadCast Id: 192.168.1.223/27
Valid host ip's range: 192.168.1.193 to 92.168.1.222 =30 in total
Subnet mask: /27 or 225.225.225.224
Step 5: Take 192.168.1.224/27,we will subdivide it.
For Management department we need also 8 ips,so divide 192.168.1.224/27 into 4 networks of 8 ips each, a total =32 ips.
Note:How we determined how many networks is, in CIDR we have 27 and for creating 8 hosts we require 29 CIDR value,so diff between then is 2 and 2^2=4.
The 4 networks looks as below:
1.192.168.1.224/29
We can use first network 192.168.1.1.224/29,for management department as it has 6 valid host address
The subnet details of management department:
Network Id: 192.168.1.224/29
BroadCast Id: 192.168.1.229/29
Valid host ip's range: 192.168.1.225 to 92.168.1.228 =6 in total
Subnet mask: /29 or 225.225.225.248
Note:The aboveexample is easy and we calculated networks easily, but some times we neeed complex maths.
Simple hack to find the subnets of subnets:
- To find the last address of a subnet, perform OR operation between the first address of the subnet and the complement of the subnet mask
- Add 1 to the last address of the previous subnet to find the first address of the next subnet.
Example: In step2 we had 2 networks
192.168.1.0/25 and
192.168.1.128/25,we calculated
2 nd network normally by adding 128 to last octet but in complex problems we cannot do this.So follow the steps
1.The first address is : 192.168.1.0 (Even we can get it by performing AND between ip and subnet mask)
2.The subnet is: 225.225.225.128
perform OR between 1 and 2,by converting then to binary
we get 192.168.1.127,so the broadcast id of that subnet is 192.168.1.127
Then by add 1 we will get network id of next subnet
Question:Create a vpc in aws, take any ip and create 4 equal subnets(Fixed length subnetting)
Very very simple and basic
Lets say given ip is 10.0.0.0/24,
We have taken /24 as CIDR beacause we want to design a simple network with otal 256 host and 4 subnets with 64 hosts each.
In Fixed length subnetting, subnet mask remains same i.e /26 because we are going to create 4 suntes so we need 2 host bits to convert it into network bits.
Subnet 1: Ip range-10.0.0.0/26-10.0.0.63/26
Subnet 2: Ip range-10.0.0.64/26-10.0.0.127/26
Subnet 3: Ip range-10.0.0.128/26-10.0.0.191/26
Subnet 4: Ip range-10.0.0.192/26-10.0.0.255/26
Note: Consier this problem here(watch at the end)
Given Ip is 10.0.0.0./24, we know we can use 4096 ips(32-20=12 &&2^12=4096)
How can we find last ip????
Well there are many ways, but inkow 2 ways
Way 1(The haard way)
We know we can get 4096 ips,so if we calculate
10.0.1.x - It will take 256 ips
similarly 10.0.2.x takes another 256 ips and we proceed further we know need 16 0f those because (16*256=4096)
So we get last range as 10.0.15.x
and the last ip would be 10.0.15.255
Way 2(Formula based)
1.Get the ip address and convert it to binary
2.Get the complement of subnet mask
3.Perform OR between 1 and 2
In simple words, perform the OR operation between given ip and complement of subnet mask
Incase of above example, the subnet mask of /24 is 11111111.11111111.11110000.00000000 and its complement is 00000000.00000000.00001111.11111111
00001010.00000000.00000000.00000000
00000000.00000000.00001111.11111111
-------------------------------------------------
00001010.00000000.00001111.11111111
and the decimal equivalent of result is 10.0.15.225
In the above video he wans to create subnets with /28 range i.e each subnet will have 16 ips, so he can create 4096/16 i.e 2^8=256 subnets
The networkids of each subnet will be:
10.0.0.0/28
10.0.0.16/28
10.0.0.32/28
10.0.0.64/28
.
.
.
10.0.0.240/28
We will have total 16 of them using 0 in 3 rd octet, similarly we can use 1,23...15 in 3rd octet which results in 16*16=256 subnets
----------------------------------------------------------------------------------------------------------------
To get overview of entire subneting:
Note:In the above pdf,VLSM example was not given, refer above example.
Imp points:
* If we want to do simpe subnetting then we will go for fixed length subneting, where the subnet mask of all subnets are same. There is lot of wastage of ips, if we use his.So people prefer VLSM
* VLSM uses ips more effectively and it is some what tought to implement, practice
If you have more time then go through below all videos in order by technical guftgu:
Note:part2 - fixed length subnetting and part4- variable length subnetting
-----------------------------------------------------------------------------------------------------------------------