When managing Windows servers remotely via RDP, executing network commands becomes tricky. The classic sequence:
ipconfig /release
ipconfig /renew
presents an obvious problem - the moment you release the IP, your RDP session terminates before the renew command can execute.
The standard approach involves creating a batch file:
@echo off
ipconfig /release
timeout /t 3 >nul
ipconfig /renew
pause
This works but requires file creation and execution permissions. Let's explore more elegant solutions.
For modern Windows servers (2012 R2 and later), PowerShell provides a cleaner solution:
Start-Process -FilePath "ipconfig" -ArgumentList "/release" -Wait; Start-Process -FilePath "ipconfig" -ArgumentList "/renew"
For servers where you need recurring IP refreshes:
schtasks /create /tn "RefreshIP" /tr "ipconfig /release && ipconfig /renew" /sc once /st 23:59 /f
Then trigger it immediately with:
schtasks /run /tn "RefreshIP"
For system administrators managing multiple servers:
$network = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq "True"}
$network.ReleaseDHCPLease()
Start-Sleep -Seconds 3
$network.RenewDHCPLease()
Always test these methods in non-production environments first. For critical servers, consider:
- Having console access as backup
- Using out-of-band management interfaces
- Scheduling during maintenance windows
Every Windows server administrator has faced this scenario: You need to refresh a machine's IP configuration, but you're connected via Remote Desktop. Running ipconfig /release
immediately drops your connection, leaving you unable to execute the subsequent ipconfig /renew
command.
The traditional approach involves creating a batch file containing both commands:
@echo off
ipconfig /release
ipconfig /renew
While effective, this method requires file creation and execution permissions, which might not always be available in locked-down environments.
For modern Windows servers (2012 R2 and later), PowerShell offers a cleaner solution:
Start-Process -FilePath "ipconfig" -ArgumentList "/release" -Wait; Start-Process -FilePath "ipconfig" -ArgumentList "/renew"
This executes both commands sequentially in a single operation.
For servers where you can't run scripts directly, create a scheduled task that runs on demand:
schtasks /create /tn "RefreshIP" /tr "cmd /c \"ipconfig /release && ipconfig /renew\"" /sc ONCE /st 00:00
Then trigger it when needed:
schtasks /run /tn "RefreshIP"
For more control over specific adapters, use netsh commands:
netsh interface ip set address "Ethernet" dhcp
netsh interface ip set dns "Ethernet" dhcp
- Always test during maintenance windows
- Document the method used for each server
- Consider creating a dedicated management interface
- For critical systems, implement out-of-band management (iDRAC, iLO, etc.)