Set from static IP to DHCP on Windows 8 using command line

两盒软妹~` 提交于 2020-01-07 08:57:34

问题


My computer is Windows 8. I used command line to set static IP address by

netsh interface ipv4 set address name="Wired Ethernet Connection" source=static address=1.1.1.1 mask=1.1.1.1 gateway=1.1.1.1

And static DNS by

netsh interface ipv4 add dnsserver name="Wired Ethernet Connection" address=1.1.1.1 index=1

Where 1.1.1.1 in both cases is just for demonstration and was replaced by my real IP.

Edit: As of 2018, 1.1.1.1 is used as a DNS server now.


I want to change from static IP to DHCP now.

I tried

netsh interface ipv4 set address name="Wired Ethernet Connection" source=dhcp

for IP and

netsh interface ipv4 set dnsservers name="Wired Ethernet Connection" source=dhcp

for DNS.

However, only the command for DNS worked.


I then checked with

ipconfig /all

It told me that DHCP was on for Ethernet. However, my previous IP was still there.

Is there any way to set from static to DHCP in command line?


回答1:


netsh interface ipv4 set address name="Wired Ethernet Connection" source=dhcp
ipconfig /renew Wired*

If above ipconfig /renew command does not help, try

netsh interface set interface name="Wired Ethernet Connection" admin=DISABLED
netsh interface ipv4 set address name="Wired Ethernet Connection" source=dhcp
netsh interface set interface name="Wired Ethernet Connection" admin=ENABLED

However, maybe all address, mask and gateway obtained from dhcp could match those defined by source=static previously.
Are there Lease Obtained and Lease Expires properties displayed in the ipconfig /ALL output?




回答2:


For Windows 10

netsh interface ip set address "Ethernet" static 10.10.10.11 255.255.255.0

netsh interface ip set address "Ethernet" source=dhcp


来源:https://stackoverflow.com/questions/32249831/set-from-static-ip-to-dhcp-on-windows-8-using-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!