Microsoft has finally implemented an official way to use both Static and Dynamic IP simultaneously on one NIC. Reportedly, this feature was added in Windows 10 Creators Update 1703.
Windows 10The key to using this feature is the new dhcpstaticipcoexistence parameter in netsh.
Commands I used to set this up:
"Ethernet" is the name of the NIC you want to configure, run an ipconfig in cmd to get the name.
REM Enable dhcpstaticipcoexistence to allow for both DHCP and Static IP netsh interface ip set interface interface="Ethernet" dhcpstaticipcoexistence=enable REM Configure the interface to use DHCP (if needed) netsh interface ip set address "Ethernet" dhcp REM Add secondary Static IP (takes a few seconds to show up in ipconfig) netsh int ip add address "Ethernet" 192.168.0.1 255.255.255.0 REM Delete the IP (if needed) netsh int ip delete address "Ethernet" 192.168.0.1 255.255.255.0
The IP-adress will be permanently configured and is not lost when sleeping, rebooting or renewing DHCP.
Thanks to Cecil at https://superuser.com/a/1250941/771867 for spreading the word.
Alternatives and older versions of WindowsAccording to petri.com (https://www.petri.com/configure_tcp_ip_to_use_dhcp_and_a_static_ip_address_at_the_same_time) this is possible to do (relatively) easily on Windows XP.
Previously I've been using peko's Win IP Config v2.7.2 (http://www.pkostov.com/wipcfg.html) to do this in Windows 10. This works like a charm, but it does lose the configuration upon sleep, reboot and renewing DHCP. It also seems to lack a CLI or other ways to automate it, so you'll have to readd the IP through the GUI everytime it's lost. I've not been able to get the latest version, "WinIPConfig 4.0", working.
If you're a programmer, the AddIPAddress function (https://msdn.microsoft.com/en-us/library/windows/desktop/aa365801(v=vs.85).aspx) should also work to temporarily add a secondary IP.