Adventures with NETSH

Networking, connecting to the internet, wi-fi and home entertainment
User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Adventures with NETSH

Post by John Gray »

I've had to play with this a bit recently, because I have to convert a whole bunch of PCs from static addressing to DHCP (and vice versa), and would like to throw the following past an expert in such arcane matters.

When converting from static addressing to DHCP, which sequence of commands would you prefer?
netsh interface ipv4 delete dnsservers "Local Area Connection" all
netsh interface ipv4 set address "Local Area Connection" dhcp

or
netsh interface ipv4 set address "Local Area Connection" dhcp
netsh interface ipv4 set dnsservers "Local Area Connection" dhcp

or
?
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

JoeP
SilverLounger
Posts: 2069
Joined: 25 Jan 2010, 02:12

Re: Adventures with NETSH

Post by JoeP »

See How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000. Even though the article says Win2K I can't believe that the procedure would've changed for more modern versions of Windows.
Joe

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Adventures with NETSH

Post by John Gray »

Joe - that's one of the articles I've encountered - but other articles have suggested an additional command - either Delete before, or Set after, so I wondered what network techies would use!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Adventures with NETSH

Post by StuartR »

I have done this kind of thing in the past John, but not for a very long time and my memory is not up to the task of recalling those details
StuartR


User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Adventures with NETSH

Post by John Gray »

Ah, Stuart - this networking stuff is new to me!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...

JoeP
SilverLounger
Posts: 2069
Joined: 25 Jan 2010, 02:12

Re: Adventures with NETSH

Post by JoeP »

Do you have a couple of machines you can try it on before attempting a whole bunch?
Joe

User avatar
John Gray
PlatinumLounger
Posts: 5408
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Adventures with NETSH

Post by John Gray »

I've tried it on one, using both indicated methods. The only apparent difference is that the Delete command gives a message like "There are no DNS servers assigned" (presumably "now"!).

What I'm not clear on is whether the single Set Address command is the scripted equivalent of going into the Change Adapter Settings GUI window and setting the two radio buttons "Obtain an IP address automatically" and (particularly) "Obtain DNS server address automatically". It looks as though I need to put a
netsh int ipv4 sh con
command after each of the commands in my first post. A job for tomorrow, when I'm at work!
John Gray

"(or one of the team)" - how your appointment letter indicates you won't be seeing the Consultant...