Apr 18, 2012
tom

How to automate DNS server reconfiguration for TCP/IPv4 and TCP/IPv6 in Windows 7?

Question

I need to switch Internet Protocol Version 4 (TCP/IPv4) and Internet Protocol Version 6 (TCP/IPv6) settings for DNS server configuration from “Obtain DNS server address automatically” to hard coded values (for Google’s DNS servers) and back. It’s kind of a hassle to do manually (I need to go to Control Panel-Network and Internet-Network Connections, open Wireless Network Connection 2, then open Properties for the corresponding version, enter the DNS server values, and repeat for the other one). Is there a utility or script that would automate the process? Thanks.

Asked by Alek Davis

Answer

In powershell:

$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"    
$wmi.SetDNSServerSearchOrder("8.8.8.8"."8.8.4.4")

To revert:

$wmi.SetDNSServerSearchOrder()

(no parameters=null, this will put it back in automatic mode)

References:

http://fatbeards.blogspot.com/2008/06/change-dnswins-ip-on-multiple-servers.html

http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/28/use-powershell-to-configure-static-ip-and-dns-settings.aspx

Answered by Lucas Kauffman

Related posts:

  1. IPv6 fallback to IPv4
  2. How do I setup a TCP over DNS tunnel on Windows?
  3. How do IPv4 only applications work on IPv6 only hosts?
  4. IPv4 over IPv6?
  5. How to get the total records in my DNS SERVER (windows Server 2003)

Leave a comment