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. 4766 views.

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
2019-12-17 09:25 by MildaEvilda
Thanks a lot, I needed to configure device with static IP and this helped me to not lost internet connection during setup.
2019-12-17 13:54 by Artem
Thanks so much for this!
2019-12-26 09:56 by Eli
HI,Is this parameter could close?i set dhcpstaticipcoexistence=disabled but it return a error."the parameter is incorrect".thanks
2020-04-18 14:45 by 2Sheds
Thank you very much for this. It worked like a charm.
2020-06-30 12:52 by SCDINET
Thank you very much for this. It worked like a charm.
2020-08-17 09:09 by secult
awesome!
2020-10-29 08:43 by Roby
Thank you very much. It works great!
2022-09-16 11:29 by Ahmed
Very useful, thank you.
2022-12-13 10:49 by Kevin
Thanks, just what I needed.