Handling IP addresses and networks with netaddr

Working and manipulating IP addresses is one of the most important tasks for network engineers. Python developers provide an amazing library that can understand the IP addresses and work on them, called netaddr. For example, assume you developed an application and part of it is to get the network and broadcast address for 129.183.1.55/21. You can do that easily via two built-in methods inside the modules called network and broadcast respectively:

net.network129.183.0.net.broadcast129.183.0.0

In general, netaddr provides support for the following features:

Layer 3 addresses:

  • IPv4 and IPv6 addresses, subnets, masks, prefixes
  • Iterating, slicing, sorting, summarizing, and classifying IP networks ...

Get Hands-On Enterprise Automation with Python. now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.