Setting Up NetBox (Ubuntu 24.04/22.04)

This guide walks you through installing NetBox directly on an Ubuntu LXC or VM (“bare metal” style).

System Requirements

  • RAM: 4GB recommended (2GB minimum for very small labs).
  • Disk: 20GB recommended (10GB minimum).
  • CPU: 2 vCPUs recommended.

1. System Preparation

Update the system and install the required system packages, including PostgreSQL, Redis, and Python build tools.

apt update && apt upgrade -y
apt install -y postgresql postgresql-common postgresql-client redis-server \
git python3-pip python3-venv python3-dev build-essential libxml2-dev \
libxslt1-dev libffi-dev libpq-dev libssl-dev zlib1g-dev

2. Database Setup (PostgreSQL)

  1. Start PostgreSQL:

    systemctl enable --now postgresql
  2. Create Database and User: Replace strong_password with a real password.

    sudo -u postgres psql

    Inside the SQL shell:

    CREATE DATABASE netbox WITH TEMPLATE template0 ENCODING 'UTF8';
    CREATE USER netbox WITH PASSWORD 'strong_password';
    ALTER DATABASE netbox OWNER TO netbox;
    \c netbox
    ALTER SCHEMA public OWNER TO netbox;
    GRANT ALL PRIVILEGES ON SCHEMA public TO netbox;
    \q

3. Install NetBox

  1. Create the NetBox system user:

    useradd -r -d /opt/netbox -s /usr/sbin/nologin netbox
  2. Clone the NetBox repository:

    git clone -b main https://github.com/netbox-community/netbox.git /opt/netbox/
    chown -R netbox:netbox /opt/netbox/
  3. Configure NetBox:

    cd /opt/netbox/netbox/netbox/
    cp configuration_example.py configuration.py

    Generate a secret key:

    root@netbox:/opt/netbox/netbox/netbox# python3 -c 'import secrets; print(secrets.token_hex(50))'
    866887ae9b6f118ce7e5a7b7f7a4b2fa7a1979dab810e8b092dd5dba4a3bc1f6b0e1028ac45850c1b55a617c3ff41c932c56

    Edit `configuration.py` (located in `/opt/netbox/netbox/netbox/`):

    • Set `ALLOWED_HOSTS` to `[’**’]` for initial testing. ***(For production, replace `*` with your NetBox server’s IP addresses or domain names)****:
      ALLOWED_HOSTS = ['*']
    • Set `DATABASE` user to `netbox` and password to `strong_password`.
    • Set `SECRET_KEY` to the string generated above.
  4. Install Dependencies & Run Migrations:

    /opt/netbox/upgrade.sh

    This script creates the Python environment, installs requirements, and builds the DB schema.

  5. Create a Superuser:

    source /opt/netbox/venv/bin/activate
    cd /opt/netbox/netbox
    python3 manage.py createsuperuser

4. Configure Gunicorn & Systemd

  1. Copy the systemd service and config files:

    cp /opt/netbox/contrib/*.service /etc/systemd/system/
    cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py
    systemctl daemon-reload
  2. Start NetBox Services:

    systemctl enable --now netbox netbox-rq

5. Web Server (Nginx)

To serve NetBox on port 80/443.

  1. Install Nginx:

    apt install -y nginx
  2. Configure Nginx: Copy the default config provided by NetBox:

    cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox
    rm /etc/nginx/sites-enabled/default
    ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox
  3. Edit the Nginx Config: Edit `/etc/nginx/sites-available/netbox`. Change `server_name` to your IP or Domain.

  4. Generate Self-Signed SSL Certificate: The default config enables HTTPS, so you need a certificate.

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /etc/ssl/private/netbox.key \
    -out /etc/ssl/certs/netbox.crt \
    -subj "/C=US/ST=State/L=City/O=NetBox/CN=netbox.local"
  5. Restart Nginx:

    systemctl restart nginx

Accessing NetBox

  • Open `<http:///>`
  • Log in with the superuser you created.

Create API Token

To allow Proxmox to talk to NetBox, you need an API token.

  1. Log in to NetBox.
  2. Click on your Username (top right) API Tokens.
  3. Click Add a Token.
  4. Description: `Proxmox SDN`
  5. Write Enabled: Checked (Proxmox needs to write IP data).
  6. Click Create.
  7. Copy the Token. You will need this for the Proxmox SDN Controller setup.

Configure Proxmox SDN with NetBox

Now that NetBox is running, connect Proxmox to it.

Add NetBox IPAM Plugin

  1. Go to Datacenter SDN Options IPAM.
  2. Click Add NetBox.
  3. ID: netbox
  4. URL: http://192.168.1.24/api (Your NetBox URL; no trailing slash or /api path).
  5. Token: Paste the API Token you generated.
  6. Click Add.

Important: Pre-create Prefixes in NetBox

Proxmox will not create the subnet/prefix in NetBox for you. You must do it manually first.

  1. In NetBox, go to IPAM Prefixes Add.
  2. Add the prefix that matches your Proxmox VNet subnet (e.g., `10.60.10.0/24`).
  3. Set Status to Active.

Assign NetBox to a Zone

  1. Go to Datacenter SDN Zones.
  2. Edit your EVPN Zone (e.g., `evpntest`).
  3. Change IPAM to netbox.
  4. Click OK.

Apply & Verify

  1. In Proxmox, go to Datacenter SDN Apply.
  2. Restart a VM/LXC in that VNet.
  3. Check NetBox IPAM; you should see the IP address automatically registered with the VM’s name.