JSI Tip 10054. How often does DNS scavenge its database?

If you have enabled scavenging for all zones, or any specific zone, the default scavenging interval is 168 hours (hexadecimal 0xA8, or 7 days, or 1 week).

To set the scavenging interval:

1. Open the DNS snap-in.

2. Right-click the server name and press Properties.

3. Select the Advanced tab.

4. Check the Enable automatic scavenging of stale records box.

5. Set the Scavenging period.

6. Press Apply.

7. Press OK.

Using REG.EXE, built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools, and Hex2Dec freeware from SysInternals, I have scripted ScavengingInterval.bat to display the scavenging interval in decimal hours.

The syntax for using ScavengingInterval.bat is:

ScavengingInterval \[LAN\]

Where LAN is optional name of your connection, like JSIINC. If not specified, it will default to Local Area Connection.

The scavenging interval number of hours is displayed on the console. To import it an environment variable:

for /f "Tokens=*" %%s in ('ScavengingInterval \[LAN\]') do set /a ScavengingInterval=%%s

If ScavengingInterval.bat returns a 0, scavenging has been disabled.

ScavengingInterval.bat contains:

@echo off
set LAN="Local Area Connection"
if \{%1\} NEQ \{\} set LAN=%1
set LAN=%LAN:"=%
set LAN=Ethernet adapter %LAN%:
set OK=N
set Zone=NONE
for /f "Tokens=*" %%a in ('IPCONFIG /ALL') do (
 set line=%%a
 for /f "Tokens=*" %%x in ('@echo %%a ^|find "Ethernet adapter "') do set OK=N
 for /f "Tokens=*" %%x in ('@echo %%a ^|find "%LAN%"') do set OK=Y
 if "!OK!" EQU "Y" for /f "Tokens=*" %%x in ('@echo %%a ^|find "DNS Servers . . . . . . . . . . . : "') do set DNSIP=!line:~36!
set qry=REG QUERY \\%DNSIP%\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters /V ScavengingInterval
set si=0x0
for /f "Tokens=1,3" %%a in ('%qry%^|find /i "ScavengingInterval"') do (
 set si=%%b
for /f "Skip=4 Tokens=2 Delims== " %%x in ('hex2dec %si%') do (
 @echo %%x

TAGS: Windows 8
Hide 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.