Microsoft Windows: Using DHCP and Static IP simultaneously on one NIC

Posted 2017-12-16 19:03 by Traesk. Edited 2017-12-16 19:10 by Traesk. Viewed 2259 times.

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 10

The key to using this feature is the new dhcpstaticipcoexistence parameter in netsh.
Commands I used to set this up:
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
"Ethernet" is the name of the NIC you want to configure, run an ipconfig in cmd to get the name.
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 Windows

According 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.

Comments
2018-03-05 11:25 by Michael
Thank you very much!
2018-10-15 13:20 by Bert
This solved a big problem for me. Thanks!
2018-10-22 11:41 by Harry
Thank you