1
votes

I'm using wmi to change my ip address but it doesnt work in a for loop

import webbrowser
import random
import ipaddress
import socket
import wmi
import time as t

ip = u'174.116.16.133'
subnetmask = u'255.255.255.0'
gateway = u'192.168.0.1'

AustraliaIP = u'154.6.147.45'
BelgiumIP = u'181.214.218.233'
BrazilIP = u'188.241.177.133'
CanadaIP = u'174.116.16.133'
FranceIP = u'51.75.5.209'
GermanyIP = u'45.136.153.58'
HongKongIP = u'47.242.48.178'
IrelandIP = u'84.247.48.56'
ItalyIP = u'84.17.58.117'
JapanIP = u'156.146.35.22'
MexicoIP = u'77.81.142.138'
UnitedStatesIP = u'192.241.129.46'


IPList = [AustraliaIP, BelgiumIP, BrazilIP, CanadaIP, FranceIP, GermanyIP, HongKongIP, IrelandIP, ItalyIP, JapanIP, MexicoIP, UnitedStatesIP]

for i in IPList:
    t.sleep(20)
    print(i)
    nic.EnableStatic(IPAddress=[i], SubnetMask=[subnetmask]) #here is where i change the ip address
    nic.SetGateways(DefaultIPGateway=[gateway]) #here too

The bottom for loop is where i change the ip addresses. Whenever i check websites like https://whatismyipaddress.com/ it shows that the ip hasnt changed

.What is nic? - Pranav Hosangadi
does the print shows the right ip? - Farid Fakhry
Could you add your output from the for loop? - AlphaA999
IP address and its gateway should be on the same network, right? or am I missing something? - Nesi
Try doing a google search or check the documentation of what you are using. - AlphaA999