Re: wha is ipv4 prefix?? (why not netmask)



On Aug 8, 2008, at 4:55 AM, Dan Williams wrote:

On Thu, 2008-08-07 at 15:17 -1000, David Cantrell wrote:
On Aug 7, 2008, at 1:11 PM, Nathaniel McCallum wrote:

Derek Atkins wrote:
Miguel Angel Cañedo <mcanedo grupogcm com> writes:


I was pulling my hair trying to set static ipv4 settings.
Until I realized that NM 0.7 asks for PREFIX instead of NETMASK....

Now, my netmask should be 255.255.0.0
How do I transalte that into the Prefix?


/16 ?

I also thought the wording was less-than-clear.


Prefix means CIDR prefix, which probably doesn't help clear it up
either.  People have been using classful IPv4 vocabulary for a long
time, but we don't really do that at a low level anymore.  Everything
is classless.  Being able to accept a subnet mask in dotted quad
notation is really a convenience thing for people still wanting to use
the pre-CIDR notation.

This Wikipedia article does a reasonable job at explaining what CIDR is:

	http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing

It also has a chart that lists all of the /XX values and what the
equivalent subnet mask is.  The /XX value refers to how many of the
leading bits of the 32-bit IPv4 address we want to be the same across
all of our hosts.  The most common would be /24, which is the old
Class C subnet with a mask of 255.255.255.0.  That means the first
three octets of the address will be the same for every host. Only the
last octet is unique.  That gives you the possibility of having 256
unique hosts (in reality, it's 254 because .0 is the network address
and .255 is the broadcast address in IPv4-world).  See the table on
the wikipedia page for more details.

Changing from prefix to netmask or netmask to prefix can be
challenging depending on where you need to do it.  Here's how to
convert a prefix to a netmask in C (take an int, give a struct in_addr):

Can you look over the implementations of these functions in
libnm-util/nm-utils.c and vet them for correctness?

nm_utils_ip4_netmask_to_prefix
nm_utils_ip4_prefix_to_netmask

Thanks,
Dan

Sure.

--
David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI



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