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?
Asked
Active
Viewed 7.7k times
14
-
1http://superuser.com/questions/463096/change-dns-with-script/463110#463110 – Logman Aug 31 '13 at 23:20
3 Answers
28
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
ephemient
- 24,884
- 4
- 30
- 20
3
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
Jet
- 2,506
- 25
- 35
Pol Hallen
- 244
- 2
- 11
-
Or to simplify the 2 statement: `netsh interface ip add dns "Local Area Connection" 8.8.4.4 2` – yW0K5o Dec 25 '19 at 17:06
1
There is a ton of information on managing DNS servers with Powershell, here is a great article from the scripting guys:
If your wanting to manage your own Local DNS settings on your workstation, you can use powershell to connect to WMI, and use the DNS WMI classes.
Brian
- 2,982
- 17
- 18