php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76966 checkdnsrr function return inconsistent results
Submitted: 2018-10-03 16:25 UTC Modified: 2018-11-18 22:39 UTC
From: stephane at dubishere dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 7.2.10 OS: Ubuntu 18.04
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
9 + 14 = ?
Subscribe to this entry?

 
 [2018-10-03 16:25 UTC] stephane at dubishere dot com
Description:
------------
---
From manual page: http://www.php.net/function.checkdnsrr
---

Root issue: I'm having networking problems when setting up the session handler to use Redis.

If I setup the session handler using an IP address pointing to my Redis host, it works fine. If I use a domain (DNS or my linux /etc/hosts file) it doesn't work, sessions are not saved in Redis.

So i've started looking into some networking related function to test this behaviour and see if I could find a DNS-related issue somewhere, and here I've encountered weird results for checkdnsrr() function.

Hopefully, fixing these would fix my Redis connection issue.

Test script:
---------------
/**
In AWS using route53, I've set 2 DNS records: 

- one A record        route53.myapp.com  >> 10.1.1.101   
- one CNAME record    route666.myapp.com  >> route53.myapp.com   

*/


// >> control the OS/hosts is seeing the DNS records: 
var_dump( gethostbyname('route53.myapp.com'));      >> 10.1.1.101 
var_dump( gethostbyname('route666.myapp.com'));     >> 10.1.1.101 




// My first test: 

var_dump( checkdnsrr('route53.myapp.com', 'A'));      >> true

var_dump( checkdnsrr('route53.myapp.com'));           >> false  !!! 

### If I have a A record, looking for ANY type of records should return true too.




// My second  test:
var_dump( checkdnsrr('route666.myapp.com'));          >> true
var_dump( checkdnsrr('route666.myapp.com', 'A'));     >> true  !!!
var_dump( checkdnsrr('route666.myapp.com', 'CNAME')); >> true

### If route666 is a CNAME, testing it's a A record should return false.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-05 00:30 UTC] pmmaga@php.net
-Status: Open +Status: Feedback
 [2018-10-05 00:30 UTC] pmmaga@php.net
About your first test, as mentioned in the manual, the default value for type is "MX" and not "ANY".

About the second test, although CNAME is not an A, typically an A record is part of the answer when you query the DNS for an A record of that domain. If you try `dig route666.myapp.com A` you can verify this.
 [2018-11-18 22:39 UTC] cmb@php.net
-Status: Feedback +Status: No Feedback
 [2018-11-18 22:39 UTC] cmb@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC