Scripts2026年4月16日·1 分钟阅读

NetBox — Source of Truth for Network Automation

NetBox is an open-source DCIM and IPAM application that serves as the source of truth for modern network automation, modeling devices, IP space, circuits, racks, and cables.

Introduction

NetBox started inside DigitalOcean as a private tool to replace a sprawl of spreadsheets tracking IP allocations, rack elevations, and fiber runs. It was open-sourced in 2016 and has become the de-facto source of truth for network teams that want their automation pipelines to generate configs from a single authoritative model instead of guessing. The project is Django-based, well-documented, and ships both a classic server-rendered UI and a full REST + GraphQL API.

What NetBox Does

  • Models physical and virtual infrastructure: sites, racks, devices, modules, inventory items, power, cabling, and console paths.
  • Provides an IP Address Management (IPAM) engine for aggregates, prefixes, IP ranges, IPs, VLANs, VRFs, and ASNs.
  • Tracks circuits, providers, and long-haul fiber, closing the loop between WAN and on-prem.
  • Exposes every object via REST, GraphQL, webhooks, and custom scripts so Ansible, Nautobot, or Terraform can consume it.
  • Supports tenancy, custom fields, change logging, and a permissions model strong enough for regulated environments.

Architecture Overview

NetBox is a Django 5 application backed by PostgreSQL for relational data and Redis for caching, queueing, and the RQ worker pool. Gunicorn fronts the Python app, nginx (or a reverse proxy of your choice) handles TLS, and a separate worker container runs async jobs like scheduled scripts, webhooks, and report execution. Object history, custom field definitions, and change logs live in the same database; search is powered by PostgreSQL full-text indexes. Plugins are first-class — they extend models, views, navigation, and GraphQL — which is how ecosystem projects like netbox-topology-views or netbox-branching integrate without forking core.

Self-Hosting & Configuration

  • Install via netbox-docker, Helm chart, or a manual systemd deploy against PostgreSQL 14+ and Redis 6+.
  • configuration.py holds secrets, ALLOWED_HOSTS, auth backends (LDAP, SAML, OIDC via social-auth), and plugin config.
  • Run manage.py migrate + manage.py collectstatic on every upgrade; keep a DB backup before major version jumps.
  • Offload object storage (device images, script uploads) to S3/MinIO via the django-storages backend for HA deploys.
  • Enable the RQ worker and schedule housekeeping daily to clean stale sessions, expired tokens, and changelog entries.

Key Features

  • Rich cable and power modeling including patch panels, breakouts, and multi-cable traces.
  • First-class custom fields, custom links, tags, and journal entries for any object type.
  • Built-in GraphQL endpoint with filtering that mirrors the REST API for efficient UI and pipeline queries.
  • Scripts and Reports execute arbitrary Python against the model, safely sandboxed per job.
  • Extensive plugin framework with a public registry and semantic-version compatibility guarantees.

Comparison with Similar Tools

  • Nautobot — NetBox fork with a plugin-first philosophy, Celery-based jobs, and a more opinionated data model.
  • phpIPAM — Lighter PHP-based IPAM with weaker DCIM; good if you only need IP tracking.
  • Infoblox — Commercial appliance covering DNS/DHCP/IPAM; NetBox is open and SOT-focused, not a DNS server.
  • RackTables — Mature but aging DCIM; lacks NetBox''s API surface and active plugin ecosystem.
  • SolarWinds IPAM — Windows-stack commercial suite; NetBox wins on automation-friendliness and licensing cost.

FAQ

Q: Does NetBox push configuration to devices? A: No. It is intentionally a source of truth. Tools like Ansible, Nornir, or Nautobot consume NetBox data and render configs.

Q: Can I use it for cloud networks? A: Yes — there are models for virtual machines, clusters, and cloud regions/providers, and plugins extend AWS/Azure/GCP coverage.

Q: How do I keep dev and prod in sync? A: Use the REST API and object-level changelog, or try the netbox-branching plugin which adds git-like branches to the data model.

Q: Is there an audit trail? A: Every create/update/delete is logged with user, timestamp, and full diff, retained for a configurable window.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产