Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create/delete DNS records from php

Posted on 2011-03-14
6
Medium Priority
?
364 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
New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

 

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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

972 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