1

Hi i'm using dnsmcd command on my windows server 2012 in order to create new zones from csv file.

But i need to change TTL on SOA record so i try to do this:

dnscmd /recordadd example.com `@ 300 SOA

but i've this error :

Command failed:  DNS_ERROR_RECORD_FORMAT     9702    0x25E6

there is a way to do that?

tafazzi87
  • 135
  • 5

2 Answers2

0

Heres the correct format to modify a Start of Authority record

dnscmd /recordadd zonename @ SOA primaryDNSservername responsibleemailipaddress serialnumber refreshinterval retryinterval expireinterval defaultTTL
0

If you are wondering why you are getting this error DNS_ERROR_RECORD_ALREADY_EXISTS when trying to change the SOA record (ie. increase the serial number of the zone), check if the serial you are changing to (the new one) is actually higher than the current one. This error message is confusing, so I hope it spares you some head scratching until you figure out why.

I used this script if you find it useful, because clicking "increase" on 200-something zones was too much for me.

rem  To increase serial on all zones: copy this to a script, as functions cannot be use from CLI

echo on

rem  get the intersting zones first that you want to change
echo. > %TEMP%\dnszones.txt
for /f %%z in ('dnscmd /enumzones ^| findstr in-addr.arpa') do echo %%z >> %TEMP%\dnszones.txt

rem  take existing serials from all zones
for /f %%z in (%TEMP%\dnszones.txt) do dnscmd /zoneprint %%z | findstr SOA > %TEMP%\dns.%%z.txt

rem  read the serials and increase them
for /f %%z in (%TEMP%\dnszones.txt) do for /f "tokens=1-8*" %%a in (%TEMP%\dns.%%z.txt) do call:increase_serial %%z %%e

goto end

:increase_serial
rem arg1=%~1 is the zone name, arg2 is existing serial
@rem  example format of the SOA record
@rem         3600 SOA   servername.domain.com. hostmaster.domain.com. 13 900 600 86400 3600

@rem  as per https://technet.microsoft.com/en-us/library/cc816941(v=ws.10).aspx
@rem  var a is minimum-default-ttl - optional
@rem  var b is string SOA
@rem  var c is PrimSvr - server name with dot
@rem  var d is Admin - contact for admin
@rem  var e is serial
@rem  var f is Refresh - in seconds
@rem  var g is Retry - in seconds
@rem  var h is Expire - in seconds
@rem  var i is MinTTL - in seconds

set /a INCREASED_SERIAL=%~2+1
@echo increase serial from %~2 to %INCREASED_SERIAL% on zone %1
for /f "tokens=1-8*" %%a in (%TEMP%\dns.%~1.txt) do dnscmd /RecordAdd %~1 @ SOA %%c %%d %INCREASED_SERIAL% %%f %%g %%h %%i
goto :eof

:end
Piotr Kierklo
  • 161
  • 1
  • 4