From owner-freebsd-questions Fri Jun 7 0:23:24 2002 Delivered-To: freebsd-questions@freebsd.org Received: from hawk.mail.pas.earthlink.net (hawk.mail.pas.earthlink.net [207.217.120.22]) by hub.freebsd.org (Postfix) with ESMTP id C64E237B405 for ; Fri, 7 Jun 2002 00:23:18 -0700 (PDT) Received: from sdn-ar-007dcwashp215.dialsprint.net ([63.178.90.129] helo=moo.holy.cow) by hawk.mail.pas.earthlink.net with esmtp (Exim 3.33 #2) id 17GE5Y-0007hd-00; Fri, 07 Jun 2002 00:23:13 -0700 Received: by moo.holy.cow (Postfix, from userid 1001) id 9A75450CB8; Fri, 7 Jun 2002 03:25:46 -0400 (EDT) Date: Fri, 7 Jun 2002 03:25:46 -0400 From: parv To: BSD Freak Cc: FreeBSD Questions Subject: Re: Converting decimal dotted subnet mask to CIDR in a script Message-ID: <20020607072546.GA6108@moo.holy.cow> Mail-Followup-To: BSD Freak , FreeBSD Questions References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 in message , wrote BSD Freak thusly... > > 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 in addition to a general solution, python & perl programs, there is at least one port on the subject: net/ipcalc ... # ipcalc -b 0/255.255.255.0 Address: 0.0.0.0 Netmask: 255.255.255.0 = 24 Wildcard: 0.0.0.255 => Network: 0.0.0.0/24 Broadcast: 0.0.0.255 HostMin: 0.0.0.1 HostMax: 0.0.0.254 Hosts/Net: 254 -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message