OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: IP range to CIDR

From: Alex van den Bogaerdt (alexergens.op.het.net)
Date: Mon Jan 26 2004 - 17:10:34 CST


On Mon, Jan 26, 2004 at 04:01:50PM -0700, Cameron Knowlton wrote:
> I was wondering if anyone knows of a web page or a Mac OS application that can convert from IP ranges to CIDR addresses, e.g.:
>
> 200.41.0.0-200.41.127.255 --> a.b.c.d/x

If nothing shows up, and if you can write your own:

Range from "x" upto and including "y", properly aligned.

r=(x xor y)
add one
shift right until r==1, count number of shifts
subtract from 32.

Example
  200.41.0.0
  200.41.127.255
  -------------- xor
  0.0.127.255

  0.0.127.255
            1
  ----------- +
    0.0.128.0

    binary:
    00000000 00000000 10000000 00000000

    15 shift-right,
    32-15=17 --> 200.41.0.0/17

HTH
Alex
--
begin sig
http://www.googlism.com/index.htm?ism=alex+van+den+bogaerdt&type=1
This message was produced without any <iframe tags