https://i.imgur.com/IQtyy2e.png
My goal is to find current nameservers behind any HTTP Host like this.
<?php
$resolver = array( '1.1.1.1' );
$domain = 'community.cloudflare.com.';
$report = dns_get_record( $domain, DNS_SOA, $resolver );
print_r( $report );
?>
Prints
Array
(
)
While it works for google.co.uk
Any idea how can I use PHP native function to get SOA report?
If this doesn't work then I have last option using 1.1.1.1 API which I dont want without trying first PHP way.
In that case, the subdomain community.cloudflare.com(.)
is part of the zone cloudflare.com.
Since community.cloudflare.com(.)
is not a zone (even if it could be), there are no SOA or NS records for it.
What you need to do is to get the SOA record or NS records from the less specific zone, which is cloudflare.com.
in that case:
Code
$domain = 'cloudflare.com.';
$report = \dns_get_record($domain, \DNS_NS);
\print_r($report);
Response
Array
(
[0] => Array
(
[host] => cloudflare.com
[class] => IN
[ttl] => 21052
[type] => NS
[target] => ns3.cloudflare.com
)
[1] => Array
(
[host] => cloudflare.com
[class] => IN
[ttl] => 21052
[type] => NS
[target] => ns4.cloudflare.com
)
[2] => Array
(
[host] => cloudflare.com
[class] => IN
[ttl] => 21052
[type] => NS
[target] => ns5.cloudflare.com
)
[3] => Array
(
[host] => cloudflare.com
[class] => IN
[ttl] => 21052
[type] => NS
[target] => ns6.cloudflare.com
)
[4] => Array
(
[host] => cloudflare.com
[class] => IN
[ttl] => 21052
[type] => NS
[target] => ns7.cloudflare.com
)
)
A close to what I was looking for
$host = 'community.cloudflare.com';
$api = "https://cloudflare-dns.com/dns-query?name=$host&type=NS";
$response = wp_remote_get( $api, array(
'timeout' => 3,
'redirection' => 0,
'headers' => array( "Accept" => "application/dns-json" ),
));
$response = wp_remote_retrieve_body( $response );
$response = json_decode( $response, true );
echo '<pre>';
print_r( $response );
echo '</pre>';
Output
Array
(
[Status] => 0
[TC] =>
[RD] => 1
[RA] => 1
[AD] => 1
[CD] =>
[Question] => Array
(
[0] => Array
(
[name] => community.cloudflare.com
[type] => 2
)
)
[Authority] => Array
(
[0] => Array
(
[name] => cloudflare.com
[type] => 6
[TTL] => 93
[data] => ns3.cloudflare.com. dns.cloudflare.com. 2036594323 10000 2400 604800 300
)
)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.