Bulk Adding Entries in DNS30 June 2006 · Filed in Tutorial
There are two pieces to the formula for bulk adding records to a DNS zone. First, we’ll reuse the
for /f command used in automating the addition of entries into WINS. This time we’ll couple it with the
dnscmd.exe tool from the Windows Server 2003 Support Tools (this link is for the 32-bit SP1 tools).
The format of the
dnscmd.exe tool to add a record in DNS is:
dnscmd <server> /RecordAdd <zone> <node> <RR type> <RR data>
To create a host (A) record, the actual command would look like this:
dnscmd . /RecordAdd example.net host1 A 10.20.30.40
The “.” syntax here refers to the local server; this can be easily substituted with an IP address or hostname of a remote DNS server.
Using some of the same techniques as before, combining
dsncmd.exe with the
for batch command allows us to do something like this:
This assumes that the “newhosts.txt” file contains something like this:
host1 10.20.30.40 host2 188.8.131.52 host3 184.108.40.206
Here’s a small twist, though: What if your list isn’t space delimited, but comma delimited? No problem, just adjust your command accordingly:
The “delims=,” parameter tells the
for command to use a comma as the delimiter, allowing us to use comma-separated input.
With this command, we now can pretty easily add large numbers of hosts to a DNS zone file.Tags: Microsoft · Windows Previous Post: Mounting ISO Images in Linux Next Post: Trojan Horse Exploiting OS X Flaw