A Python script to list network devices and their IP addresses from a NetBox instance.
This script allows you to retrieve information about a network device (such as a router or switch) from a NetBox instance and display its interfaces along with their associated IP addresses. It uses the NetBox REST API to fetch the data.
- Python 3.x
- Access to a NetBox instance
- A NetBox API token with the necessary permissions
- The Python
requestslibrary (install viapip install requests)
- Clone this repository to your local machine:
git clone https://github.com/JollyFred26/netbox-snapshot.git
- Navigate to the project directory:
cd netbox-snapshot - Install the required dependencies:
pip install requests
- Open the device.py file.
- Update the following variables with your NetBox instance details:
NETBOX_URL = "http://192.168.0.250:8000/api/" # Your NetBox instance URL NETBOX_TOKEN = "YOUR_API_TOKEN" # Your NetBox API token
To run the script and list the information for a specific device, use the following command:
python device.pyYou can use the script without parameters, in this case all devices will be scaned. If you want you can indicate a the device ID as:
python device.py 1Contributions are welcome! To contribute:
- Fork this repository.
- Create a branch for your feature (git checkout -b new-feature).
- Commit your changes (git commit -am 'Add a new feature').
- Push your branch (git push origin new-feature).
- Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.