Hello,
If you are lazy (as we are) or you don’t want to waste all your time adding DNS entries manually, you can use dnscmd via command line on Windows. It’s a nice way to put a large entries from a file or something that needs further configuration.
PROMPT> dnscmd help
dnscmd yourdnsserver /RecordAdd yourdomain.com mynewrecord A ip
so
(creates ftp.domain.com that points to 192.168.1.20)
dnscmd localhost /RecordAdd domain.com ftp A 192.168.1.20
(creates http://www.domain.com that points to 192.168.1.21)
dnscmd localhost /RecordAdd domain.com www A 192.168.1.21
You can use A, CNAME, PTR, TXT etc.
An example of a batch file putting entries in the same IP using loops.
PROMPT> type records.txt
record1
record2
record2
etc …
type dns.bat
@echo off
set dnshost=localhost
set domain=yourdomain.com
set type=A (dns type, PTR, CNAME etc)
set ipserver=192.168.1.20
echo “We are reading line by line records.txt”
for /f %%record in (records.txt) do dnscmd %dnshost% /RecordAdd %domain% %%record %type% %ipserver%
See you!
Hi All,
I need help on this. I need to ADD a SYSTEM DNS from a Command Prompt.
And the DNS uses a driver Microsoft Access Driver (*.MDB).
Please Need your help.
Sudhir
I’m sorry but you are confusing concepts and acronyms. Here we were talking about DNS (Domain Name System, http://en.wikipedia.org/wiki/Domain_Name_System), you are seeking info on DSN (Database Source name, http://en.wikipedia.org/wiki/Database_Source_Name). I left the DSN’s realm years ago so I’m sorry but I cannot help you. :)
Good job! I used this to determine the reverselookup-addresses of PCs in our network. The Netbiosname is vt1-05, dns=vt1-05.localdomain.de
Add a CNAME (=alias)
dnscmd localhost /RecordAdd localdomain.de pc-richard CNAME vt1-05.localdomain.de
Change a reverselookup:
# delete old record
# ip: _only_ the last number 192.168.81.5 -> 5
dnscmd localhost /RecordDelete 81.168.192.in-addr.arpa 5 PTR /f
dnscmd localhost /RecordAdd 81.168.192.in-addr.arpa 5 PTR pc-richard.localdomain.de
Thanks for the info!
Once I started playing around with this, I found it a little smoother if I had the contents of the text file as host and ip, ie:
host1 ip1
host2 ip2
and then slightly modified the batch file to be:
FOR /f “tokens=1,2” %a IN (records.txt) DO dnscmd localhost /RecordAdd %domain% %a %type% %b
Hope this comes in handy for others!
Thanks again,
Patrick
typo in my FOR line above (it’ll work on command line but not embedded in a batch file)… should have double %’s in front of a and b:
FOR /f “tokens=1,2” %%a IN (records.txt) DO dnscmd localhost /RecordAdd %domain% %%a %type% %%b
@ Patrick
works great
The “dnscmd” command is only available under :
– Windows Server 2003
– Windows Server 2003 R2
– Windows Server 2003 with SP1
– Windows Server 2008,
according to http://technet.microsoft.com/en-us/library/cc772069%28WS.10%29.aspx
Any Windows Vista alternatives?
I knew this would be possible. Day after day I have to use public IP’s for remote management and it gets tedious! this way I can just add memorable names to the IP’s saving me a load of hassle. Great article, very well laid out and demo’d.