[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: netmasks



On  0, Martin Clarke <prolix@redbrick.dcu.ie> wrote:
> a question i was asked recently on a topic that I thought
> i understood untill i was asked....
> 
> Given the hypothetical subnet 136.206.16.128 and netmask 255.255.255.128,
> state the valid range of IP addresses that could be assigned to hosts on
> the subnet?(also another was 64.122.34.83 & netmask 255.255.255.240  :(  )
> 
> i was used to looking at plain netmasks ie 255.255.255.0(ffffff00) etc 
> which I understand fine but my grasp of anything else is less than
> good...
> 
> any help is appreciated..

I find that looking at it in binary helps.  Sooo, given an address of
136.206.16.157...

136.206.16.128        10001000 11001110 00010000 10000000
255.255.255.128       11111111 11111111 11111111 10000000
136.206.16.157        10001000 11001110 00010000 10011101
                      \--------------------------/\-----/
                          This is the network      This is
                                  part            the host part

The host part can take on any value and still be a valid address
within that subnet[1].  So there are 2^7=128 valid addresses in this
subnet, and they are 136.206.16.128 through 136.206.16.255.  If you
take the logical AND of an address and the netmask, ADDR AND NETMASK,
then you get the network part of the address if you take
ADDR AND ( NOT NETMASK ) then you get the host part.

Another way of specifying this sort of network is to say that it is
136.206.16.128/25, which is to say that the network's addresses start
at 136.206.16.128 and that the first 25 bits specify the network part
of the address.

This network would be different if it was specified as
136.206.16.128/255.255.255.192, because then it would only be half as
large.  Then it would look like this:

136.206.16.128      10001000 11001110 00010000 10000000 (Same)
255.255.255.192     11111111 11111111 11111111 11000000 (Extra 1)
136.206.16.157      10001000 11001110 00010000 10011101 (Same)
                    \---------------------------/\----/
                        Network part           Host part

Now the range of valid addresses are 136.206.16.128 through to
136.206.16.191, and there is another possible network,
136.206.16.192/255.255.255.192, which contains the other half of the
addresses from our original, 25bit network.

So these are the key points:

* The network number (136.206.16.128) is the first valid address in
  that network.
* The netmask (255.255.255.128) tells you which bits in an address
  determine the network and which the host.
* The valid addresses on that network are the addresses starting at
  the network number through to the address that has all the host bits
  set to 1, taking into account [1] below.

[1]The address where the host part is all 1s is the broadcast
address.  There are also some broken implementations that consider the
address where the host part is all 0s to be the broadcast address as
well.

HTH.
Tom
-- 
Tom Cook
Information Technology Services, The University of Adelaide

"That you're not paranoid does not mean they're not out to get you."
	- Robert Waldner

Get my GPG public key: https://pinky.its.adelaide.edu.au/~tkcook/tom.cook-at-adelaide.edu.au

Attachment: pgpPslKyKt9PO.pgp
Description: PGP signature


Reply to: