From owner-freebsd-questions Thu Jun 6 21:32:36 2002 Delivered-To: freebsd-questions@freebsd.org Received: from ares.blahz.ab.ca (h24-64-95-168.cg.shawcable.net [24.64.95.168]) by hub.freebsd.org (Postfix) with SMTP id 92ABD37B400 for ; Thu, 6 Jun 2002 21:32:31 -0700 (PDT) Received: (qmail 13303 invoked by uid 508); 7 Jun 2002 04:32:39 -0000 Received: from bsd-lists@blahz.ab.ca by ares.blahz.ab.ca by uid 505 with qmail-scanner-1.12 (sweep: 2.10/3.58. . Clear:. Processed in 1.470417 secs); 07 Jun 2002 04:32:39 -0000 Received: from unknown (HELO zeus) (24.64.93.70) by h24-64-95-168.cg.shawcable.net with SMTP; 7 Jun 2002 04:32:37 -0000 From: "Mike Roest" To: "'BSD Freak'" , "'FreeBSD Questions'" Subject: RE: Converting decimal dotted subnet mask to CIDR in a script Date: Thu, 6 Jun 2002 22:32:03 -0600 Message-ID: <000001c20ddc$4916c370$465d4018@zeus> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 In-Reply-To: Importance: Normal Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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