Friday, March 24, 2006
Calling nsupdate from PHP script
First, I should note that this is very situational but hopefully someone can make use of it. The environment at work is mostly Windows machines. There is a Windows DNS server as well which accepts dynamic updates for reverse lookups, among other things. This can be a pain when you are working on various Unix/Linux platforms. I wrote up a very quick web page that uses the nsupdate package (should be available for most platforms) to remove stale reverse lookup entries from the server. Released public domain, a comment here would be appreciated if it helped you at all.
<html>
<head>
<title>Jamie's DNS fixer thingy</title>
</head>
<body>
<P>This tool clears reverse lookup entries for a given IP. Stale reverse lookup
entries can cause problems with non-Windows systems. Entering an IP here submits
a dynamic update request to the DNS server for removal of the entry for that IP.</P>
<form method="POST">
<input name="IP" type="text" value="<?=(!empty($_POST['IP'])) ? $_POST['IP'] : ""?>">
<input name="Submit" type="submit"/>
</form>
<?php
$input = $_POST['IP'];
$valid = preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $input);
if (isset($_POST['Submit'])) {
if (!$valid) {
?>
<p><?=empty($input) ? "You must specify an IP address." : "$input is not a valid IP address."?></p>
<? } else { // Input validated by regexp
$iparr = split('\.', $input);
$iprev = $iparr[3].'.'.$iparr[2].'.'.$iparr[1].'.'.$iparr[0];
$dnscmd = <<<EOF
update delete {$iprev}.in-addr.arpa
send
exit
EOF;
$nsupdate = popen('/usr/bin/nsupdate', 'w');
fwrite($nsupdate, $dnscmd);
$retval = pclose($nsupdate); // nsupdate doesn't return anything useful when called this way
?>
<p>Submitted removal request for stored DNS record on <?=$input?>.
</p>
<?
} // if(!$valid)
} // if(isset($_POST['Submit']))
?>
</body></html>
Comments:
I Loved your article! It is really helpful for me. Keep doing...
Graphic Design Courses in Chennai
best graphic design courses in chennai
Linux Training in Chennai
Oracle DBA Training in Chennai
Tableau Training in Chennai
Pega Training in Chennai
Placement Training in Chennai
Soft Skills Training in Chennai
Quick up your career with Azure Training in Chennai from Infycle Technologies, the best software training institute in Chennai. A massive place to learn topmost technical courses like Medical Coding, Mobile App Development, Data Science, Big Data, BlockChain, Full Stack Development, Digital Marketing with Graphic Design, Python, and Oracle with emphasized trainers of the industry. Speak to us on 7504633633, 7502633633 to know the updated offers for your learning.
Post a Comment
<< Home
In recent days Angular plays vital role to loading your site content in a fastest way, so it’s a required skill for everyone, thanks for sharing this useful information to our vision keep blogging.
Regards,
Angularjs training in chennai
Regards,
Angularjs training in chennai
PHP Training in Chennai
Online PHP Training
Online PHP Training India
PHP Training Chennai
PHP Training institute in Chennai
Online PHP Training
Online PHP Training India
PHP Training Chennai
PHP Training institute in Chennai
Thanks for nice blog and article, very much informative.
Java Training in chennai|Dot Net Training in chennai
Java Training in chennai|Dot Net Training in chennai
Good resources.
Thanks Java Tutorials | Learn Java
Well organized and easy to understand programming tutorials with lots of examples of why,what and how to program in Java and OOPs
Thanks Java Tutorials | Learn Java
Well organized and easy to understand programming tutorials with lots of examples of why,what and how to program in Java and OOPs
If your test framework reads XML files to load a list of suites and test cases, it's defective. XML is not a human writable format. If you want to more details to contact us :
Web Designing Training in Coimbatore
Web Designing Training in Coimbatore
It is very useful for me to learn and understand easily.
PHP Training in Gurgaon
PHP Course in Gurgaon
PHP Training in Gurgaon
PHP Course in Gurgaon
I Loved your article! It is really helpful for me. Keep doing...
Graphic Design Courses in Chennai
best graphic design courses in chennai
Linux Training in Chennai
Oracle DBA Training in Chennai
Tableau Training in Chennai
Pega Training in Chennai
Placement Training in Chennai
Soft Skills Training in Chennai
Quick up your career with Azure Training in Chennai from Infycle Technologies, the best software training institute in Chennai. A massive place to learn topmost technical courses like Medical Coding, Mobile App Development, Data Science, Big Data, BlockChain, Full Stack Development, Digital Marketing with Graphic Design, Python, and Oracle with emphasized trainers of the industry. Speak to us on 7504633633, 7502633633 to know the updated offers for your learning.
<< Home