Calculate PREFIX from subnet mask in bootscripts
fost at hotmail.com
Sat Oct 23 21:28:09 PDT 2004
"Kevin P. Fleming" <kpfleming at linuxfromscratch.org> wrote in
news:41752662.4040709 at linuxfromscratch.org:
> Gerard Beekmans wrote:
>> So never mind my question about what 255.255.255.252 is. It's /30
>> according to this table. Good enough for me. Though I'd still
>> appreciate the math behind it if anybody can explain it.
> The math is pretty easy:
> An IP address is 32 bits long. Some portion of those bits, starting
> from the beginning, are used to separate the address into "network"
> and "host" addresses.
> If you turn your netmask of 255.255.255.252 into binary, it becomes:
> 1111-1111 1111-1111 1111-1111 1111-1100
> If you then count the number of 1-bits starting from the beginning,
> you get 30, so this netmask is equivalent to a VLSM prefix of /30.
> The common /24 prefix is:
> 1111-1111 1111-1111 1111-1111 0000-0000
> And so on.
well explained ;)
I've a question about using prefix tho - how do you handle supernets?
e.g. netmask of 255.248.255.242
I can't see any way to reliably express this as a prefix (i.e. so you can
revert from a prefix to a full mask) ;(
More information about the lfs-dev