|
dns_get_record
Fetch DNS Resource Records associated with a hostname
(PHP 5)
Example 1591. Using dns_get_record()<?php The above example will output something similar to: Array Example 1592. Using dns_get_record() and DNS_ANYSince it's very common to want the IP address of a mail server once the MX record has been resolved, dns_get_record() also returns an array in addtl which contains associate records. authns is returned as well containing a list of authoritative name servers. <?php The above example will output something similar to: Result = Array Code Examples / Notes » dns_get_recordmarcus
The docs say "nor does it (currently) work on *BSD systems". Unfortunately this includes MacOS X. It's just not there in my build of 5.1.2 running on 10.4.4.
axelm-php
I've done a backport of the function to PHP4. It is available as extension at: http://nona.net/software/dns_get_record/ comments & feedback appreciated. -- Alexander Mayrhofer axelm-php@nona.net ed
I recently needed to do some name server and IP discovery on the fly. Server and domain monitoring system. If you've got a system with dig the below seems to work fine for discovering name server and a addresses. Shouldn't be hard for you to modify it for the other records if needed. $_REQUEST[url] = "http://www.example.com/"; $url_parts = parse_url($_REQUEST[url]); $dns = Dig($url_parts[host]); print_r($dns[name_servers]); print_r($dns[ips]); function Dig ($domain) { $dig = `dig $domain`; preg_match_all("/in\s+ns\s+(.+?)\s+/is" ,$dig,$name_servers,PREG_PATTERN_ORDER); preg_match_all("/$domain.\s+[0-9]+\s+in\s+a\s+([0-9.]+)\s+/is" ,$dig,$ips,PREG_PATTERN_ORDER); $dns[name_servers] = $name_servers[1]; $dns[ips] = $ips[1]; return($dns); } |
Change Languagecheckdnsrr closelog debugger_off debugger_on define_syslog_variables dns_check_record dns_get_mx dns_get_record fsockopen gethostbyaddr gethostbyname gethostbynamel getmxrr getprotobyname getprotobynumber getservbyname getservbyport header headers_list headers_sent inet_ntop inet_pton ip2long long2ip openlog pfsockopen setcookie setrawcookie socket_get_status socket_set_blocking socket_set_timeout syslog |