Link to home
Start Free TrialLog in
Avatar of sunray_2003
sunray_2003Flag for United States of America

asked on

smarter way of adding host records

Hello all,

I need to add a lot of host A records in one of my domains in my forward lookup zone. lets say as an example , I need to add A records from ip address 200.100.50.0 to 200.100.50.255 . (Example IP )

I heard that I can use GENERATE command ( assuming I have the latest BIND version). How do I find the latest BIND version and can I download , if I donot have the latest .

Please guide

SR
Avatar of NJComputerNetworks
NJComputerNetworks
Flag of United States of America image

Are you using Windows 2003 DNS?  If so, you have the latest version of BIND...
Avatar of sunray_2003

ASKER

I have windows 2003 server standard version.. Can I download BIND and get that Generate command going ?
you have the latest version
>> you have the latest version

not sure what you meant by above..  Are you saying that I already have the latest BIND version ?
try DNSCMD.exe to add these records from a command prompt:  http://www.jsiinc.com/subh/tip3900/rh3905.htm

ASKER CERTIFIED SOLUTION
Avatar of NJComputerNetworks
NJComputerNetworks
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Pete Long
Pete Long
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using Windows 2003 DNS and the IP addresses you mention belong to Windows clients, then they should register on their own.

If these are static hosts, then DNSCMD is one choice that will allow you to script it - however, you will need a source file for the input.  Either way, there will be some manual intervention at some point unless you already have a list of addresses and hostnames handy.

There may be other choices depending upon whether you are trying to pull records out of BIND to add to 2003 DNS - let us know.

Netman,

These are static hosts and all I need to do is to add host A records for each of these IP addresses. The domain name has been created in the forward lookup zone and individually , I can add HOST A records with the hostname and IP information. But I need to do for more than 200 ips ..  So easy way would be scripting (obviously)..

lets say I have ips from 200.100.50.10 to 200.100.50.255 (example IPs )

My host A records for each of them would be

ip-200-100-50-10       host(A)       200.100.50.10
ip-200-100-50-11       host(A)       200.100.50.11   ........
|
|
|
|
ip-200-100-50-255     host(A)       200.100.50.255

How would I accomplish this ?

SR
The command syntax for DNSCMD is this:

Dnscmd {DNS FQDN} /RecordAdd {Zone name} {computername} A {IP address}

So in your case, we would script something that loops.

Here is what the command would look like - I'll need a minute to create the entire script:

DNSCMD mydns.mydomain.local /RecordAdd mydomain.local %comp% A %IP%

where %comp% is the computername and %IP% is the IP address for this host.

I'll be back shortly with something.
Or you might be able to do this with Excel:

Copy all of the information into Excel....then copy the excel sheet into notepad and save the file as test.bat.  Then try to run test.bat from a command line.  

DNSCMD mydns.mydomain.local /RecordAdd mydomain.local computer1 A 200.100.50.10
DNSCMD mydns.mydomain.local /RecordAdd mydomain.local computer1 A 200.100.50.11
DNSCMD mydns.mydomain.local /RecordAdd mydomain.local computer1 A 200.100.50.12
DNSCMD mydns.mydomain.local /RecordAdd mydomain.local computer1 A 200.100.50.13
DNSCMD mydns.mydomain.local /RecordAdd mydomain.local computer1 A 200.100.50.14
...etc
Just give more information here..  After I created a domain name called "test.com" in my forward zone , I have a dns file called  "test.com.dns" in the directory c:\windows\system32\dns..

The file presently has

**************************************
;
;  Database file test.com.dns for test.com zone.
;      Zone version:  4
;

@                       IN  SOA comp.  hostmaster. (
                              4            ; serial number
                              900          ; refresh
                              600          ; retry
                              86400        ; expire
                              3600       ) ; default TTL

;
;  Zone NS records
;

@                       NS      comp.

;
;  Zone records
;

ip-200-100-50-1       A      200.100.50.1

********************************** where "comp" is the computer name (or rather the windows 2003 server name) **************************

SR
Here is a script.

***** begin ******

Set computerName = "ip-200-100-50-"
Set ipAddress = "200.100.50."

Set shellCommand = "DNSCMD mydns.domain.com /RecordAdd domain.com " 
Set shellCommandSeperator = " A "
set runCommand = shellCommand

Set objShell = CreateObject("WScript.Shell")

For i = 10 TO 254
  computerName = computerName & i
  ipAddress = ipAddress & i  

  runCommand = shellCommand & computerName & shellCommandSeperator & ipAddress
 
  Set objScriptExec = objShell.Exec(runCommand)

Next

***** end *****

Copy what's between the Begin and End into a new file with a .vbs extension.  Change the 10 to 254 to whatever you like.  Also change "mydns.domain.com" to the FQDN of the DNS server and "domain.com" to the name of the Forward Zone you are populating.

Let me know.
Netman,

Since all my Host A records are inside the file , test.com.dns , shudnt the value for /RecordAdd be "test.com.dns"..

moreover , I have got several domains in my forward lookup zone.. where do I find the FQDN for the server. Not sure what I need to give for  mydns.domain.com at DNSCMD mydns.domain.com
No.  What is the name of the actual zone in the DNS console?  That's the value for the file for test.com.

The DNS server FQDN is found several ways.  Easiest way is to right-click My Computer then select Properties, then select Network Identification tab.  The Full computername is the FQDN you want to use in the batch parameter.

I need assistance in adding many host A records ..

Sorry could not get back to you on this earlier than I thought..

OK , here is the deal..


When I open my test.com dns file , I see this

************************************************
;
;  Database file test.com.dns for test.com zone.
;      Zone version:  77
;

@                       IN  SOA machine.test.com.  hostmaster. (
                              77           ; serial number
                              900          ; refresh
                              600          ; retry
                              86400        ; expire
                              3600       ) ; default TTL

;
;  Zone NS records
;

@                       NS      machine.test.com.

;
;  Zone records
;

@                       MX      10      mail.test.com.
ip-200-100-50-1         A      200.100.50.1 <=== dummy IPs
ip-200-100-50-2         A      200.100.50.2

************************************************

I need to add from

ip-200-100-50-3        A             200.100.50.3
|
|
|
ip-200-100-50-254        A             200.100.50.254

Could you edit the vbs script for me so that I can do this using this script instead of adding it one by one..

Thanks
SR
I am trying to get DNSCMD command work from the command prompt to add host A records to test.com forward zone
Avatar of oBdA
oBdA

(got called here from http:Q_21412848.html)
Hi sunray_2003,
looks like Netman66's script should do the trick; in Windows, you shouldn't edit the DNS file directly.
The one thing worth adding might be that you'll find the dnscmd.exe in the Support Tools on the installation CD, it's not installed by default.
I'll be off for a few days, I'll have a look if you've got it solved by then.
Good luck.
I have already got the dnscmd.exe file to c:\windows\system32\dns.

I created a test forward zone called as "test.com" and the contents of test.com.dns is what I had posted above..
Not sure what needs to be given for DNSCMD.. I am just trying to add ONE A host record to test.com ...

DNSCMD   machine.test.com \RecordAdd  test.com   www   A 10.10.10.10  
Basically , i am trying to add one A host record "www" with the IP "10.10.10.10"..  The above command doesnot seem to work... Looks like i am not giving the servername correctly.
The syntax is not correct:

DNSCMD   machine.test.com \RecordAdd  test.com   www   A 10.10.10.10

should read:

DNSCMD   machine.test.com /RecordAdd  test.com   www   A 10.10.10.10
Netman,

Sorry I mistyped wrongly.. i was using / instead of \.

https://www.experts-exchange.com/questions/21351448/smarter-way-of-adding-host-records.html

I get this error

Command failed:  UNKNOWN        1753 (000006d9)

SR
Do you have a path to the DNSCMD file?  Placing it in System32\DNS means it isn't normally picked up as a valid command unless it's caught in a path statement somewhere.

I will go over to that link now.

NM
That's this question!  

Let me see what I can run here and come up with.

Hold tight.
I kind of doing few mistyping this evening.. may be tired after returning from work.. I didnot really want to post that link.  

i just downloaded this dnscmd.exe file from the internet and placed in c:\windows\system32\dns
Ok, this worked for me and it added the www Host record just fine.

DNSCMD servername /RecordAdd forwardlookupzone www A 10.10.10.10

Replace servername with the DNS servername (either NetBIOS or IP address)
Replace forwardlookupzone with the exact forward zone name you want to populate.

I placed the line in a CMD file called addrecord.cmd on the root of C:, then opened a CMD window and ran it from there.

Place a PAUSE command at the end so it stays open for you to read any error messages.

Single spaces between all the elements in the line.

Let me know.
I should add that if this is Server 2003 with SP1, then uninstall any Support Tools that you have now and download and install this:

http://www.microsoft.com/downloads/details.aspx?FamilyID=6ec50b78-8be1-4e81-b3be-4e7ac4f0912d&DisplayLang=en

No need to copy the tools anywhere after this installs - just run the command.
OK . I did this

I created  a file called "addrecord.cmd" in C root , and it has this

DNSCMD 10.1.1.50 /RecordAdd test.com www A 10.10.10.10
PAUSE

Since my server IP is an private IP, I gave it as 10.1.1.50

When I double-click the CMD file , it gives this

****************
C:\>DNSCMD 10.1.1.50 /RecordAdd test.com www A 10.10.10.10
'DNSCMD' is not recognized as an internal or external command,
operable program or batch file.

C:\>PAUSE
Press any key to continue . . .
****************

So I put "addrecord.cmd" file in c:\windows\system32\dns ( this is the exact location were dnscmd.exe file is ) and I get this

******************************
C:\WINDOWS\system32\dns>DNSCMD 10.1.1.50 /RecordAdd test.com www A 10.10.10.10

Command failed:  UNKNOWN        1753 (000006d9)

C:\WINDOWS\system32\dns>PAUSE
Press any key to continue . . .
******************************
This machine is a  windows 2003 server standard edition with NO Sp1
I am off to bed .. just late and tired. Will check back tommorrow.
Ok, on server 10.1.1.50 can you open up the DNS console and expand the forward lookup zone?  Does test.com exist?  If not, this is your problem.

The Zone referred to in the command must exists exactly as you typed it on the server you are running the command against.

The reason for the first error is simply the path.  Move DNSCMD to System32 directly - that should take care of one problem.

Have a good sleep - will look for this in the AM.

NM
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Any takers for this
https://www.experts-exchange.com/questions/21435312/Multiple-FTP-single-IP-windows-2003.html

NM,
Since I had to add the A hosts very urgently , I manually added those .. I know that is not quite smart.. Hence I will take a look at your suggestions and see what could be the problem.