Skip navigation

JSI Tip 3511. How can I change all my computer's DNS Server addresses using a batch file?


If you specifically configured the DNS Server address on your computers, and need to change its' IP address, you do NOT have to visit each of clients to effect the change.

The DNS server address is stored in the registry in the NameServer value name, a simple string data type, at or below the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\parameters

Using Regfind.exe, which I first documented in tip 1084, from either the Windows NT 4.0 Resource Kit Supplement or the Windows 2000 Resource Kit Supplement, you can create a batch file to change it. The batch file would contain one line for each remote computer that has a DNS Server IP address specifically configured. It can also contain a line for the local workstation that you run the batch from:

@echo off
REM Local computer
regfind -p HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\parameters "Old DNS IP" -r "New DNS IP"
REM Remote computers
regfind  -m \\computer1 -p HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\parameters "Old DNS IP" -r "New DNS IP"
regfind  -m \\computer2 -p HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\parameters "Old DNS IP" -r "New DNS IP"
regfind  -m \\computer3 -p HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\parameters "Old DNS IP" -r "New DNS IP"
'Old DNS IP' and 'New DNS IP' are dotted decimal notation, like 198.192.0.1




Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish