Solved

Create/delete DNS records from php

Posted on 2011-03-14
6
360 Views
Last Modified: 2012-05-11
Hi,
We already have in place a solution for quering DNS reocrds and creating/deleting DNS records.
It was developed earlier last year when I was a trainee :)
I think we make it a little better at this time.
Here are the few important questions that I would like to ask you exparts in this regards,
1. Can we query the whole windows DNS from php directly?
2. Can we create/delete DNS records from php directly?
I know that we can do NS lookup from single IP/host but not sure about whole DNS
Also I remeber that when I was developing it, we could create DNS records from php but I think there some internal security procedures that I couldnt get that to work.
Just hoping that dsome one owuld bge able to help me out with it i.e questions 1 and 2.
Thanks for ur help.
0
Comment
Question by:SameerMirza
  • 3
  • 3
6 Comments
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35129559
You would need to tell us a lot more about the DNS records in question, but....

1. If the DNS records are 'local' ie hosted on your server then you can update them by writing the relevant config files in the approriate folder, but you say it is a windows machine and I've never seen a Windows machine being used as a DNS server

2. If the server is remote but you have access to it then you can create a passwordless login key to allow the use of rsync to read/write the DNS conf files, but you will need to have a way to issue the BIND server a "reload" instruction of else the changed will not take effect

3. If the server is remote and you have no access to then you will need to use an API to access it. Many hosting companies release their own API and sometimes their own scripts for doing the update.

Finally, you say "I think we make it a little better at this time." My reaction is to say "if it works ok then don't fiddle with it". Improving code is often a route to hardship and working code is better in many respects than 'perfect' code that causes a lot of work for little payback.
0
 

Author Comment

by:SameerMirza
ID: 35129686
ok. But the existing process drop a file which is then picked up by a batch script that uses dnscmd to create/delete entries.
I can provide further detail if you think its worth improving it.? But yes it works perfactly fine. Specially if we can create it directly from php.
Yes, we can access the remote dns server and I am pretty sure its windows based.
Just one question. I have changed the confirmation to be based on ns lookup for which I am using gethostbyaddr()
this function return the hostname if the entry exists. And returns the IP itself if it doesnt
So I keep the check based on this function.
If it return the host on creation -> I assume entry has been created
and if it reuturns the IP itself I accume that the entry has not been created.
Just wanted to confirm if there a ny better lookup procedure or this is ok?
I fire it straight on the DC that we create record on so its almost instant.
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35129842
By the sound of what you are describing, you are creating a text file which PHP can easily generate for you via fopen() or file_put_contents()  

http://www.php.net/fopen
http://www.php.net/file_put_contents

"I have changed the confirmation to be based on ns lookup for which I am using gethostbyaddr()"

As far as I recall gethostbyaddr() will use whatever nameserver the system it is running on uses. As long as you are sure that the nameserver service you use provides an accurate reflection of the server in question then you should be OK.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:SameerMirza
ID: 35130024
bportlock,
Thanks for your help. I ment to say that we already have the functionality in place based on text files generated by php and the batch script to process them. - CURRENT FUNCTINALITY
Yes, I am aware of the nameserver the system is using and we are creating the records on the same server.
So thanks for confirming that.
The actualy question is that do you think we should try and improve it or not?
I think I already know your answer on it but may be it would be good to know. :)

thanks again
0
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 35130099
"The actualy question is that do you think we should try and improve it or not?"

No. Not unless you need to add a feature that is needed and is completely missing or if you have a broken feature that does not work

Try Googling "If it ain't broke don't fix it"  http://lmgtfy.com/?q=If+it+ain%27t+broke+don%27t+fix+it
0
 

Author Closing Comment

by:SameerMirza
ID: 35130255
:) I am sure it would be helpful for many
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Learn about cloud computing and its benefits for small business owners.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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