Is a batch file the only way to release and renew an IP in one step?

ipconfig /release
ipconfig /renew

I unfortunately have to admin some Windows servers using Remote Desktop. Obviously if I type ipconfig /release, then I'll loose my connection and won't be able to ipconfig /renew. Obviously this can be done with .bat files, but I wanted to ask the pros just to see if there were any other tricks to doing it in the Windows server world.

  • The 'pros' would look to have an out-of-band remote management solution such as HP Integrated Lights Out or Dell's DRAC system in place. It then doesn't matter if the main network interfaces are functional with a correct IP address or not, you can still remote control the server to get them changed and working again. – SteveBurkett Jun 25 '10 at 11:33

Most people I think just either use static IP addresses for servers, or fixed DHCP assignments, and don't change IP addresses outside of scheduled reboots (Changing endpoints on running servers=bad). A bat file seems the simplest solution, but honestly even a straight up release should autorenew an IP address before the remote desktop session times out.

| improve this answer | |
  • in agreement, sounds odd to have renew the ip address of a server- it is generally not recommended. – redknight Jun 24 '10 at 17:57
  • 1
    +1 DHCP on a server is not recommended at all, but I'd go with a right-click Repair on the NIC properties in the systray; that should work too and on a remote workstation I just tried, my RDP session persisted without issue. – gravyface Jun 24 '10 at 17:58
  • 1
    I'm in the process of switching the server from a fixed address to a static DHCP lease on a new DHCP server. That's why I need to release/renew it, so it picks up its static lease from the new DHCP server. – Jake Wilson Jun 24 '10 at 17:58
  • When you set it to DHCP it should auto renew? It certainly shouldn't need to release (what would it even be bound to?). – yasth Jun 24 '10 at 18:01
  • Agreed that this, in general, is not something you would want to do... but when setting up the machine to use a static IP in the first place, while remoted in? It just saved my bacon. – mmc Feb 3 '13 at 20:55

Combine the two commands into one

ipconfig /release && ipconfig /renew

| improve this answer | |
  • 7
    +1 for answering what they asked instead of touting best practices at them! Although, in my trials here, you might need to stop the RDP session and re-establish (even if it's by name, not IP) as mine seems to just be trying to reconnect to the old IP still. Don't forget to ipconfig /flushdns after renewing the IP and giving it time to check in and before trying to find the hostname again! – PsychoData Apr 15 '15 at 21:17

Use AT command. Example AT 12:58 ipconfig /release

AT 12:59 ipconfig /renew (this is useful when connecting with psexec, because it does not handle && commands)

| improve this answer | |
  • Would definitely work! Use at to schedule a renew in a minute or so and schedule the /release for shortly before, or just do the /release yourself – PsychoData Apr 15 '15 at 21:18

Since the at command is deprecated now and doesn't work in Windows 10 (it gives the error The AT command has been deprecated. Please use schtasks.exe instead. The request is not supported.), here's an example of using schtasks to schedule the command to renew later.

schtasks /create /tr "ipconfig /renew" /st 02:00 /sc once /tn iprenew

Note that this creates a one-time scheduled task which clutters up the scheduled tasks list so simply delete it when you're done via the GUI or the command line.

| improve this answer | |

In powershell it would be ipconfig /release | ipconfig /renew

| improve this answer | |
  • This would pipe the output of ipconfig /release into ipconfig /renew. I guess both commands would run, but simultaneously - it might try (and fail) renewing before it releases. && might work instead of |, as in Jason's answer. – mwfearnley Jan 25 '19 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.