Cracking subnetting
If you can't understand the subnetting read the following.
What is the subnet?
According to uncle Google, the subnet is:
A subnet, or subnetwork, is a segmented piece of a larger network. More specifically, subnets are a logical partition of an IP network into multiple, smaller network segments. Bla bla bal...
Simply, it's a piece of network (appear from its name).
Yes, If we have a network we can divide it into subnets.
So, How to do this?
Here we should define the subnet mask.
It's a binary mask used to reserve a piece of your IP for the network(as you should know the IP consists of two parts: network IP and Host IP).
Ok Let's take an example to understand.
If you have this IP 48.25.24.71
and I told you that this IP is 21
.
-What is the network IP?
here, we should use the subnet mask.
Your mask is:
1111 1111.1111 1111.1111 1000.0000 0000
Yes, it's 21 ones and the rest of 32 bits is zeros.
Now just make anding operation for your mask and IP to get the network IP.
You network IP is 48.25.24.0
I HOPE YOU FIND IT EASY.
Let's taka the next step.
If you have a network IP and subnet mask for this network, but you want to make subnetworks from it, How to do that?
I really like to take examples to explain this.
Example:
This is an IP and subnet for a network
10.0.0.0/10
I want you to divide it into 4 subnets.
Thinking loudly...
I want to make four subnet from this subnet, ok how to count from 0 to 3 into binary? Yes I should have 2 bits to count
00
01
10
11
So, we will add two bits to our old mask to give us some space to count our network without changing the main network IP. And obviously the rest of the bits will be used to count the host IPs and broadcast.
So, In our example each sub network has (2^20) IPs including the network IP, hosts IP, and broadcast.
The answer
For subnet 0:
The network IP will be:
10.0.0.0
The first host IP will be:
10.0.0.1
The last host IP will be:
10.15.255.254
The broadcast IP will be:
10.15.255.255
let's see it in binary
0000 1010. 0000
1111 .1111 1111. 1111 1111
These first 12 bits identify the network or more accurately the subnetwork.
So if we want to get the next subnet we will add one for the right most two bits and make the rest 20 bits zeros...
Subnet 1:
The network IP will be:
10.16.0.0
The first host IP will be:
10.16.0.1
The last host IP will be:
10.31.255.254
The broadcast IP will be:
10.31.255.255
let's see it in binary
0000 1010. 0001
1111 .1111 1111. 1111 1111
And so on...
Just a small note to you:
0000 1010. 00
00 0000.0000 0000.0000 0000
Don't touch the 10 highlighted bits. These are the main network IP and If you change it, you died.
‐------------------------------------
I hope I helped you with subnetting. If you find any mistake don't hesitate to tell me.