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:

host1 192.168.0.10
host2 192.168.0.11
host3 192.168.0.12

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

Simple!

You can import pretty much most types of record this way.

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: