Simple DNS script

For some weird reason secondary Simple DNS server waits too long sometimes to update DNS records changed on primary DNS server. Especially if lots of records were changed in a short time.

It takes too much time to reload all the records manually in such cases. So we recommend to run the following script on your secondary Simple DNS server. The script forces the server to make the secondary zones update.

The script is created, tested and used many times by our team and our friends. And we feel the need to share it with our website community. Use it and enjoy!

You just need to change FIND_A_RECORD and PRIMARY_DNS_IP constants in this script and run it.

Let’s say you have changed multiple A records on your primary DNS server and changed their IP address from 101.202.3.4 to something else. And your primary DNS IP address is 99.88.77.66. In this case FIND_A_RECORD = “101.202.3.4” and PRIMARY_DNS_IP = “99.88.77.66”

Download the script.

‘ А-record we need to replace (“old” record)
Const FIND_A_RECORD = “1.2.3.4”
‘ IP address of your primary DNS server
Const PRIMARY_DNS_IP = “10.11.12.13”

Set C = CreateObject(“SDNSAPI.Connection”)
C.Init “127.0.0.1”,8053,””
Set L = C.GetZoneList()

for each O in L
if O.Secondary then
Set zone = C.GetZone(O.ZoneName)
k = zone.Records.IndexOf(“www.” & O.ZoneName, “A”, FIND_A_RECORD)
if k <> -1 then
WScript.Echo “FOUND ZONE: ” & zone.Name

C.RemoveZone(O.ZoneName)
WScript.Echo “Removed: ” & O.ZoneName

Set Z = C.CreateZone(O.ZoneName, “ns1.testzone.com”, “hostmaster@testzone.com”)
Z.PrimaryIP = PRIMARY_DNS_IP
C.UpdateZone(Z)
Set Z = Nothing

WScript.Echo “Created secondary zone: ” & O.ZoneName
end if
Set zone = Nothing
end if
next