1 2 |
IP address 192.168.1.10 Subnet mask 255.255.255.0 |

Network address is **192.168.1** and host address is **10**.

**In binary notation**

1 2 |
IP address 11000000.10101000.00000001.00001010 Subnet mask 11111111.11111111.11111111.00000000 |

Network address is 11000000.10101000.00000001 and host address is 00001010

IP Class | Default Subnet | Network bits | Host bits | Total hosts | Valid hosts |

A | 255.0.0.0 | First 8 bits | Last 24 bits | 16, 777, 216 | 16, 777, 214 |

B | 255.255.0.0 | First 16 bits | Last 16 bits | 65,536 | 65,534 |

C | 255.255.255.0 | First 24 bits | Last 8 bits | 256 | 254 |

**Convert binary in decimal**

To convert a binary in decimal we will follow above method in reverse mode. We will find the decimal value of on binary bit position and add them. For example convert 10101010 binary number in decimal.

Target binary number 10101010

Move direction From Left ===========================> to Right

Base position |
2^{7} |
2^{6} |
2^{5} |
2^{4} |
2^{3} |
2^{2} |
2^{1} |
2^{0} |

Decimal value |
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

Bit status |
1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |

Decimal value in addition |
128 | 0 | 32 | 0 | 8 | 0 | 2 | 0 |

Decimal value of 10101010 is 170 [ 128+0+32+0+8+0+2+0 ]

#### Default subnet mask

Class | Subnet Mask | Format |

A | 255.0.0.0 | Network.Host.Host.Host |

B | 255.255.0.0 | Network.Network.Host.Host |

C | 255.255.255.0 | Network.Network.Network.Host |

**How many subnets does given subnet mask provide ?**

To calculate the number of subnets provided by given subnet mask we use 2^{N} , where N = number of bits borrowed from host bits to create subnets. For example in 192.168.1.0/27, N is 3. By looking at address we can determined that this address is belong to class C and class C has default subnet mask 255.255.255.0 [/24 in CIDR]. In given address we borrowed 27 – 24 = 3 host bits to create subnets. Now 2^{3} = 8, so our answer is 8.

**What are the valid subnets?**

Calculating valid subnet is two steps process. First calculate total subnet by using formula 2^{N}. In second step find the block size and count from zero in block until you reach the subnet mask value. For example calculate the valid subnets for 192.168.1.0/26.

Borrowed host bits are 2 [26-24].

Total subnets are 2^{2} = 4.

Subnet mask would be 255.255.255.192.

Block size would be 256-192 = 64.

Start counting from zero at blocks of 64, so our valid subnets would be 0,64,128,192.

**What are the total hosts?**

Total hosts are the hosts available per subnet. To calculate total hosts use formula 2^{H} = Total hosts. H is the number of host bits. For example in address 192.168.1.0/26 we have 32 – 26 [Total bits in IP address – Bits consumed by network address] = 6. Total hosts per subnet would be 2^{6} = 64.

CIDR /25 has subnet mask 255.255.255.128 and 128 is 10000000 in binary. We used one host bit in network address.

N = 1 [Number of host bit used in network]

H = 7 [Remaining host bits]

Total subnets ( 2^{N} ) :- 2^{1} = 2

Block size (256 – subnet mask) :- 256 – 128 = 128

Valid subnets ( Count blocks from 0) :- 0,128

Total hosts (2^{H}) :- 2^{7} = 128

Valid hosts per subnet ( Total host – 2 ) :- 128 – 2 = 126

Subnets | Subnet 1 | Subnet 2 |

Network ID | 0 | 128 |

First host | 1 | 129 |

Last host | 126 | 254 |

Broadcast ID | 127 | 255 |

**/26**

CIDR /26 has subnet mask 255.255.255.192 and 192 is 11000000 in binary. We used two host bits in network address.

N = 2

H = 6

Total subnets ( 2^{N} ) :- 2^{2} = 4

Block size (256 – subnet mask) :- 256 – 192 = 64

Valid subnets ( Count blocks from 0) :- 0,64,128,192

Total hosts (2^{H}) :- 2^{6} = 64

Valid hosts per subnet ( Total host – 2 ) :- 64 – 2 = 62