DNSCMD command line tool can be used to create DNS entry, I would like to explain how we can use DNSCMD to create and delete bulk DNS record from text file, creating and deletion bulk DNS entry it very simple if you use this procedure
How to create Bulk DNS record
First we will see the bulk DNS creation, we have to create the A record first (In forward zone) then corresponding PTR record for that A record (In reverse zone), before that we have to create input file, update the input file like below
RECORD_2_ADD;ZONE_WHERE_ADD_RECORD;IP_ADDRESS
Example:
Test001;eur.domainname.com;192.168.100.10
Command to create Bulk A record (host record)
for /f "tokens=1-3 delims=;" %a in (list.txt) do dnscmd Server Name /RecordAdd %b %a A %c
Command to create Bulk PTR record
for /f "tokens=1-3 delims=;" %a in (list.txt) do for /f "tokens=1-4 delims=." %e in ("%c") do dnscmd Server Name /recordadd %g.%f.%e.in-addr.arpa. %h PTR %a.%b
How to delete Bulk DNS record
Like creation, you have to delete both A as well as corresponding PTR records to completely delete the DNS entry, you can use the similar input file
Command to delete Bulk A record
for /f "tokens=1-3 delims=;" %a in (list.txt) do dnscmd Server Name /RecordDelete %b %a A /f
Command to delete Bulk PTR record
for /f "tokens=1-3 delims=;" %a in (list.txt) do for /f "tokens=1-4 delims=." %e in ("%c") do do dnscmd Server Name /RecordDelete %g.%f.%e.in-addr.arpa. %h PTR /f
Note: Change the server name with your DNS server name and You should run this command from where the input file (list.txt) there, and this command will check all the DNS names in the input file (list.txt)
No need to change the input file format, yes we can use same input file for all this commands, you can use our Free DNS tool to create a single DNS record
Hi,
I want to delete a particular DNS “A” record and its corresponding “PTR” record by using “DNSCMD” or “Remove-DnsServerResourceRecord”, IF it only resolve host name by “NSLOOKUP” or “Resolve-DnsName”. By using batch file or powershell.