Pynetbox is a Python library that serves as an API client for NetBox, an open-source IP address management (IPAM) and data centre infrastructure management (DCIM) tool. This library allows network automation engineers to interact programmatically with NetBox, enabling them to perform various tasks such as retrieving information, creating, updating, and deleting objects within the NetBox environment.
Getting started with Pynetbox
Pynetbox Examples
To interact with Netbox directly
Open Terminal
python
>>> import pynetbox
>>> nb = pynetbox.api(
... "http://<netbox-ip",
... token="<netbox-token"
... )
>>> ipam = nb.ipam.prefixes.filter(within="172.16.0.0/16")
>>> for prefix in ipam:
... print(prefix)
...
This will return all the prefixes in the 172.16.0.0/16 range
Leave a Reply