Adding few DNS records from GUI is a breeze, but when you have more than one some automation will help.

Windows provides command line tools to help you with that.

But the trick is that you have to get your hands “dirty” and type some commands in bat file.

In this case I’m using dnscmd tool (from Windows Support Tools).

If you are unsure how to install it check Install Windows Support Tools tutorial from Microsoft

Here is dns.bat:

@echo off

set dnshost=localhost
set domain=

echo “We are reading records from records.txt”
for /F “tokens=1,2,3 delims=,” %%G in (records.txt) do dnscmd %dnshost% /RecordAdd %domain% %%G %%H %%I

It reads records from records.txt formatted in following way:

<hostname>,<record type>,<IP>

First record is hostname (without domain) followed by record type (A, PTR…) and last ip addres

NOTE: there is comma separating all values

How to use it:

1. Put your records in records.txt

2. type dns.bat

3. That it is… (Probably good time to validate 🙂 )

Comments

One Response to “How to add DNS records from command line (Windows)”

  1. ourworld hack on July 20th, 2013 3:06 pm

    My spouse and I stumbled over here from a different
    website and thought I might check things out. I like what I
    see so now i am following you. Look forward to looking into your web page yet again.

Leave a Reply

You must be logged in to post a comment.