IP Math anyone?

Tino Wildenhain tino at wildenhain.de
Tue Feb 27 04:37:11 EST 2001


Hi Timothy,

for teaching I made a class for this.

you can instantiate it with a=ip('192.168.0.254/24') or 
a=ip('192.168.0.254','255.255.255.0') just using a=ip('192.168.0.254') 
would assign a appropriate subnet mask for this class (class B results in 
/16 or 255.255.0.0)

Since IP-adresses are only 32bit non signed integers, they are internally 
represented
like that.
If you make a class like that you can simply add the support to add 
integers to
it according to the subnet-mask you use.

Regards
Tino

--On Montag, 26. Februar 2001 17:02 -0800 Timothy Grant 
<tjg at exceptionalminds.com> wrote:

> On Mon, Feb 26, 2001 at 12:59:03PM -0800, Timothy Grant wrote:
>> Hi all,
>>
>> I checked Parnassus, but couldn't find anything, so I'll ask
>> here. Has anyone done anything with IP math (e.g.,
>> 192.168.0.254 + 1 = 192.168.1.1).
>>
>>
>
> Thanks to all who replied to this. I greatly appreciated it!
> I'll be checking out each of those solutions carefully.
>
> --
> Stand Fast,
>     rhacer.
>
> Timothy Grant, RHCE <><                              MIG #1433
> tjg at exceptionalminds.com                          '00 Marauder
> www.exceptionalminds.com/rhacer                   Craigelachie
>>>>>>>>>>> Linux, because rebooting is *NOT* normal.<<<<<<<<<<<
>>>>> This machine was last rebooted:  41 days  5:14 hours ago<<
>
> --
> http://mail.python.org/mailman/listinfo/python-list








More information about the Python-list mailing list