How can I set my DNS settings using the command-prompt or PS?

Through the CLI (either cmd.exe or PowerShell) on Windows 7, how do I edit the TCP/IP DNS parameters for a specific network adapter?


Solution 1:

netsh.exe

netsh interface ip set dns name="Local Area Connection" source=static addr=none

netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4 index=1
netsh interface ip add dns name="Local Area Connection" addr=8.8.8.8 index=2

netsh interface ip set dns name="Local Area Connection" source=dhcp

Solution 2:

Main thing: you can set first DNS as static entry. Next you can only add/append other DNS servers. So, to set primary DNS server use something like this:

netsh interface ip set dns name="Local Area Connection" static 8.8.8.8

for adding/appending other DNS servers you have to use add option, something like this:

netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4 index=2