NetBox is an open-source network documentation and management tool that allows users to manage IP addresses, devices, racks, and more. It is widely used for managing data center infrastructure and network automation. In this guide, we will walk through the steps to install NetBox on Ubuntu 22.04. Whether you’re setting it up on a local server or deploying it on a Windows VPS UK, this guide will help you get NetBox up and running efficiently.

Step 1: Update Your System

Before installing any new software, it’s important to update your system. Run the following commands to ensure your Ubuntu 22.04 system is up to date:

sudo apt update && sudo apt upgrade

This step ensures that your system has the latest software updates and security patches. Keeping your system updated is important whether you’re hosting locally or on a UK Windows VPS.

Step 2: Install Required Dependencies

NetBox requires several dependencies, including PostgreSQL, Redis, and Python packages. To install these dependencies, run the following command:


sudo apt install -y python3 python3-pip python3-venv libpq-dev postgresql postgresql-contrib redis-server nginx
            

These dependencies are necessary to run NetBox, whether you’re deploying it locally or on a Windows Virtual Private Server hosting environment.

Step 3: Configure PostgreSQL

After installing PostgreSQL, you need to create a database and user for NetBox. Log in to the PostgreSQL shell with the following command:

sudo -u postgres psql

Create a new database and user for NetBox:


CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'yourpassword';
ALTER ROLE netbox SET client_encoding TO 'utf8';
ALTER ROLE netbox SET default_transaction_isolation TO 'read committed';
ALTER ROLE netbox SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\q
            

This creates a database and user for NetBox and assigns the necessary privileges. This setup will work whether you're using a local server or deploying on a Windows VPS hosting UK.

Step 4: Download and Set Up NetBox

Now, download the latest stable version of NetBox. Navigate to the /opt directory:

cd /opt

Clone the NetBox repository from GitHub:

sudo git clone -b master https://github.com/netbox-community/netbox.git

Once the repository is cloned, navigate into the NetBox directory:

cd netbox

Create a Python virtual environment for NetBox and activate it:


sudo python3 -m venv /opt/netbox/venv
source /opt/netbox/venv/bin/activate
            

Install the required Python dependencies:

pip install -r requirements.txt

Step 5: Configure NetBox

Copy the example configuration file and open it for editing:


sudo cp /opt/netbox/netbox/netbox/configuration_example.py /opt/netbox/netbox/netbox/configuration.py
sudo nano /opt/netbox/netbox/netbox/configuration.py
            

Update the ALLOWED_HOSTS setting with your server’s IP address or domain name:

ALLOWED_HOSTS = ['your-server-ip', 'your-domain.com']

Next, configure the database settings with the PostgreSQL credentials you created earlier:


DATABASE = {
    'NAME': 'netbox',
    'USER': 'netbox',
    'PASSWORD': 'yourpassword',
    'HOST': 'localhost',
    'PORT': '',
}
            

Save and exit the file. This configuration works for both local and cloud-based environments such as Windows VPS Italy.

Step 6: Initialize NetBox

Run the following command to apply database migrations and create a superuser for NetBox:


cd /opt/netbox/netbox/
python3 manage.py migrate
python3 manage.py createsuperuser
python3 manage.py collectstatic
            

During the createsuperuser process, you will be prompted to enter a username, email, and password for the superuser account.

Step 7: Set Up Gunicorn and Nginx

To run NetBox in production, you’ll need to configure Gunicorn and Nginx. Create a systemd service file for Gunicorn:

sudo nano /etc/systemd/system/netbox.service

Add the following configuration:


[Unit]
Description=NetBox WSGI Service
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/netbox/netbox/
ExecStart=/opt/netbox/venv/bin/gunicorn --workers 3 --bind 0.0.0.0:8001 netbox.wsgi

[Install]
WantedBy=multi-user.target
            

Save the file, reload systemd, and start the NetBox service:


sudo systemctl daemon-reload
sudo systemctl start netbox
sudo systemctl enable netbox
            

Now configure Nginx to act as a reverse proxy. Create a configuration file for NetBox:

sudo nano /etc/nginx/sites-available/netbox

Add the following configuration:


server {
    listen 80;
    server_name your-server-ip;

    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /static/ {
        alias /opt/netbox/netbox/static/;
    }
}
            

Save the file, enable the site, and restart Nginx:


sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/
sudo systemctl restart nginx
            

This setup is ideal for both local servers and hosting on a Windows VPS hosting UK platform.

Step 8: Access NetBox

NetBox should now be accessible via your server’s IP address or domain name. Open a browser and navigate to http://your-server-ip/ to access the NetBox login page. Log in using the superuser credentials you created earlier.

NetBox is now installed and running on your Ubuntu 22.04 server. This powerful network documentation and management tool is ready to help you manage your network infrastructure. For reliable and scalable hosting solutions, consider using Windows VPS UK. They offer a range of hosting plans, including windows virtual private servers, windows vps hosting, and windows virtual dedicated server hosting. Whether you need a windows vps italy or a uk vps windows solution, they provide the performance and flexibility needed to host your NetBox instance efficiently.

Was this answer helpful? 0 Users Found This Useful (0 Votes)