-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
192.0.0.8 (IPv4 dummy address) considered globally reachable #87103
Comments
Currently the method The correct behaviour now, according to the documentation of |
This a simple matter of adding the address to the _private_networks constant. I will add it and issue a pull request today/tomorrow. I could add some of the others too for completeness. However, these are really special use versus private. 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 many others included in https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml. |
This is related to bpo-42937, the IPv4 private network list is not considering the whole of 192.0.0.0/24 to be private. RFC 5736 / 6890 reserved 192.0.0.0/24 for special purposes (private networks) and to date a few subnets of that network have received assignments. The ipaddress modules should use that subnet for any E.g. the list currently contains just 192.0.0.0/29 and 192.0.0.170/31, but as this bug report points out, 192.0.0.8/32 has since been added, as have 192.0.0.9/32 and 192.0.0.10/32. The IPv6 implementation *does* cover the whole reserved subnet (although it also includes 2 specific registrations, see the aforementioned bpo-42937), it is just IPv4 that is inconsistent and incomplete here. |
Oops, I got my issue numbers mixed up. This is related to bpo-44167, I meant. |
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:
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. |
I completely agree with comments about .is_global and special_use. Private IPs are just a subset of special use. For some part Private means the Private use networks reserved by IANA and specified in IETF RFC1918. For this PR "IPv4 dummy address" is for sure not global. Technically, it is not a private use IP either. Just following what others have done. I really like the apporoach of removing the routable special IPs. Let me know if I should create a PR to do this. This would include adding specific special use constant plus a whole bunch of very specific constants. A constant like is_dummy will be added. I pretty much have the code ready to go for IPV4. |
I'm really surprised by the decisions, made within this issue and during the development, when it comes to the "grouping" of the different address spaces. Even if the arguments are correct on an academic low level, they are not correct when it comes to the practical use of those address spaces. Private should never be considered to be outside of RFC1918. The IANA flagged those address spaces as "Private-Use". As a result, I'm coming from a troubleshooting, where code looked like that:
Imagine my confusion, when it turned out to leave By the checking the code Lines 1551 to 1566 in f1f85a4
is_private is the last statement, but in general it makes sense to change this (for the most people) unintended behavior. I support the thought of @wjohnston99 in #87103 (comment) to have a separate constant _special_use , along with a separate method is_special , to summarize all those address spaces, that are mostly not in use at all, like those dummy addresses.
|
@tsvsj Having gone through this code recently I agree with you. There's a ticket about documenting things so the confusion is avoided somewhat: #65056 In that ticket there's a comment #65056 (comment) that suggests the following course of action
But either way I think it's out of the scope of this issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: