This is a post I did on techexams.net about subnetting. I wanted it here for reference.
You've got two way to look at it 0., Binary and 1., Magic. <-- see that binary humor?!?
Ok, your question is
what is the first usable host of the IP address 184.108.40.206/25
we'll look at 3 different kinds of bits,
S = subnet bits
H= host bits
220.127.116.11 is a class C address which means the first 3 of the 4 sets of 8 bit blocks called octets, are N blocks (Class A = first octet, class B = first two octets, class C = first three octets - are network). like:
thats says the 212.46.165 is the network portion of the address. So the rest is devided up into S bits and H bits. Lets look at that CIDR number again, /25. So the first 3 blocks, our network blocks are /24 (count the Ns in the above class C example). That means we have 1 extra bit to be placed in our network bits, but its beyond the class C first 3 blocks so it ends up being a subnet bit like so
nnnnnnnn.nnnnnnnn.nnnnnnnn.s <--/25 where /24 is the n bits and /1 is the subnet bit
The rest of our bits are then host bits. So IPv4 is a total of 32 bits. We have 24 N bits, 1 S bit, and that leaves us with 7 bits. Those last bits are then H bits which makes the IP 18.104.22.168/25 effectively look like this:
We can then take those H bits and drop them into the equation
2^H= number of hosts per subnet (we can also do 2^s but well save that for later)
We have 7 H bits which gives us, 2^7 = 128
So for each subnet in the address 22.214.171.124 there is 128 hosts. So lets count by 128s
126.96.36.199 <-- first subnet
188.8.131.52 <-- second (and last) subnet
For usable hosts, we need to take out the broadcast and network address' (first and last address)
184.108.40.206 <--network address
220.127.116.11 <-- first usable host
18.104.22.168 <-- last usable host
22.214.171.124 <-- broadcast
Whew! On to magic!
Again, we look at the CIDR notation /25. If we count up the first 3 octects are 24 bits which means /25 lands us at the first bit in the 4th octet.
first bit last octet
So that 1st bit in the last octet, that points to our magic number. If we look at an octet, its powers of 2,
128 64 32 16 8 4 2 1
if we take that 1 bit left over (25-24=1) then we can drop that bit in the first place on the left side, the 128th place.
128 64 32 16 8 4 2 1
So that left over 1 is telling us that the magic number is 128. So, to figure the subnets we count by 128.
In our questioned address 126.96.36.199, it would look like so,
188.8.131.52 <--subnet 1
184.108.40.206 <-- subnet 2 -- it stops here (because 2^8=256 thus an octet can only handle 256).
So the address 220.127.116.11/25 falls into the host range
18.104.22.168 - 22.214.171.124
But as you know, we need to take out the broadcast and subnet addresses in order to get our usable hosts, thus the usable host range is
126.96.36.199 - 188.8.131.52
Great subnetting by binary (and IPv6) lecture here. Also, great practice here.