netmask in a script

Dazed_75 lthielster at gmail.com
Thu Oct 27 00:38:34 MST 2011


Thanks Josef, I was hoping there was a way to avoid the manipulation work.

I have never used Python though I have looked at some.  I saw 3 .py files
and release notes in the download.  I saw no readable description of the
contents/functionality and more unfamiliar code I didn't want to read.
probably easier to do the manipulations than to learn Python.

On Thu, Oct 27, 2011 at 12:24 AM, Joseph Sinclair <plug-discussion at stcaz.net
> wrote:

> well, an IP4 address is just an unsigned int32, and a netmask is just the
> number of bits to keep...
> you could turn the dotted notation into an int32, then mask off the proper
> bits, then translate back to the dotted notation.
>
> Or you could use Python for the script and use the ip address library in
> Python[1] to apply the netmask.
>
> [1] http://code.google.com/p/ipaddr-py/
>
> On 10/26/2011 09:49 PM, Dazed_75 wrote:
> > I would like to apply a netmask to an arbitrary IP in a bash/dash script
> > (e.g. apply 255.255.255.0 to 173.10.3.155 to get 173.10.3.0).  Is there
> any
> > easy way to do that without taking the IP apart, doing 4 operations and
> > reassembling the results?
> >
> >
> >
> >
> > ---------------------------------------------------
> > PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> > To subscribe, unsubscribe, or to change your mail settings:
> > http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>



-- 
Dazed_75 a.k.a. Larry

The spirit of resistance to government is so valuable on certain occasions,
that I wish it always to be kept alive.
  - Thomas Jefferson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.PLUG.phoenix.az.us/pipermail/plug-discuss/attachments/20111027/f6585590/attachment.html>


More information about the PLUG-discuss mailing list