How to Install NetBox IRM on Ubuntu 24.04 Server Using Windows VPS
NetBox is an open-source Infrastructure Resource Management (IRM) tool designed to manage and document networks, IP addresses, and data center infrastructure. This guide provides step-by-step instructions for installing NetBox on an Ubuntu 24.04 server hosted on a Windows VPS using manual setup, Docker, Ansible, Kubernetes, and Terraform. We’ll also configure Let’s Encrypt for SSL and set up a domain. For reliable VPS hosting, consider Netcloud24 for high-performance Windows VPS solutions.
Power Your NetBox IRM with Netcloud24
Host your NetBox instance on a robust Windows VPS from Netcloud24. Explore our services in your region:
Prerequisites
- Ubuntu 24.04 VPS (e.g., from Netcloud24)
- SSH access with root or sudo privileges
- A registered domain name
- Basic knowledge of Linux commands
Method 1: Manual Setup
Step 1: Update System and Install Dependencies
sudo apt update && sudo apt upgrade -y sudo apt install -y python3 python3-pip python3-venv python3-dev postgresql postgresql-contrib libpq-dev redis-server nginx git
Step 2: Configure PostgreSQL
sudo -u postgres psql CREATE DATABASE netbox; CREATE USER netbox WITH PASSWORD 'YourSecurePassword'; GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox; \q
Step 3: Install NetBox
cd /opt sudo git clone -b release https://github.com/netbox-community/netbox.git cd netbox/netbox sudo python3 -m venv venv source venv/bin/activate pip install -r requirements.txt
Step 4: Configure NetBox
Copy the configuration file and edit it:
sudo cp configuration.example.py configuration.py sudo nano configuration.py
Update the following in configuration.py:
ALLOWED_HOSTS = ['yourdomain.com']
DATABASE = {
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'YourSecurePassword',
'HOST': 'localhost',
'PORT': '',
}
SECRET_KEY = 'your-secret-key' # Generate a secure key
REDIS = {
'tasks': {
'HOST': 'localhost',
'PORT': 6379,
'DATABASE': 0,
},
'caching': {
'HOST': 'localhost',
'PORT': 6379,
'DATABASE': 1,
}
}
Step 5: Run NetBox Installation Script
sudo ./manage.py migrate sudo ./manage.py createsuperuser sudo ./manage.py collectstatic --noinput
Step 6: Configure Gunicorn and Nginx
Create Gunicorn service:
sudo nano /etc/systemd/system/gunicorn.service
Add:
[Unit] Description=gunicorn daemon for NetBox After=network.target [Service] User=www-data Group=www-data WorkingDirectory=/opt/netbox ExecStart=/opt/netbox/venv/bin/gunicorn --workers 3 --bind 127.0.0.1:8001 netbox.wsgi [Install] WantedBy=multi-user.target
Configure Nginx:
sudo nano /etc/nginx/sites-available/netbox
Add:
server {
listen 80;
server_name yourdomain.com;
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;
}
}
Enable services:
sudo systemctl enable gunicorn sudo systemctl start gunicorn sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/ sudo systemctl restart nginx
Method 2: Docker Setup
Step 1: Install Docker
sudo apt install -y docker.io sudo systemctl enable docker sudo systemctl start docker
Step 2: Run NetBox with Docker Compose
mkdir netbox-docker && cd netbox-docker nano docker-compose.yml
Add to docker-compose.yml:
version: '3'
services:
netbox:
image: netboxcommunity/netbox:latest
environment:
- DB_HOST=postgres
- DB_NAME=netbox
- DB_USER=netbox
- DB_PASSWORD=YourSecurePassword
- REDIS_HOST=redis
- SECRET_KEY=your-secret-key
ports:
- "8080:8080"
postgres:
image: postgres:15
environment:
- POSTGRES_DB=netbox
- POSTGRES_USER=netbox
- POSTGRES_PASSWORD=YourSecurePassword
redis:
image: redis:7
Run Docker Compose:
sudo docker-compose up -d
Access NetBox at http://yourdomain.com:8080.
Method 3: Ansible Setup
Step 1: Install Ansible
sudo apt install -y ansible
Step 2: Create Ansible Playbook
mkdir netbox-ansible && cd netbox-ansible nano netbox.yml
Add to netbox.yml:
---
- hosts: all
become: yes
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install dependencies
apt:
name: "{{ packages }}"
state: present
vars:
packages:
- python3
- python3-pip
- postgresql
- redis-server
- nginx
- git
- name: Clone NetBox
git:
repo: 'https://github.com/netbox-community/netbox.git'
dest: /opt/netbox
version: release
- name: Install Python requirements
pip:
requirements: /opt/netbox/requirements.txt
virtualenv: /opt/netbox/venv
Step 3: Run Playbook
ansible-playbook netbox.yml
Method 4: Kubernetes Setup
Step 1: Install Kubernetes
sudo apt install -y kubeadm kubectl kubelet sudo kubeadm init mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config
Step 2: Deploy NetBox
kubectl apply -f https://raw.githubusercontent.com/netbox-community/netbox-docker/master/k8s/netbox-deployment.yaml kubectl apply -f https://raw.githubusercontent.com/netbox-community/netbox-docker/master/k8s/netbox-service.yaml
Access NetBox via the Kubernetes service endpoint.
Method 5: Terraform Setup
Step 1: Install Terraform
sudo apt install -y terraform
Step 2: Create Terraform Configuration
mkdir netbox-terraform && cd netbox-terraform nano main.tf
Add to main.tf (example for AWS, adjust for your provider):
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "netbox" {
ami = "ami-0c55b159cbfafe1f0" # Ubuntu 24.04 AMI
instance_type = "t2.medium"
tags = {
Name = "NetBox-Server"
}
user_data = <<-EOF
#!/bin/bash
apt update && apt upgrade -y
apt install -y python3 python3-pip postgresql redis-server nginx git
git clone -b release https://github.com/netbox-community/netbox.git /opt/netbox
EOF
}
Step 3: Apply Terraform
terraform init terraform apply
Configuring Let’s Encrypt SSL
Step 1: Install Certbot
sudo apt install -y certbot python3-certbot-nginx
Step 2: Obtain and Install SSL Certificate
sudo certbot --nginx -d yourdomain.com
Follow the prompts to configure SSL. Certbot will update Nginx configuration.
Adding a Domain
Update your domain’s DNS records to point to your VPS’s public IP address. For Nginx, ensure the virtual host is configured as shown above.
Conclusion
You’ve now learned how to install NetBox IRM on an Ubuntu 24.04 Windows VPS using manual setup, Docker, Ansible, Kubernetes, and Terraform, along with Let’s Encrypt SSL and domain configuration. For a seamless hosting experience, choose Netcloud24 for reliable VPS solutions tailored for applications like NetBox.
Why Choose Netcloud24?
Netcloud24 offers high-performance VPS solutions for your infrastructure needs. Visit our regional sites: