Share via


How to import to DNS from Host file

Question

Thursday, May 6, 2010 4:38 PM

I work for a large corporation and help manage our 200+ Cisco devices.  We have these devices mapped to IP addresses with a host file.  I have been tasked with getting those devices and ~300+ more devices listed in DNS with A records.  I have done a bit of looking and could not find a method that would allow me to take either a text file or csv file and import those into an existing AD primary DNS zone.  Anyone have an idea on this?

All replies (3)

Thursday, May 6, 2010 6:15 PM ✅Answered

The only idea that I can come up with that would possibly work for you is that you can create the DNS zone initially as a primary standard zone (not AD integrated).  Take the DNS zone file (its a txt file) and edit it manually using a text editor such as notepad.  Copy the entries from your HOSTS file into the DNS zone file.  Then format the information properly (dns record syntax).  Copy the file back to the DNS server and start the services and load the zone using that file.

Once you have validated that the zone came up properly, covert the zone to AD integrated (zone properties, general tab).

 

Visit my blog: anITKB.com, an IT Knowledge Base.


Friday, May 7, 2010 6:31 AM ✅Answered

Hi WilliamHuber,

From my knowledge, I believe that there hasn't a tool out there that we may use to import record from txt or CSV files. However, you can achieve your goal with the batch file with DNScmd utility indirectly.

1.Input the host file’s record to excel  , format the record to host and domain with the “text to columns” feature .
2.Input the domain zone (If you need to create a new zone for those DNS records) and hosts record to DNS server

dnscmd [<ServerName>] /zoneadd <ZoneName> <ZoneType>

dnscmd [<ServerName>] /recordadd <ZoneName> <NodeName> <RRType> <RRData>

For batch operation, I suggest you to write all command in one batch file and execute it.

Here are some articles about DNScmd utility for you reference

Dnscmd Overview

http://technet.microsoft.com/en-us/library/cc778513(WS.10).aspx

Dnscmd Syntax

http://technet.microsoft.com/en-us/library/cc756116(WS.10).aspx#BKMK_14

Thanks.

Tiger Li


Friday, May 7, 2010 7:42 AM ✅Answered

I can import from CSV using PowerShell, what format do you have?

For instance, it may be:

Import-CSV "YourFile.csv" | %{ New-DnsRecord -Name $_.Name -Zone domain.com -RecordType A -Address $_.IPAddress -Server YourDnsServer }

It will possibly need more work than that, but not much more. In the example above, Name and IPAddress are the column names from the CSV.

You would need these two:

http://support.microsoft.com/kb/968929

http://code.msdn.microsoft.com/dnsshell

 

Chris