Skip to main content

netbox-unifi-sync

netbox_unifi_sync is a NetBox 4.2+ plugin that runs UniFi -> NetBox sync jobs inside NetBox workers.



Visual Overview

netbox-unifi-sync overview

flowchart LR
    U["UniFi Controller(s)"] --> P["netbox_unifi_sync plugin<br/>NetBox Jobs (RQ)"]
    P --> N["NetBox DCIM/IPAM/Wireless"]
    A["Plugin UI<br/>Settings/Controllers/Mappings"] --> P

Architecture & Internal Flow

Runtime Execution Flow

flowchart TD
    A[Scheduled Job / Manual Trigger] --> B[NetBox RQ Worker]
    B --> C[Load Plugin Settings]
    C --> D[Authenticate to UniFi]
    D --> E[Fetch Data from UniFi API]
    E --> F[Normalize / Map Data]
    F --> G[Create / Update NetBox Objects]
    G --> H[Write Audit Log]

Detailed Sync Pipeline

flowchart LR
    U[UniFi API] --> V[Devices]
    U --> W[VLANs]
    U --> X[WLANs]
    U --> Y[DHCP Scopes]

    V --> M1[Device Mapping]
    W --> M2[VLAN Mapping]
    X --> M3[Wireless Mapping]
    Y --> M4[IP Range Mapping]

    M1 --> NB[NetBox ORM]
    M2 --> NB
    M3 --> NB
    M4 --> NB

    NB --> DB[(NetBox Database)]

Object Lifecycle Logic

flowchart TD
    A[UniFi Object] --> B{Exists in NetBox?}
    B -- Yes --> C[Update Object]
    B -- No --> D[Create Object]
    C --> E[Mark as Synced]
    D --> E
    E --> F{Cleanup Enabled?}
    F -- Yes --> G[Remove Stale Objects]
    F -- No --> H[Keep Orphaned Objects]

Authentication Flow

flowchart LR
    A[Plugin Settings] --> B{Auth Mode}
    B -- API Key --> C[Attach Authorization Header]
    B -- Username/Password --> D[Session Login]
    D --> E[Optional MFA]
    C --> F[Authenticated API Session]
    E --> F
    F --> G[Execute Requests]

Error Handling & Retry Logic

flowchart TD
    A[API Request] --> B{Success?}
    B -- Yes --> C[Process Response]
    B -- No --> D{Retry < Max Attempts?}
    D -- Yes --> E[Backoff + Retry]
    D -- No --> F[Log Error]
    F --> G[Mark Job Failed]

Current release

v0.3.27 is available on PyPI. It fixes disabled-prefix sync, duplicate device names, power-port counters and library device-type matching. It also improves credential/mapping isolation, authorization and dependency security. See the upgrade guide and changelog.

Features

  • Device sync (devices, interfaces, VLANs, prefixes, WLANs, uplink relations, IP assignments)
  • Security Appliance sync — VLAN subinterfaces and gateway IPs created correctly, including Integration API controllers
  • MAC address sync — per-port MACs (Legacy API) or device base MAC on Port 1 (Integration API); NetBox 4.5 MACAddress model compatible
  • DHCP scope sync to NetBox IP Ranges
  • Client IP sync to NetBox IPAM with unifi-client tagging, stable MAC markers, descriptions, and interface assignment by MAC when NetBox has a matching DCIM or virtualization interface
  • NetBox Change Log support for global settings, controllers, and site mappings
  • UniFi auth via API key or legacy login (username/password + optional MFA)
  • Manual and scheduled sync jobs
  • Runtime settings stored in plugin models (Settings, Controllers, Site mappings)

Quick Start

1. Install

pip install netbox-unifi-sync

PyPI project page: https://pypi.org/project/netbox-unifi-sync/

For netbox-docker, build a custom image containing the plugin and use it for both the web service and worker. A requirements file alone does not change the stock image. Follow the Docker setup.


2. Enable plugin in NetBox

PLUGINS = ["netbox_unifi_sync"]

PLUGINS_CONFIG = {
    "netbox_unifi_sync": {}
}

3. Apply migrations

python manage.py migrate

4. Configure in UI

Go to:

Plugins -> UniFi Sync

Configure:

  1. Settings (tenant_name, netbox_roles, defaults)
  2. Controllers (URL, auth mode, credentials)
  3. Site mappings (if UniFi/NetBox site names differ)

5. Run first sync

UI: Plugins -> UniFi Sync -> Sync Dashboard -> Run now

CLI:

python manage.py netbox_unifi_sync_run --dry-run --json
python manage.py netbox_unifi_sync_run
python manage.py netbox_unifi_sync_run --cleanup

Credentials

Set credentials only in:

Plugins -> UniFi Sync -> Controllers


Scheduled Jobs

The plugin supports NetBox Scheduled Jobs.

Recommended intervals:

  • Small environments: every 30–60 minutes
  • Larger environments: every 2–4 hours

NetBox Permissions

For normal NetBox users, grant permissions through NetBox object permissions:

  • View dashboard/run history: view on netbox_unifi_sync.SyncRun
  • Queue a manual sync job: add on netbox_unifi_sync.SyncRun
  • Manage controllers: view/add/change/delete on netbox_unifi_sync.UnifiController
  • Test controller connectivity: change on netbox_unifi_sync.UnifiController
  • Manage site mappings: view/add/change/delete on netbox_unifi_sync.SiteMapping
  • Manage global settings: view/change on netbox_unifi_sync.GlobalSyncSettings
  • View audit log: view on netbox_unifi_sync.PluginAuditEvent

The legacy custom permission netbox_unifi_sync.run_sync is still accepted by the UI and job enqueue boundary for compatibility, but NetBox object permissions map naturally to netbox_unifi_sync.add_syncrun. The legacy custom permission netbox_unifi_sync.test_controller is also accepted, but NetBox object permissions map naturally to netbox_unifi_sync.change_unificontroller.


Cleanup additionally requires netbox_unifi_sync.run_cleanup, together with the permission to queue a sync. Requests through the management command and scheduler run in their administrative/server context.

Security Notes

  • SSL verification defaults to true
  • Secrets are redacted in run history and audit logs
  • Timeouts, retries, and backoff are configurable

Documentation


Maintainer: Release to PyPI

  1. Bump version in:
    • pyproject.toml ([project].version)
    • netbox_unifi_sync/version.py (__version__)
    • netbox-plugin.yaml (compatibility[].release)
  2. Configure PyPI Trusted Publisher (OIDC) for this repository/workflow.
  3. Create tag vX.Y.Z either:
    • via GitHub Actions Create Release Tag (manual) (recommended), or
    • manually with git:
    • git tag -a vX.Y.Z -m "Release vX.Y.Z"
    • git push origin vX.Y.Z
  4. release.yml checks lint, security/dependencies, Python 3.11/3.12 tests, package build and all three version files before creating the GitHub Release.
  5. The standalone publish-python-package.yml verifies the completed tag-push release through workflow_run, then publishes with OIDC and attestations. The manual tag workflow calls the release checks and dispatches publication explicitly. Manual publication remains available for retries.

See the release guide for the exact Trusted Publisher identity, recovery steps and verification. GitHub Release and PyPI upload are separate results: verify both.

Metadata

Release files for netbox-unifi-sync 0.3.27

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for netbox-unifi-sync 0.3.27
File Size Uploaded Provenance Actions
netbox_unifi_sync-0.3.27.tar.gz 333.7 kB With provenance Details for netbox_unifi_sync-0.3.27.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for netbox-unifi-sync 0.3.27
File Interpreter ABI Platform Actions
netbox_unifi_sync-0.3.27-py3-none-any.whl Python 3 none any Details for netbox_unifi_sync-0.3.27-py3-none-any.whl

Total release size: 571.0 kB

Release files / netbox_unifi_sync-0.3.27.tar.gz

Download URL netbox_unifi_sync-0.3.27.tar.gz
Size 333.7 kB
Tags Source
SHA-256 checksum
How to use checksums
16bf69b28dd09df350b7c7952951dc6d4f27275ec5d5677d8510ee007d6c42a7
BLAKE2b-256 checksum
How to use checksums
e906c99d037b4c37d2fdb80b26facb22b9435526ca80239bb59e6a5105c15865
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / netbox_unifi_sync-0.3.27-py3-none-any.whl

Download URL netbox_unifi_sync-0.3.27-py3-none-any.whl
Size 237.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
59fb58dd8d183143b147c9b19ca3998a4661609edd642b3799a5825a7dacc076
BLAKE2b-256 checksum
How to use checksums
2f1f475f4e752112039c0dd4151441aa9b1adb0d54699a16ddbda495867b7908
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for netbox-unifi-sync 0.3.27

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for netbox_unifi_sync-0.3.27.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.27 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page