Skip to content

Instantly share code, notes, and snippets.

@agusmu
Created February 9, 2022 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agusmu/7ef4f7555525a68c6947a82625aed685 to your computer and use it in GitHub Desktop.
Save agusmu/7ef4f7555525a68c6947a82625aed685 to your computer and use it in GitHub Desktop.
How to fix dns_get_record php function in RunCloud

How to fix dns_get_record php function in RunCloud

When using dns_get_record with DNS_ANY or DNS_ALL, it does not work with this warning message.

php -r "var_dump(dns_get_record('google.com', DNS_ANY));"
PHP Warning:  dns_get_record(): A temporary server error occurred. in Command line code on line 1
bool(false)

Using DNS_ANY on dns_get_record is not recommended on production server.

This is because using DNS_ANY is considered to be a DNS Amplification Attack.

Some references:

https://www.cisa.gov/uscert/ncas/alerts/TA13-088A

https://blog.cloudflare.com/deprecating-dns-any-meta-query-type/

https://datatracker.ietf.org/doc/html/rfc8482

https://fanf.livejournal.com/140566.html

We recommend you to modify your code a little bit, instead of using this code,

dns_get_record('google.com', DNS_ANY)

You can use this for example

dns_get_record('google.com', DNS_A + DNS_AAAA + DNS_CNAME + DNS_NS + DNS_TXT + DNS_MX )

Now, it should works in your server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment