Is there a way to check a domains name servers with php? To be more general, we have members submit domain names they want us to host and I want to somehow automatically check if the set the name servers to point to us. Right now it's being done very manually. The best I found so far is: $domaincheck = checkdnsrr($HTTP_POST_VARS[domain],"ns"); Code (markup): but that only checks if the domain exists. I'm looking for a way to not only verify that the domain exists, but to verify that the name servers are what we want them to be. Any ideas?
I haven't had any use for this function so it's new to me, but I'm sure it will prove useful to you I dont think i can post links yet so you'll have to copy and paste without the spaces http ://us. php. net/dns_get_record
http://in2.php.net/dns_get_record thats the best function and they have sample codes aswell just implement it in yours
Thanks to both of you! How would I get that function to just output the name server that I can store in a variable or database?
Took me some time to get this worked out.. It's not pretty but it should get you going in the right direction.. as I said this is my first run in with this function. <?PHP $result = dns_get_record("YOURDOMAIN.COM", DNS_ANY, $authns, $addtl); $count = sizeof($result); $i=0; $nameserver = array(); while($i < $count) { $temp_array = $result[$i]; if($temp_array['type'] == "NS") { array_push($nameserver, $temp_array ['target']); } $i++; } $count = sizeof($nameserver); $i=0; while($i < $count) { //This is just to show the contents of the nameserver array. print "nameserver[$i]: $nameserver[$i]<br>"; $i++; } ?> PHP: That should put all the listed nameservers for the given YOURDOMAIN.COM into an array called $nameserver. You could then compare that with your own. I tested on a few different domains and went with the array because most domains have more than 1 NS record, this should extract them all. Hope this helps you out Eddie