How to change IP Address by Python program on Win Platform

Gerhard Häring gh_pythonlist at
Mon Dec 10 18:52:11 CET 2001

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.

According to the following sources, you should be able to do all that
from Python now (NT 4 requires registry changing and reboot; NT 5.x
obviously requires invoking a win32 commandline program called
netsh.exe). Caveat: I've personally never done this.

mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))

More information about the Python-list mailing list