Wednesday, June 29, 2011

what is the first usable host of the IP address 212.46.165.199/25

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 212.46.165.199/25

binary
we'll look at 3 different kinds of bits,
N=network bits
S = subnet bits
H= host bits

212.46.165.199 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:
nnnnnnnn.nnnnnnnn.nnnnnnnn.xxxxxxxx

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 212.46.165.199/25 effectively look like this:
nnnnnnnn.nnnnnnnn.nnnnnnnn.sHHHHHHH

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 212.46.165.0 there is 128 hosts. So lets count by 128s
212.46.165.0 <-- first subnet
212.46.165.128 <-- second (and last) subnet

For usable hosts, we need to take out the broadcast and network address' (first and last address)

212.46.165.128 <--network address
212.46.165.129 <-- first usable host
212.46.165.254 <-- last usable host
212.46.165.255 <-- broadcast



Whew! On to magic!

212.46.165.199/25
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.
nnnnnnnn.nnnnnnnn.nnnnnnnn.nxxxxxxx
----------------------------- ^
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
^
1

So that left over 1 is telling us that the magic number is 128. So, to figure the subnets we count by 128.
0 128
In our questioned address 212.46.165.199, it would look like so,

212.46.165.0 <--subnet 1
212.46.165.128 <-- subnet 2 -- it stops here (because 2^8=256 thus an octet can only handle 256).

So the address 212.46.165.199/25 falls into the host range
212.46.165.128 - 212.46.165.255

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
212.46.165.129 - 212.46.165.254

Great subnetting by binary (and IPv6) lecture here. Also, great practice here.

No comments:

Post a Comment