Skip to content
Fresh IPv4 news just dropped โ€” ๐ŸŽ‰ see what you’re missing

NetBox Quickstart for IPv4 Address Management

Reviewed by Marek Dvoล™รกk, Network engineer

Build a local IPv4 source of truth with the community Docker deployment, then verify the imported prefixes through the REST API. This setup is for evaluation; a production deployment also needs managed secrets, backups, TLS, access controls, and an upgrade plan.

Assumed: Git, Docker with the Compose plugin, curl, and jq installed, a running Docker daemon, and port 8000 available on the Docker host.

Tested with NetBox 4.7.5, netbox-docker 5.1.2, Docker Engine 29.7.2, and Docker Compose 5.5.1. The application and deployment versions are pinned below; the UI paths, CSV scope fields, and API response fields refer to that combination. See the deployment quickstart and image-tag guidance before selecting another version.

Use the private aggregate 10.100.0.0/22 for this lab. These examples do not assert that you hold any public address space. Replace the lab prefixes and site names when loading your own inventory.

Run NetBox with Docker Compose

git clone --depth 1 --branch 5.1.2 https://github.com/netbox-community/netbox-docker.git
cd netbox-docker
cp docker-compose.override.yml.example docker-compose.override.yml
printf 'VERSION=v4.7.5-5.1.2\n' > .env

Before starting, edit docker-compose.override.yml: replace the example port entry "8000:8080" with "127.0.0.1:8000:8080". The override publishes container port 8080 as host port 8000; the added address restricts it to the host’s loopback interface. Without this override the base Compose file does not publish the web port.

docker compose config --quiet
docker compose pull
docker compose up -d

The stack takes a couple of minutes to initialise on first run because it applies database migrations. Watch it complete:

docker compose logs -f netbox

Press Ctrl+C to stop following logs; the containers keep running. Check readiness:

docker compose ps
curl -I http://127.0.0.1:8000/login/

Expected result: netbox is healthy and the login endpoint returns HTTP 200. Then create an administrative user:

docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser

Open http://127.0.0.1:8000 on the Docker host and sign in. If Docker runs on a remote server, forward the port with ssh -L 8000:127.0.0.1:8000 user@your-server, then open the same URL locally. Before production use, replace the supplied application and database/cache secrets and configure the deployment for your environment.

Create a RIR and an aggregate

NetBox models held space top-down, so register the source first. Under IPAM โ†’ RIRs, add the registry your space came from โ€” RIPE NCC, ARIN, APNIC, LACNIC, or AFRINIC. Add a separate RIR entry marked private for RFC 1918 space, so internal and public allocations do not share a utilization figure.

For this lab, create a RIR named Private with Private enabled, then under IPAM โ†’ Aggregates add 10.100.0.0/22 and attach it to that RIR. In your real inventory, add the blocks you hold under their actual RIR. An aggregate records the source space; prefixes describe how you use it.

Do not create aggregates for space you merely route on behalf of someone else. That belongs in prefixes with an appropriate role, and keeping it out of aggregates prevents it from inflating your utilization.

Define roles and sites

Under IPAM โ†’ Prefix & VLAN Roles, create the roles you actually allocate by. A workable starting set is management, customer, loadbalancer, point-to-point, and reserved.

Under Organization โ†’ Sites, create a site with both name and slug ams-01 for the lab. Use the same lowercase names and slugs for the management and customer roles so the CSV below can resolve them by name.

Doing this before entering prefixes is what makes utilization reporting useful later. A prefix with a role and a site answers “what is this for” without anyone reading a free-text description.

Add prefixes under the aggregate

Under IPAM โ†’ Prefixes, create 10.100.0.0/24 with status Container. For its scope, choose DCIM โ†’ Site and select ams-01. NetBox places it under the aggregate automatically based on the addresses โ€” there is no parent field to set. The CSV in the next step creates allocations inside this container.

Set status deliberately so reports distinguish allocation intent:

  • Container โ€” space subdivided further, not assigned directly.
  • Active โ€” in use.
  • Reserved โ€” held deliberately, counted as used.
  • Deprecated โ€” being retired, still recorded.

Mark your intended growth headroom as Reserved rather than leaving it absent. Space that is not recorded is space someone will assign.

Import existing allocations in bulk

Entering an existing estate by hand is where these projects stall. Use IPAM โ†’ Prefixes โ†’ Import with CSV instead:

prefix,status,role,scope_type,scope_name,description
10.100.0.0/26,active,management,dcim.site,ams-01,Out-of-band management
10.100.0.64/26,active,customer,dcim.site,ams-01,Customer VLAN 101
10.100.0.128/25,reserved,,dcim.site,ams-01,Growth headroom

In this version, prefix imports use scope_type and scope_name, rather than a site column. Role and scope names must match existing objects; creating only a matching slug is insufficient. Check the import form’s field list when using another version.

Import in one pass per site so a rejected row is easy to locate. NetBox validates the whole file before committing, so a single malformed prefix fails the batch rather than importing half of it. Expected result: three new prefixes, with two active rows and one reserved row, all scoped to ams-01.

Verify utilization and query the API

Open the aggregate view. The lab’s prefixes cover one /24 inside the /22, so aggregate utilization should be 25%. The /24 container is fully covered by its two active /26s and reserved /25. NetBox measures recorded coverage here, rather than observed traffic or live hosts.

Confirm the same data is reachable programmatically. Open API Tokens from your user menu and create a v2 token with write access disabled. Set NETBOX_TOKEN in your shell to the complete value shown at creation (nbt_<key>.<token>); it uses Bearer authentication. Then:

curl --fail-with-body -sS -H "Authorization: Bearer $NETBOX_TOKEN" \
  "http://127.0.0.1:8000/api/ipam/prefixes/?within=10.100.0.0/22&status=active" \
  | jq '{count, next, prefixes: [.results[] | {prefix, role: .role.name, site: .scope.name}]}'

Expected result: count is 2, next is null, and the active prefixes are 10.100.0.0/26 and 10.100.0.64/26, with their roles and site ams-01. The reserved /25 and container /24 are excluded by status=active. For larger inventories, follow the API’s next URL until it is null. Legacy v1 tokens use Authorization: Token instead; see API authentication.

Troubleshooting

SymptomCheckExpected result or next action
Startup fails or netbox stays unhealthyRun docker compose ps and docker compose logs --tail=100 netbox postgres redis redis-cache.Resolve database/cache connection or configuration errors first. If migrations are still progressing, allow them to finish; increase healthcheck.start_period in the override if first-run initialization exceeds it, then run docker compose up -d again.
Port 8000 is unreachableRun docker compose port netbox 8080 and curl -I http://127.0.0.1:8000/login/ on the Docker host.The mapping should be 127.0.0.1:8000. If absent, check the override filename and recreate with docker compose up -d. A port conflict requires a different host port and matching URL; remote access requires the SSH tunnel above.
CSV import is rejectedRead the row and field error; compare the header with the import form’s field list.Use the scope columns above and existing role/site names. Fix the rejected batch before importing it again.
API returns count: 0Remove status=active, check the within prefix, and confirm the token user’s view permissions.The lab has two active prefixes inside 10.100.0.0/22. A successful empty response is different from an authentication failure: inspect HTTP errors before changing filters.

Where teams get this wrong

Recording only what is deployed. Reserved and planned space belongs in NetBox too. An empty range in the tool reads as available, and someone will take it.

Skipping roles. Roles are optional, so they get skipped, and a year later utilization reporting cannot answer which space is customer-facing.

Treating it as documentation. NetBox earns its keep when provisioning reads from the API. Until something consumes it, it drifts like any other document.

Related

Last updated on