# IP Address and IP Subnetting

***

### IPV4 Address Classes

```shell
IP CLASSES

Class A 1-126  They are used by very large companies such as google 
11111111 00000000 00000000 00000000

Class B 128-191 medium and large sized enterprises
11111111 11111111 00000000 00000000

Class C 192-232 General use
11111111 11111111 11111111 00000000

Class D 192-239 Research Purpouse / Multicast
Class E 240-254 Advance Research Purpouse
```

### How to identify type of IP Address:

<figure><img src="https://2332860236-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq6mjlFfyDOi3mV0lemKE%2Fuploads%2FdMvVTVeCnqE39HzutlxL%2Fimage.png?alt=media&#x26;token=1e085282-acb6-411b-a578-fad54e586bb8" alt=""><figcaption></figcaption></figure>

### How to calculate Subnets:

Subnetting is the process of taking some of the hosts bits to the network bit to expand the network efficiently.

```
Network = 1
Hosts = 0
The standerd code of the IP classes look like
Class A : 11111111 00000000 00000000 00000000 
Class B : 11111111 11111111 00000000 00000000
Class C : 11111111 11111111 11111111 00000000

Take the following IP as Refrence

192.168.26.10
--> This is the Typical class C network
Thus it will be like
11111111 11111111 11111111 00000000


--> Take 192.168.26.10 If we have to expand the network bit we will change the binary
11111111 11111111 11111111 11|000000
It defines that we have taken 2 extra bits from the host

On the above example:
The subnetting has 4 diffrent parts : 
Subnet notation : 192.168.26.10/26 {/26 : it defines the total number of network bits}
Subnet mask: 255.255.255.192 {.192 AS (2^7)+(2^6)}
|||| OR OPREATION ||||||
0*0=0
0*1=0
1*0=0
1*1=1
|||| |||| |||| |||| ||||

Network ID : 192.168.29.0
{
Step 1: Convert the IP to binary (192.168.29.10)
Binary Address: 11000000 10101000 00011101 00001010
Notation:       11111111 11111111 11111111 00000000 {OR METHOD APPLIED}
____________________________________________________________
                11000000 10101000 00011101 00000000 --> 192.168.26.0 (Network ID)
}
Number of Subnets : which are added : 2^n {2^2=4}
Number of hosts : (Number of remaining hosts) 2^n-2{2^6-2=62}
Host Range (Derived): 192.168.26.0 .. 192.168.26.62
Broadcast IP : 192.168.26.63


---> Derived Subnets : 🎯
Host Range Subnet-1: 192.168.26.1    ..  192.168.26.62    BR : 192.168.26.63  
Host range Subnet-2: 192.168.26.65   ..  192.168.26.126   BR : 192.168.26.127
Host range Subnet-3: 192.168.26.129  ..  192.168.26.190   BR : 192.168.26.191
Host Range Subnet-4: 192.168.26.193  ..  192.168.26.254   BR : 192.168.26.255 
```

***

### Examples related to subnetting

```shell
-->  IP Address : 192.168.112.0 |  Create 3 Extra Subnets
STEP 1: Subnet Notation : 192.168.112.0/27
STEP 2: Subnet mask : 11111111 11111111 11111111 111 00000 --> 192.168.29.224
STEP 3: {
Network ID : 192.168.112.0
//Calculation//
11000000 10101000 01110000 00000000
11111111 11111111 11111111 11100000
_________________________________________
11000000 10101000 01110000 00000000 --> 192.168.112.0
}
Number of Subnets : n=3 {2^n} = 2^3= 8
Number of hosts : n=5 (2^n-2)= 2^5-2=30
Host Range (derived): 192.168.112.0 .. 192.168.112.30
Broadcast IP : 192.168.112.31

|||||  Derived Subnets
Subnet 1 : 192.168.112.0 .. 192.168.112.30 | 192.168.112.31
Subnet 2 : 192.168.112.32 ..192.168.112.62 | 192.168.112.63
Subnet 3 : 192.168.112.64 .. 192.168.112.94 | 192.168.112.95
Subnet 4 : 192.168.112.96 .. 192.168.112.126 | 192.168.112.127
Subnet 5 : 192.168.112.128 .. 192.168.112.158 | 192.168.112.159
Subnet 6 : 192.168.112.160 .. 192.168.112.190 | 192.168.112.191
Subnet 7 : 192.168.112.192 .. 191.168.112.222 | 192.168.112.223
Subnet 8 : 192.168.112.224 .. 192.168.112.254 | 192.168.112.255

```

***
