Mailinglist Archive: opensuse (3378 mails)

< Previous Next >
Re: [SLE] Subnet mask settings....
  • From: Gideon Hallett <diogenes@xxxxxxxxxx>
  • Date: Fri, 12 Apr 2002 17:46:29 +0000
  • Message-id: <200204121746.29639.diogenes@xxxxxxxxxx>
On Friday 12 April 2002 14:46, Michael Garabedian wrote:
> Isn't there some rule that goes up by a certain amount.
> Like 10.0.0.0/8 is something
> And 10.0.0.0/128 is something...is there a table I can find these things
> out with or what is the math on this.

10.0.0.0/8 is a 32-bit address where the first octet represents the network
part of the address - in classful addressing, it's the RFC 1918-reserved
Class A. In classless addressing, it's just another netblock, albeit one with
((2 to the power 24) -2) addresses - some 16.78 million addresses.

Generally speaking, the most useful thing for working out addresses is a
thorough familiarity with powers of two.

As I assume you know, a network with no subnets has two sections; the network
and host parts of the address; and the netmask (e.g. 255.255.255.0) tells the
network device where the network/host boundary is. With classless notation,
it's very easy to tell where the network/host boundary is in the address,
since the /<number> tells you - /8 means that the first octet of the address
is the network portion, and the rest is the hosts portion.

Calculating how many hosts per network is easy if you know the number of host
bits in the address (let's call it 'n') - since each bit is a binary number,
the total number of combinations for an n-bit host portion is 2 to the power
n - minus two, since every network must have a network address (e.g. .0.0.0)
and a broadcast address (.255.255.255). So, as I said above, for a 24-bit
hosts portion, it's simply (2 to the 24)-2.

So, if you're using classless addressing, the best practice is to use a
netblock that's only as large as you need, since it means you've got more
addresses left for as-yet-unknown requirements.

Secondly, your netmask has to be *contiguous*. If network devices see 0-1 or
1-0 in the mask, they assume a network/host boundary. as such, the mask
255.254.255.0 will be seen as a 15-bit mask (if it works!). Try looking at it
in binary;

11111111.11111110.11111111.00000000.

That first 0 will tell your devices where the network/host boundary is;
everything else in the netmask *should* be zero - and may be ignored,
although it may well not be, and may well break stuff, depending on the kit
used.

Basically, a netmask should be all ones until you get to the network/host
boundary, and then should be all zeroes. So if you really want a netmask of
255.254.y.z, it should be 255.254.0.0 - and that will give you 17 host bits,
for a total of 131,070 host addresses!

If your network address is 10.0.0.0/24, then you have 8 host bits, and thus (2
to the 8) - 2 hosts per 'net - 254.

If you want to add another 'net, the best idea is to use as *large* a number
of network bits as you can; it cuts down on wasted addresses.

So, instead of using 10.10.0.0 and 255.254.255.0, try using 10.0.0.0 /23 (if
your second network is 254 hosts or smaller). That will give you 2 networks
to play with, both comprising up to 254 devices.

First network 10.0.0.0 255.255.254.0
Second network 10.0.1.0 255.255.254.0

So, you see, each network has 254 hosts (e.g. 10.0.0.0-10.0.0.255 - minus
broadcast and network addresses). If your second network is much larger than
your first, you might want to consider moving the host-network boundary in
the mask a bit or two to the left (i.e. /22 or /21).

If this still seems a little odd, try looking at the binary representation of
the addresses;

00001010.00000000.0000000 0.00000000 (= 10.0.0.0)
00001010.00000000.0000000 1.00000000 (= 10.0.1.0)
11111111.11111111.1111111 0.00000000 (= 255.255.254.0)

I broke up the third octet to show where the network portion of the mask ends;
at the 23rd digit. Anything after that is host digits, and since it's binary,
the only possible values are 0 and 1.

I hope that answers your question!

cheers,

Gideon.


< Previous Next >
References