How To Bulk Upload DNS Records
The other day I had to add new A records for just over 250 hosts, not something I wanted to do manually! Hunting around I found some good pointers but nothing concrete, so I thought I’d put my process on here.
First, it’s worth making sure you understand and test (if needed) the dnscmd.exe tool. For example, if you want to add a standard A record to you DNS you would use the following:
dnscmd DNSServerName /RecordAdd DNSZoneName HostName RecordType IPAddress
For clarity, this could be:
dnscmd DNSServer1 /RecordAdd domain.com host1 A 192.168.0.10
Once you’ve got that down, we can then manipulate the command to pull in a list of the updates you want to do:
I put the list of IP’s and Hostnames seperated by a space into a .txt file like so:
I then used some basic batch style scripting to pull those into a command:
for /f "tokens=1-2" %i in (C:\dnsimport.txt) do dnscmd DNSServer1 /RecordAdd domain.com %i A %j
You can import pretty much most types of record this way.