Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Re: IP Maths

Expand Messages
  • Richard Maynard
    Well, in script I worked on that did this basically, wrote a function to convert an IP to a binary number, then worked with those binary numbers for network
    Message 1 of 7 , May 29, 2002
    • 0 Attachment
      Well, in script I worked on that did this basically, wrote a function to
      convert an IP to a binary number, then worked with those binary numbers
      for network groupings, as well as IP address manipulation.

      It takes a list of IP's and CIDR networks and narrows them down into the
      smallest possible list.

      _____________________ ___________________________________________
      / Richard Maynard Y "There is nothing to take a man's freedom \
      | System Administrator| away from him, save other men. To be |
      | Earthlink, Pasadena | free, a man must be free of his |
      | 1-800-EARTHLINK | brothers." -Ayn Rand |

      On Thu, 30 May 2002, ramprasad_ap wrote:

      > Can I directly do binary add , subtract or comapre in perl or Do I
      > have to convert this binary to decimal first
      >
      > --- In perl-beginner@y..., Richard Maynard <ephur@c...> wrote:
      > > Convert the IP address into binary first, then do your math, then
      > convert
      > > it back. That's the best way to do that.
      > >
      > > _____________________ ___________________________________________
      > > / Richard Maynard Y "There is nothing to take a man's freedom \
      > > | System Administrator| away from him, save other men. To be |
      > > | Earthlink, Pasadena | free, a man must be free of his |
      > > | 1-800-EARTHLINK | brothers." -Ayn Rand |
      > >
      > > On Sat, 25 May 2002, ramprasad_ap wrote:
      > >
      > > > No these are not simple numbers . These numbers range from 0-255 each
      > > > in groups of 4 etc
      > > >
      > > > --- In perl-beginner@y..., "daymobrew" <daymobrew@y...> wrote:
      > > > > --- In perl-beginner@y..., "ramprasad_ap" <ramprasad@n...> wrote:
      > > > > > I am required to write a perl script which will be able to
      > > > > manipulate
      > > > > > IP addresses
      > > > > > like 1 add to IP , subtract 2 from IP etc
      > > > > > Is there a module that can do this directly
      > > > >
      > > > > If the IP address is in a string 'split' it on the full stops (aka
      > > > > periods), then add or subtract as necessary and then 'join' it back
      > > > > together.
      > > >
      > > >
      > > >
      > > > Unsubscribing info is here:
      > http://help.yahoo.com/help/us/groups/groups-32.html
      > > >
      > > > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      > > >
      > > >
      >
      >
      >
      > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.