1

I'm trying to setup a script using ipaddress module in python 3.x. I'm looking for making a parser looking for some info on public IP.

When checking the IP, I'm finding that ipaddress is not tagging as reserved the IP range 192.0.0.0/24.

From IETF docs :

192.0.0.0/24 192.0.0.0–192.0.0.255 Private network IETF Protocol Assignments.

From ipaddress docs :

is_reserved: True if the address is otherwise IETF reserved.

The code :

import ipaddress
print(ipaddress.ip_address("192.0.0.12").is_reserved)

Output :

False

Is there something I'm doing wrong ?

Felkor
  • 11
  • 1
  • The [`_private_networks`](https://github.com/python/cpython/blob/3.7/Lib/ipaddress.py#L1568-L1583) attribute in the [`_IPv4Constants`](https://github.com/python/cpython/blob/3.7/Lib/ipaddress.py#L1559) class suggests, that this IP is rather considered private than *otherwise reserved*. [`is_private`](https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Address.is_private) should return `True` here. The only network that `is_reserved` seems to be `240.0.0.0/4`. – shmee Apr 25 '19 at 11:04

0 Answers0