This script automatically updates the internet provider information for sites in Netbox based on DNS reverse lookup of device IP addresses.
- Python 3.6 or higher
- Access to a Netbox instance
- Required Python packages:
pip install pynetbox python-dotenv


-
Copy the environment file template and fill in your Netbox credentials:
cp .env.example .env
Then edit
.env
with your actual Netbox URL and API key. -
Review and modify
config.json
if needed:tenant_groups
: List of tenant groups to processdevice_roles
: Device roles to look for at each siteinternet_providers
: Mapping of domain names to provider labels
-
Create and activate a virtual environment:
# On Windows python -m venv .venv .\.venv\Scripts\activate # On Linux/Mac python3 -m venv .venv source .venv/bin/activate
-
Install required packages:
pip install -r requirements.txt
To run the script in test mode (no changes to Netbox):
python update_internet_providers.py --test
To update the internet provider information in Netbox:
python update_internet_providers.py
This will display the site names and their detected internet providers.
- The script gets all tenants that belong to the configured tenant groups
- For each tenant's sites, it looks for devices with the specified roles
- It performs a reverse DNS lookup on the device's primary IP
- Based on the FQDN, it determines the internet provider
- Updates the site's
internet_provider
custom field in Netbox
.env
: Contains Netbox credentials (not version controlled)config.json
: Contains tenant groups, device roles, and provider mappings
python update_internet_providers.py --test
python update_internet_providers.py --test --verbose
python update_internet_providers.py --test
python update_internet_providers.py --verbose
python update_internet_providers.py