How to fetches DNS records associated with a hostname in PHP

1 Answer

0 votes
$dns_r = dns_get_record("google.com");
echo "<pre>";
print_r($dns_r);
echo "</pre>";

/*
run:

Array
(
    [0] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 60
            [type] => SOA
            [mname] => ns4.google.com
            [rname] => dns-admin.google.com
            [serial] => 134949397
            [refresh] => 900
            [retry] => 900
            [expire] => 1800
            [minimum-ttl] => 60
        )

    [1] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 3600
            [type] => TXT
            [txt] => v=spf1 include:_spf.google.com ~all
            [entries] => Array
                (
                    [0] => v=spf1 include:_spf.google.com ~all
                )

        )

    [2] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 600
            [type] => MX
            [pri] => 50
            [target] => alt4.aspmx.l.google.com
        )

    [3] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 600
            [type] => MX
            [pri] => 30
            [target] => alt2.aspmx.l.google.com
        )

    [4] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 600
            [type] => MX
            [pri] => 40
            [target] => alt3.aspmx.l.google.com
        )

    [5] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 600
            [type] => MX
            [pri] => 10
            [target] => aspmx.l.google.com
        )

    [6] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 600
            [type] => MX
            [pri] => 20
            [target] => alt1.aspmx.l.google.com
        )

    [7] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 99
            [type] => A
            [ip] => 172.217.22.78
        )

    [8] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 255
            [type] => AAAA
            [ipv6] => 2a00:1450:4001:81c::200e
        )

    [9] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 144490
            [type] => NS
            [target] => ns4.google.com
        )

    [10] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 144490
            [type] => NS
            [target] => ns2.google.com
        )

    [11] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 144490
            [type] => NS
            [target] => ns1.google.com
        )

    [12] => Array
        (
            [host] => google.com
            [class] => IN
            [ttl] => 144490
            [type] => NS
            [target] => ns3.google.com
        )
)



*/

 



answered Oct 3, 2016 by avibootz

Related questions

1 answer 165 views
165 views asked Oct 8, 2016 by avibootz
1 answer 309 views
1 answer 189 views
1 answer 175 views
2 answers 216 views
...