JSI Tip 10054. How often does DNS scavenge its database?
January 11, 2006
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 offsetlocal ENABLEDELAYEDEXPANSIONset LAN="Local Area Connection"if {%1} NEQ {} set LAN=%1set LAN=%LAN:"=%set LAN=Ethernet adapter %LAN%:set OK=Nset DNSIP=NONEset Zone=NONEfor /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%HKLMSYSTEMCurrentControlSetServicesDNSParameters /V ScavengingIntervalset si=0x0for /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)endlocal
About the Author
You May Also Like