How to change IP Address by Python program on Win Platform

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Dec 11 04:44:47 EST 2001


Peter Hansen <peter at engcorp.com> wrote in 
news:3C1591EA.2E57F1CD at engcorp.com:

> 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?

You can definitely change the ip address without rebooting in some 
circumstances. For example connecting a dial-up modem link adds a new ip 
address and you can hangup and redial to get a different address. If you 
use DHCP you can release and renew your IP address from the DHCP server, 
and this may result in a changed address.

More relevantly, I have recently used some software from Veritas which 
dynamically adds and removes ip addresses at runtime, although each network 
card also has a fixed ip address that is not changed. So it must be 
possible, although I don't know offhand what system calls might be involved 
or whether you can do it from python.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list