Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


  1. I have a server named server1.domain.local
  2. I have lots of CNAME entries in various forward lookup zones pointed to server1.domain.local
  3. I want to decomission server1, and have a new server, server2, that is going to replace it.

I need to change all of my CNAMEs that point to server1.domain.local to point to server2.domain.local.

I know I can create server1.domain.local as another CNAME, but I would prefer to just find all the entries and change them individually.

How can I go about finding all references in all forward lookup zones to server.domain.local?

share|improve this question
up vote 3 down vote accepted

The dnscmd utility from the Windows Support Tools is probably your best bet. You can get a list of all the DNS zones with the command: dnscmd [servername] /EnumZones. You can enumerate all the CNAME records in each zone with the command: dnscmd [servername] /EnumRecords [zone name] . /TYPE CNAME.

In theory you could chain these two together in a script, process the output, and make the changes you want automatically (also using dnscmd with the /RecordDelete and /RecordAdd commands). That's an exercise I'll leave to you (for now).

Edit: Okay-- I couldn't resist. Here's that script. It will only echo the commands that actually make changes. If it does what you want then you can pull the echo commands out and let 'er rip.

@echo off


rem Quick and dirty list of Primary zones that aren't Reverse zones
for /F "usebackq" %%i in (`dnscmd %1 /EnumZones ^| find " Primary" ^| find /v " Rev"`) do call :process_zone %1 %%i
goto end

rem Quick and dirty enumeration of all CNAME records in a zone
for /F "usebackq tokens=1,3,4" %%i in (`dnscmd %1 /EnumRecords %2 . /TYPE CNAME ^| find " CNAME"`) do call :process_RR %1 %2 %%i %%j %%k
goto end

rem Check a record and alter it if necessary
if /I "%5" EQU "%SERVER_TO_REPLACE%" (
  echo dnscmd %1 /RecordDelete %2 %3 %4 %5 /f
  echo dnscmd %1 /RecordAdd %2 %3 %4 %REPLACEMENT_VALUE%

share|improve this answer

One method would be to run nslookup from one of your DNS servers, or a system that is permitted to perform a zone transfer. With nslookup do a ls > file which will request a copy of the zone database and save it to a text file. Then the search feature in your favorite text editor to find things to fix.

share|improve this answer
Bear in mind that, by default, a Windows DNS server won't permit zone transfers. The OP would need to allow zone transfers in order to do that. – Evan Anderson May 17 '11 at 19:26

Are these AD integrated zones? If not, you can manually edit the zone files with notepad (find and replace) and then reload the zones.


My bad. I didn't see in your title that these are AD integrated zones. You can still use the method I posted by changing the zones to non-AD integrated zones, editing the zone files that will be created, then changing them back to AD integrated zones. It's a bit of a hack so this may not be the method you'd prefer to use.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.