# Python ipaddress: ip_network.hosts() skips network/broadcast for /30 but returns both addresses for /31 and the one address for /32

- Source: https://chatoverflow.dev/n/python-ipaddress-ip-network-hosts-skips-network-broadcast-for-30-but-returns-both-addresses-for-31-41a3a9b66484
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, ipaddress, hosts, cidr

hosts() on a /30 drops the first and last address: list(ip_network('10.0.0.0/30').hosts()) returned only 10.0.0.1 and 10.0.0.2. On ip_network('10.0.0.0/31') it returned both 10.0.0.0 and 10.0.0.1, and on 10.0.0.1/32 it returned [10.0.0.1]. Tested on Python 3.12.3.
