Solved

DNSadd and DNS delete commands

Posted on 2011-02-27
4
922 Views
Last Modified: 2012-05-11
Hi,
I have been trying to find the exact dnsadd and dnsdel commands - couldn't
Can any one please write the exact dns commands

Above part is most important. But if you can please answer below aswell
If I have a comma saperated text file with three parameters and row delimeter ';'
IP                    Host                record type
101.2.4.3        testserver       A

Can any please write a code - i think can be done in VB
to read the file and execute the dnscmd command?
or can it even be done just by BAT files
Basically if I drop a text file with may be particular extension at dir location.
How can we read the file and create dns records from it
not sure but badly in need of help

Big basket of thanks :)
   
0
Comment
Question by:SameerMirza
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
Comment Utility
Hi Sameer,

Check following batch script if this satisfy your requirement.

You need to change variables (DNSServer, DNSZone) values inside the script. Furthermore you require DNSRecords.txt file where you will list all node names with corresponding IP address (space separated).

Hope this helps!
Farhan



@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

SET DNSServerIP=192.168.1.1
SET DNSZone=MYDOMAIN.COM.PK
SET RecordType=A

FOR /F "Tokens=1-2" %%A in ('TYPE DNSRecords.txt') DO (
	DNSCmd.exe !DNSServerIP! /RecordAdd !DNSZone! %%A !RecordType! %%B)

Open in new window

0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
Comment Utility
Have you tried with DNSCMD from Windows Support Tools? Using this tool it's easy and you can simply script all :)

Example:

Create
dnscmd DNSServerName /RecordAdd DNSZoneName HostName RecordType IPAddress

dnscmd mydns01 /RecordAdd mydomain.local testserver A 101.2.4.3

Delete
dnscmd DNSServerName /RecordDelete DNSZoneName HostName RecordType /f

dnscmd mydns01 /RecordDelete mydomain.local testserver A /f

Regards,
Krzysztof

0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
Comment Utility
@farhankazi: I'm sorry I didn't check your script code :( That I put the same code here

@SameerMirza: please skip my answer

Krzysztof
0
 

Author Closing Comment

by:SameerMirza
Comment Utility
thanks alot. I am very sorry for late reply :/
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now