简体   繁体   中英

gethostbynamel() and dns_get_record() returns empty for some domains

I am using a compute instance VM of Google Cloud, have installed Debian 10 and PHP 7.3.

Then tried to run this:

php -r "print_r(gethostbynamel('2.0.0.127.zen.spamhaus.org.'));"

Surprisingly it returns an empty string.

However, on any other non-Google Cloud VM it works perfectly:

Array ( [0] => 127.0.0.4 [1] => 127.0.0.10 [2] => 127.0.0.2 ) 

Even stranger, with gethostbyname() it works perfectly:

php -r "print_r(gethostbyname('2.0.0.127.zen.spamhaus.org.'));"

But obviously I get only one result and not all.

I tried also this command:

php -r "print_r(dns_get_record('2.0.0.127.zen.spamhaus.org.', DNS_A));"

But it returns an empty array.

So gethostbynamel() and dns_get_record() seem to show empty fields.

While gethostbyname() works perfectly.

I opened port 53 TCP for outbound traffic on Google Firewall.

Does anyone know why this behavior is happening?

If you have suggestions please share them.

This is a known and expected behaviour which has been called out in spamhaus site as well.

It is applicable to the internal DNS resolver for your VM as well. Google DNS will return a "not listed" (NXDOMAIN) reply from 'Spamhaus' public DNSBL servers because there is a DNSBlock enabled for Google DNS services.

I recommend you to use your own DNS servers when doing DNSBL queries to Spamhaus. If that is not possible, contact Spamhaus Technology for other options.

For further more information on DNSBL, refer the link

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM