Skip to content

resolve: fix CNAME chain resolution with caching #3709#3733

Merged
bogdan-iancu merged 1 commit intoOpenSIPS:masterfrom
hafkensite:feature/dns-cache-cname
Jan 27, 2026
Merged

resolve: fix CNAME chain resolution with caching #3709#3733
bogdan-iancu merged 1 commit intoOpenSIPS:masterfrom
hafkensite:feature/dns-cache-cname

Conversation

@hafkensite
Copy link
Contributor

Summary
The DNS resolver now explicitly follows CNAME chains instead of relying on res_search() to handle them transparently. This fixes resolution failures when the DNS cache module is enabled, as cached CNAME responses need to be followed manually to reach the final A/AAAA records.

Details
Fixes issue #3709, recursive CNAME doesn't work when dns_cache module is used.

Solution

Changes:

  • Add iterative CNAME chain following in own_gethostbyname2()
  • Limit chain depth to 10 to prevent infinite loops
  • Add debug logging for CNAME traversal

Compatibility
Nope.

Closing issues

closes #3709

The DNS resolver now explicitly follows CNAME chains instead of relying
on res_search() to handle them transparently. This fixes resolution
failures when the DNS cache module is enabled, as cached CNAME responses
need to be followed manually to reach the final A/AAAA records.

Changes:
- Add iterative CNAME chain following in own_gethostbyname2()
- Limit chain depth to 10 to prevent infinite loops
- Add debug logging for CNAME traversal
@bogdan-iancu bogdan-iancu self-assigned this Oct 21, 2025
@bogdan-iancu
Copy link
Member

Thank you @hafkensite , it took me a bit to understand the details of the issue and of the fix (the dns_cacher is not guilty at all, just its usage triggers a different way of doing DNS queries in the core).
But all look good, the patch is clean, great catch and work - Thanks again!!

@bogdan-iancu bogdan-iancu merged commit 401957b into OpenSIPS:master Jan 27, 2026
84 of 86 checks passed
bogdan-iancu added a commit that referenced this pull request Jan 27, 2026
resolve: fix CNAME chain resolution with caching #3709
(cherry picked from commit 401957b)
bogdan-iancu added a commit that referenced this pull request Jan 27, 2026
resolve: fix CNAME chain resolution with caching #3709
(cherry picked from commit 401957b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CName resolution breaks when using dns_cache

2 participants