Hi i'm trying to write a script for changing my ip, subnet mask and gateway.
The script runs, don't give out any error but doesn't change anything. Even the print, the new ip is still the same as the current one.
what am i doing wrong?
# importing os module
import os
import ipaddress
import socket
# Get the current working
# directory (CWD)
cwd = os.getcwd()
# Print the current working
# directory (CWD)
print("Current working directory:", cwd)
# Print current IP
hn = socket.gethostname()
ipa = socket.gethostbyname(hn)
print("Current IP: ",ipa)
os.system('netsh interface ip set address name="FirstSetup" static 192.168.0.20 255.255.255.0 192.168.0.1')
print("IP ADRESS CHANGED!")
# Print newIP
hn = socket.gethostname()
ipa = socket.gethostbyname(hn)
print("New IP: ",ipa)
Changing all of this requires windows to make a reboot. Try restarting and you will see that your IP has changed.