Sunday, January 1, 2012

Get DNS Record through PHP

1 comment
View your domains's dns record using this short and simple php script


<?php

$domain='facebook.com'; // domain name to check, you can also implement query ex: $_GET['domain']

ini_set('display_errors',0); // hide error from browser (if error occur)

$x=dns_get_record($domain); // i used the "dns_get_record" function of php

foreach($x as $y) // iterate array elements
{
if(is_array($y)) // check if $y is array
{
foreach($y as $k) // iterate array elements in $y (multidimensional)
{
echo $k."<br>"; // output the result
}
}
}
?>

OUTPUT: domain = facebook.com

facebook.com
NS
ns1.facebook.com
IN
19262
facebook.com
NS
ns2.facebook.com
IN
19262
facebook.com
NS
ns3.facebook.com
IN
19262
facebook.com
NS
ns4.facebook.com
IN
19262
facebook.com
NS
ns5.facebook.com
IN
19262

***********************************************************
dns_get_record has 4 parameters, the first parameter is required
if you want to return the A record only put the second parameter next to "hostname"
ex:

$x=dns_get_record($domain,DNS_A);

OUTPUT: domain = facebook.com

facebook.com
A
69.63.189.11
IN
3600
facebook.com
A
69.63.189.16
IN
3600
facebook.com
A
69.63.181.11
IN
3600
facebook.com
A
69.63.181.12
IN
3600

see this link for the completed "dns_get_record" documentation

1 comment:

  1. I am hosting my website Free on QuotesFox.com
    Its providing
    10 GB space
    100 GB monthly bandwidth
    Free Sub Domain
    Unmetered MySQL space
    PHP + MySQL
    Cpanel full featured
    PhpMyAdmin
    Firewall Protection
    UPS Power Back-up/Back-up
    Hotlink Protection
    Forum support [ http://quotesfox.com/forums ]
    and most importantly no ads
    My website is working like a charm with a lot of monthly traffic.
    This is worth taking look.
    QuotesFox.com

    ReplyDelete