1
我有一個PHP腳本,它使用get_dns_record來檢索並顯示通過表單提交的域的特定DNS記錄。DNS_GET_RECORD MX查找失敗
它工作得很好,除了處理MX記錄的部分有點不可靠。有時候根本沒有顯示MX記錄(在我知道的域名上)。如果刷新2-3次,有時會顯示。有時他們不會。
想法?
function getDNSRecord($domain1) {
$dns = dns_get_record($domain1, DNS_ANY);
echo "These are DNS records";
foreach($dns as $d) {
// Only print A and MX records
if($d['type'] != "A" and $d['type'] != "MX")
continue;
// Print type specific fields
switch($d['type']) {
case 'A':
// Display annoying message
echo "<b>\n" . $d['ip'] . "</b>\n is the Primary A Record for this domain.";
break;
case 'MX':
// Resolve IP address of the mail server
$mx = dns_get_record($d['target'], DNS_A);
foreach($mx as $server) {
echo "This MX record for " . $d['host'] . " points to the server <b>\n" . $d['target'] . "</b>\n whose IP address is <b>\n" . $server['ip'] . "</b>. It has a priority of <b>\n" . $d['pri'] . "</b>\n.";
}
if ($d['target'] == $domain1) {
echo "<div id='mx-status'>There is an issue with this MX Record</div>\n";
} else {
echo "<div id='mx-status'>This MX Record looks fine.</div>\n";
}
break;
}
}
}
是的,但我不知道如何實現它,使用相同的設置。我不僅需要找到MX記錄,還需要顯示它所指向的位置以及目標的IP地址。 – Batfan 2010-08-04 19:58:29