Solved

Create/delete DNS records from php

Posted on 2011-03-14
6
361 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've written instructions for one router type, but this principle may be useful for others of the same brand and even other brands of router. Problem: I had an issue especially with mobile devices that refused to use DNS information supplied via…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

733 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