Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Enterprise Automation with Python

You're reading from   Hands-On Enterprise Automation with Python Automate common administrative and security tasks with Python

Arrow left icon
Product type Paperback
Published in Jun 2018
Publisher Packt
ISBN-13 9781788998512
Length 398 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Bassem Aly Bassem Aly
Author Profile Icon Bassem Aly
Bassem Aly
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Setting Up Our Python Environment 2. Common Libraries Used in Automation FREE CHAPTER 3. Setting Up the Network Lab Environment 4. Using Python to Manage Network Devices 5. Extracting Useful Data from Network Devices 6. Configuration Generator with Python and Jinja2 7. Parallel Execution of Python Script 8. Preparing a Lab Environment 9. Using the Subprocess Module 10. Running System Administration Tasks with Fabric 11. Generating System Reports and System Monitoring 12. Interacting with the Database 13. Ansible for System Administration 14. Creating and Managing VMware Virtual Machines 15. Interacting with the OpenStack API 16. Automating AWS with Boto3 17. Using the Scapy Framework 18. Building a Network Scanner Using Python 19. Other Books You May Enjoy

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.network
129.183.0.
net.broadcast
129.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
  • Dealing with various range formats (CIDR, arbitrary ranges and globs, nmap)
  • Set-based operations (unions, intersections, and so on) over IP...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime