### How to find Network Bits and Host Bits?

We can find Network Bits and Host Bits from any below information available.

How to find Network Bits and Host Bits from prefix?

So, Network Bits = Prefix #
Network Bits and Host Bits together forms 32 bits binary number(Subnet Mask).

NB + HB = 32
HB = 32 - NB

Example:
Network Bits and Hostsbits for /23 network

Here Prefix# = 23
NB = Prefix#
NB = 23
We know that NB + HB = 32
HB = 32 - NB
HB = 32 - 23
HB = 7
Hence for network /23 Network Bits is 23 and Host Bits is 9

How to find Network Bits and Host Bits from Subnet Mask?

As mentioned before Subnet Mask is 32 bits binary number. Which consists of Network Bits and Host Bits.

SM = NB + HB
Convert Subnet Mask in binary format Count consicutive '1' from MSB Number of consicutive '1' is Network Bits. and Number of consicutive '0' is Host Bits.

Example:
Network Bits and Host Bits for Subnet Mask 255.255.255.128

Convert Subnet Mask to binary number
SM = 11111111.11111111.11111111.10000000

We can write as
SM = 11111111111111111111111110000000

Consicutive '1' from MSB represents Network Bits.
NB = 1111111111111111111111111 and HB = 0000000
Now simply count number of '1' and number of '0' for Network Bits and Host Bits respectively.
Hence for Subnet Mask 255.255.255.128, Network Bits = 25 and Host Bits = 7

How to find Network Bits and Host Bits from Wildcard Mask?

WM = ~SM
We can say '1' represents Host Bits and '0' represents Network Bits.

Example:
Network Bits and Host Bits from Wildcard Mask 0.0.0.127

WM = 00000000.00000000.00000000.01111111
Now simply count number of '0' and number of '1' for Network Bits and Host Bits respectively.
Hence for Wildcard Mask 0.0.0.127 Network Bits are 25 and Host Bits are 7

How to find Netwokbits and Host Bits from Class information?

Classful IP address allocating scheme were designed on basic of predefined block of IP ranges.

Default Network Bits and Host Bits for classes are as below

ClassNetwork BitsHost Bits
A824
B1616
C248