Solved

Create/delete DNS records from php

Posted on 2011-03-14
6
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…
This article discusses how to create an extensible mechanism for linked drop downs.
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

695 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