Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Jun 2002 22:32:03 -0600
From:      "Mike Roest" <bsd-lists@blahz.ab.ca>
To:        "'BSD Freak'" <bsd-freak@mbox.com.au>, "'FreeBSD Questions'" <freebsd-questions@FreeBSD.ORG>
Subject:   RE: Converting decimal dotted subnet mask to CIDR in a script
Message-ID:  <000001c20ddc$4916c370$465d4018@zeus>
In-Reply-To: <f9079af91739.f91739f9079a@mbox.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help
You can 
1)split each of the octects at the decimals.
2)convert each resulting numbers to binary
3)count the number of ones in the 4 binary numbers.
4)bang you have the result.

This procedure "should" work for all subnet masks
-Mike

-----Original Message-----
From: owner-freebsd-questions@FreeBSD.ORG
[mailto:owner-freebsd-questions@FreeBSD.ORG] On Behalf Of BSD Freak
Sent: Thursday, June 06, 2002 10:05 PM
To: FreeBSD Questions
Subject: Converting decimal dotted subnet mask to CIDR in a script


Hi all,

I have a variable in a script we use

$MASK=255.255.255.0

Is there a utility or an easy way to process $MASK and get 

$MASKCIDR=24

the CIDR value of 255.255.255.0


Many thanks...

---------------------------------------------------------------------
Faxes delivered directly to any email address, new to mBox!
Find out more http://www.mbox.com.au/fax

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c20ddc$4916c370$465d4018>