-1

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?

dibery
  • 2,760
  • 4
  • 16
  • 25

3 Answers3

0
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?

JosefZ
  • 28,460
  • 5
  • 44
  • 83
  • I tried your commands above, but they didn't work when unplugged. (When plugged in, they worked.) Is there any way I can do when not plugged in? Or I must plugged in to set these commands? – dibery Aug 28 '15 at 06:57
  • An unplugged interface can't reach a `dhcp` server therefore it loses all leased properties... Leases should be renewed after re-plugging it with no _hand_ intervention. – JosefZ Aug 28 '15 at 07:30
0

It is because you did not plugged the cable for that specific interface. So try plugging the cable to the interface and run command again.

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

It worked for me.

-1

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
stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
RWK
  • 9