This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mjpieters
Recipients CosmicKid, cdirkx, mjpieters
Date 2021-05-18.11:30:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621337422.5.0.500456048968.issue42937@roundup.psfhosted.org>
In-reply-to
Content
> Private is a subset of special use.  Should a "_special_use" constant be created.  This would include multicast, link_local, private_use, and a few more.

There are already dedicated tests for those other special use networks in ipaddress. 192.0.0.0/24 is the block reserved for "IETF Protocol Assignments", which really means: private use. https://datatracker.ietf.org/doc/html/rfc6890#section-2.2.2 marks the block as "Not usable unless by virtue of a more specific reservation.".

The registry at https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml lists those specific reservations, and only 2 to date are *globally reachable*, which means they are probably not private:

- 192.0.0.9/32, Port Control Protocol Anycast, RFC 7723
- 192.0.0.10/32, Traversal Using Relays around NAT Anycast, RFC 8155

I strongly feel that _any other IP address in the reserved range_ should be treated as private unless marked, by IANA, as globally reachable, at some future date.

That would require the list of networks for IPv4Address / IPv4Network is_private to include all of 192.0.0.0/24 _minus those two exceptions_; calculating the network masks for these:

>>> def exclude_all(network, *excluded):
...     try:
...         for sub in network.address_exclude(excluded[0]):
...             yield from exclude_all(sub, *excluded[1:])
...     except (IndexError, ValueError):
...         yield network
...
>>> iana_reserved = IPv4Network("192.0.0.0/24")
>>> to_remove = IPv4Network("192.0.0.9/32"), IPv4Network("192.0.0.10/32")

>>> for sub in exclude_all(iana_reserved, *to_remove):
...     print(sub)
...
192.0.0.128/25
192.0.0.64/26
192.0.0.32/27
192.0.0.16/28
192.0.0.0/29
192.0.0.12/30
192.0.0.11/32
192.0.0.8/32

The module could trivially do this on import, or we could hard-code the above list.
History
Date User Action Args
2021-05-18 11:30:22mjpieterssetrecipients: + mjpieters, cdirkx, CosmicKid
2021-05-18 11:30:22mjpieterssetmessageid: <1621337422.5.0.500456048968.issue42937@roundup.psfhosted.org>
2021-05-18 11:30:22mjpieterslinkissue42937 messages
2021-05-18 11:30:21mjpieterscreate