How to Reset IP address from static IP address to dynamic IP Address everytime when a User reboots the system?
-
I am new to networking and i am curious to find a way to write a script so that when the system IP address is set static, it must set back to dynamic IP address automatically when the system reboots. so I learnt how to do it manually but its a set of 30 Systems so i want to know if there is a way to write a script such that if the system has a static IP address it should be set back to dynamic IP address when the system reboots. Is it possible to do this? Please let me know. Any help is much appreciated. Thank you :)
-
I am new to networking and i am curious to find a way to write a script so that when the system IP address is set static, it must set back to dynamic IP address automatically when the system reboots. so I learnt how to do it manually but its a set of 30 Systems so i want to know if there is a way to write a script such that if the system has a static IP address it should be set back to dynamic IP address when the system reboots. Is it possible to do this? Please let me know. Any help is much appreciated. Thank you :)
From the command-line, you can use
netsh
to change back to a DHCP address:netsh interface ip set dns "Local Area Connection" dhcp
Netsh commands for Interface IP | Microsoft Docs[^] You'll need to know the name of the interface you're changing. From C# or PowerShell, you can use WMI: networking - C# - enable / disable DHCP - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
From the command-line, you can use
netsh
to change back to a DHCP address:netsh interface ip set dns "Local Area Connection" dhcp
Netsh commands for Interface IP | Microsoft Docs[^] You'll need to know the name of the interface you're changing. From C# or PowerShell, you can use WMI: networking - C# - enable / disable DHCP - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thank You Richard. I will research on that.Thanks for the heads up :thumbsup: :)
-
I am new to networking and i am curious to find a way to write a script so that when the system IP address is set static, it must set back to dynamic IP address automatically when the system reboots. so I learnt how to do it manually but its a set of 30 Systems so i want to know if there is a way to write a script such that if the system has a static IP address it should be set back to dynamic IP address when the system reboots. Is it possible to do this? Please let me know. Any help is much appreciated. Thank you :)
Been a while but I am pretty sure that you can configure your DHCP server to require that the IP change. Basically the client computer asks for a new IP from the DHCP server and it is allowed to suggest a prior one. The DHCP server and accept that request or reject it and send back the one it wants. So one can set up a rule in the DHCP server that forces a new IP based on other criteria. That means nothing the client does, normally, would allow it to 'set' a static IP. Even if a user sets it up that way the DHCP would refuse. At least at one time this was a common security constraint.