Skip to content

Incorrect ipaddress.ip_address.reverse_pointer with improved textual representation of IPv4-mapped IPv6 addresses #123409

Closed

Description

@kellyjonbrazil

Bug report

Bug description:

I'm seeing strange results with python 3.13 with the ipaddress.ip_address.reverse_pointer attribute with the new improved textual representation of IPv4-mapped IPv6 addresses:

IP Address: ::FFFF:192.168.1.35

Results in a reverse_pointer of:

5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa

instead of the old:

3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa

Python 3.13:

>>> import ipaddress
>>> ip = '::FFFF:192.168.1.35'
>>> ipaddress.ip_address(ip).reverse_pointer
'5.3...1...8.6.1...2.9.1.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'

Python 3.12:

>>> import ipaddress
>>> ip = '::FFFF:192.168.1.35'
>>> ipaddress.ip_address(ip).reverse_pointer
'3.2.1.0.8.a.0.c.f.f.f.f.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'

I'm not sure which one is more valid or if a pointer record is even relevant in the context of mapped addresses. The original way seems more correct to me if nothing for the fact that there are strange extra dots in the new output.

This is related to:

Issue: #87799

PR: #29345

Originally posted by @kellyjonbrazil in #87799 (comment)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

@opavlyuk

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Aug 28, 2024
  2. picnixz commented on Aug 28, 2024

    @picnixz
    Member

    I think there is indeed an issue with the reverse pointer of IPv6. It does not match the RFC. I'll provide a patch.

  3. self-assigned this
    on Aug 28, 2024
  4. opavlyuk commented on Aug 28, 2024

    @opavlyuk
    Contributor

    @kellyjonbrazil Godd catch! Thank you for logging that, and I apologize for missing it during testing.
    @picnixz thank you for taking care of this!

  5. added a commit that references this issue on Sep 2, 2024
  6. added a commit that references this issue on Sep 2, 2024
  7. added a commit that references this issue on Sep 2, 2024
  8. encukou commented on Sep 5, 2024

    @encukou
    Member

    Thanks @kellyjonbrazil for the report and @picnixz for the patch!

  9. picnixz commented on Sep 5, 2024

    @picnixz
    Member

    You're welcome! (I hope that I didn't misread the RFC because it doesn't tell anything about mapped addresses; however I assumed that we first map IPv4 to IPv6 before taking its reverse pointer, which is what was being done in 3.12.5)

  10. added 4 commits that reference this issue on Jun 3, 2025
  11. added 4 commits that reference this issue on Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions