How to change IP Address by Python program on Win Platform

Peter Hansen peter at engcorp.com
Mon Dec 10 23:56:10 EST 2001


Gerhard Häring wrote:
> 
> Le 10/12/01 à 16:05, Joel Quinet écrivit:
> > [about changing IP address from Python]
> > Windows Platform and more generally NT and 2K
> > Sorry for that.
> 
> IIRC you cannot change the IP address on NT without rebooting. A common
> solution is to create several hardware profiles with different network
> settings (IP address, gateway, ...), then select the appropriate
> hardware profile when booting.
> 
> I'm certain it's possible to change the IP address programmatically on
> Windows NT 5.x, but as as far as I can see, the relevant API functions
> aren't exposed to ActiveState's win32 extensions, yet.

If I recall correctly, and believe me I may not :-), I think
I've successfully changed the IP address on a WinNT machine
*without* rebooting.  It may simply be that I changed the
routing tables with 'route add' and such, which could easily
be wrapped with Python, but I somehow remember actually
having changed the IP address too.  I no longer have an
NT machine handy to test on (thank god :-), but is it
possible that if you change the network settings and simply
ignore the request to reboot, that an address change is
actually accepted immediately?

-- 
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com



More information about the Python-list mailing list