From owner-freebsd-net@FreeBSD.ORG Thu Aug 8 11:31:04 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id C803FB90 for ; Thu, 8 Aug 2013 11:31:04 +0000 (UTC) (envelope-from patfbsd@davenulle.org) Received: from smtp.lamaiziere.net (net.lamaiziere.net [94.23.254.147]) by mx1.freebsd.org (Postfix) with ESMTP id 90F152A10 for ; Thu, 8 Aug 2013 11:31:04 +0000 (UTC) Received: from roxette.lamaiziere.net (149.169.100.84.rev.sfr.net [84.100.169.149]) by smtp.lamaiziere.net (Postfix) with ESMTPA id 6B08FA130; Thu, 8 Aug 2013 13:30:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by roxette.lamaiziere.net (Postfix) with ESMTP id 38294B0DC; Thu, 8 Aug 2013 13:30:56 +0200 (CEST) Date: Thu, 8 Aug 2013 13:30:55 +0200 From: Patrick Lamaiziere To: s m Subject: Re: how calculate the number of ip addresses in a range? Message-ID: <20130808133055.15e53b94@davenulle.org> In-Reply-To: References: X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.19; amd64-portbld-freebsd9.1) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Cc: FreeBSD Net X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2013 11:31:04 -0000 Le Thu, 8 Aug 2013 11:34:22 +0430, s m a écrit : > hello guys, > > i have a question about ip addresses. i know my question is not > related to freebsd but i googled a lot and found nothing useful and > don't know where i should ask my question. > > i want to know how can i calculate the number of ip addresses in a > range? for example if i have 192.0.0.1 192.100.255.254 with mask 8, > how many ip addresses are available in this range? is there any > formula to calculate the number of ip addresses for any range? > i have 192.0.0.1 192.100.255.254 with mask 8 This doesn't mean anything ? There are few tools to deal with ip addresses, you can study the code : python: IPy https://github.com/haypo/python-ipy perl : ipcalc: /usr/ports/net-mgmt/ipcalc ... Basically, an ip address is just a number. IPy associates also a prefix length in an "IP" object. So it can represent a host or a network which is nice. Regards.