netaddr

Python library for working with network addresses and subnets

brewmacoslinux
Try with needOr install directly
Source

About

Network address manipulation library

Commands

netaddr

Examples

Check if an IP address is in a specific subnet$ python -c "from netaddr import IPNetwork, IPAddress; print(IPAddress('192.168.1.5') in IPNetwork('192.168.1.0/24'))"
List all IP addresses in a subnet$ python -c "from netaddr import IPNetwork; [print(ip) for ip in IPNetwork('192.168.1.0/30')]"
Parse and display information about an IP network$ python -c "from netaddr import IPNetwork; net = IPNetwork('10.0.0.0/8'); print(f'Network: {net.network}, Broadcast: {net.broadcast}, Size: {net.size}')"