AlmaLinuxRHEL Based

How To Install NetBox on AlmaLinux 10

Install NetBox on AlmaLinux 10

NetBox stands as the industry-leading open-source infrastructure resource modeling (IRM) platform, revolutionizing how organizations manage their network infrastructure and IP address management (IPAM). Built on Django’s robust Python framework, this powerful tool provides comprehensive data center infrastructure management (DCIM) capabilities that streamline network documentation, IP address tracking, and infrastructure visualization.

AlmaLinux 10 offers the perfect foundation for NetBox deployment. As a 1:1 binary compatible fork of Red Hat Enterprise Linux, AlmaLinux provides enterprise-grade stability, security, and performance. The combination of NetBox’s advanced features with AlmaLinux’s reliability creates an optimal environment for managing complex network infrastructures.

This comprehensive installation guide covers every aspect of deploying NetBox on AlmaLinux 10. You’ll learn to configure dependencies, optimize system performance, implement security best practices, and troubleshoot common installation challenges. Whether you’re a seasoned system administrator or network engineer, this step-by-step tutorial ensures successful NetBox deployment.

Table of Contents

System Prerequisites and Requirements

Before beginning the NetBox installation process, your AlmaLinux 10 system must meet specific hardware and software requirements. Proper planning at this stage prevents installation complications and ensures optimal performance.

AlmaLinux 10 System Specifications

NetBox requires substantial system resources for efficient operation. Your server should have a minimum of 4GB RAM, though 8GB provides better performance for larger deployments. CPU requirements include at least two cores, with quad-core processors recommended for production environments.

Storage considerations are equally important. Allocate minimum 20GB disk space for the base installation, with additional capacity based on expected data growth. SSD storage significantly improves database performance and overall system responsiveness.

Network connectivity requirements include stable internet access for package downloads and updates. If deploying in production, ensure proper DNS resolution and firewall access for external users.

Dependency Requirements Overview

NetBox’s architecture relies on several critical dependencies that must be properly configured. Python 3.10 or newer serves as the runtime environment, with Python 3.11 and 3.12 also supported. PostgreSQL 12 or higher provides the primary database backend, while Redis 5+ handles caching and background task processing.

Web server requirements include Nginx for reverse proxy functionality and SSL termination. Gunicorn serves as the WSGI server, bridging Django applications with the web server. Additional system libraries support XML parsing, encryption, and database connectivity.

Development tools facilitate Python package compilation during installation. These include GCC compiler, Git version control, and various development headers for system libraries.

Security and Network Considerations

Security planning begins with user account strategy. Create dedicated service accounts with minimal privileges following the principle of least access. SELinux configuration requires specific policies for NetBox components to function properly.

Firewall planning involves opening ports 80 and 443 for web access, plus port 8001 for development testing. Database and Redis services should remain accessible only to local applications unless clustering is required.

Certificate management becomes crucial for production deployments. Plan SSL certificate procurement, either through Let’s Encrypt or commercial certificate authorities. Proper certificate installation ensures encrypted communications and user trust.

Installing System Dependencies

System preparation involves updating AlmaLinux 10 and installing essential packages. This foundation ensures all NetBox components have necessary libraries and development tools.

Updating AlmaLinux 10 System

Begin by updating your AlmaLinux 10 installation to the latest packages. This process addresses security vulnerabilities and ensures compatibility with NetBox requirements.

sudo dnf update -y
sudo reboot

System updates may require a reboot, particularly when kernel updates are involved. Plan maintenance windows accordingly for production systems. After rebooting, verify system status and available disk space.

Installing Core Dependencies

NetBox compilation requires comprehensive development tools and system libraries. Install these packages using the dnf package manager with appropriate flags for automatic dependency resolution.

sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y python3 python3-pip python3-devel python3-setuptools
sudo dnf install -y git gcc gcc-c++ libxml2-devel libxslt-devel
sudo dnf install -y libffi-devel openssl-devel redhat-rpm-config

Development tools provide compilation capabilities for Python packages with C extensions. Python development headers enable proper package building, while XML libraries support NetBox’s data processing requirements.

Additional libraries support cryptographic operations and database connectivity. These dependencies resolve during NetBox installation, preventing compilation errors and ensuring smooth deployment.

PostgreSQL Database Installation and Configuration

PostgreSQL serves as NetBox’s primary data store, requiring careful installation and configuration. AlmaLinux 10 repositories include PostgreSQL packages suitable for NetBox deployment.

sudo dnf install -y postgresql postgresql-server postgresql-devel
sudo postgresql-setup --initdb
sudo systemctl enable postgresql --now

Database initialization creates necessary system catalogs and configuration files. The setup process generates authentication settings and storage parameters appropriate for AlmaLinux environments.

Configure PostgreSQL for NetBox access by modifying authentication settings. Edit the pg_hba.conf file to allow local connections with password authentication.

sudo nano /var/lib/pgsql/data/pg_hba.conf

Locate the local connection entries and modify authentication methods:

local   all             all                                     md5
host    all             all             127.0.0.1/32            md5

Create the NetBox database and dedicated user account with appropriate privileges:

sudo -u postgres psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'strong_password_here';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\q

Restart PostgreSQL to apply authentication changes:

sudo systemctl restart postgresql

Redis Installation and Configuration

Redis provides caching services and background task queue management for NetBox. Install Redis server and configure it for NetBox requirements.

sudo dnf install -y redis
sudo systemctl enable redis --now

Redis default configuration works well for most NetBox installations. However, production deployments benefit from memory optimization and persistence settings. Edit the Redis configuration file for performance tuning:

sudo nano /etc/redis.conf

Key configuration parameters include:

  • maxmemory-policy allkeys-lru for memory management
  • save 900 1 for data persistence
  • bind 127.0.0.1 for local access only

Creating NetBox System User and Directory Structure

Security best practices require dedicated system accounts for service applications. NetBox should operate under its own user account with restricted privileges and proper file system permissions.

Creating the NetBox System User

Create a system user account specifically for NetBox operations. This account provides isolation and limits potential security exposure if system compromise occurs.

sudo useradd --system --shell /bin/bash --home-dir /opt/netbox --create-home netbox
sudo chmod 750 /opt/netbox

The system user account prevents interactive login while maintaining necessary file system access. The home directory serves as the NetBox installation location, with restrictive permissions preventing unauthorized access.

Setting Up Directory Structure

Proper directory organization facilitates maintenance and security. Create subdirectories for NetBox components with appropriate ownership and permissions.

sudo mkdir -p /opt/netbox/{media,reports,scripts}
sudo chown -R netbox:netbox /opt/netbox
sudo chmod -R 755 /opt/netbox

Directory structure separates static files, user uploads, and custom scripts. This organization simplifies backup procedures and security auditing.

Security Hardening Implementation

SELinux integration requires specific contexts for NetBox directories and executables. Configure SELinux labels to allow proper NetBox operation without compromising system security.

sudo setsebool -P httpd_can_network_connect 1
sudo setsebool -P httpd_execmem 1
sudo semanage fcontext -a -t httpd_exec_t "/opt/netbox/venv/bin/python3"
sudo restorecon -Rv /opt/netbox

These SELinux modifications permit web server communication and Python execution within NetBox directories. Boolean settings enable network connectivity and memory execution as required by Django applications.

Downloading and Installing NetBox

NetBox installation involves downloading source code, creating Python virtual environments, and installing dependencies. This process ensures clean deployment with proper dependency isolation.

Downloading NetBox Source Code

Obtain NetBox source code from the official GitHub repository. Git cloning provides version control benefits and simplifies future updates.

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

The master branch contains the latest stable release, appropriate for production deployments. Alternative branches provide access to development features or specific version requirements.

Verify download integrity by checking file permissions and directory contents:

sudo -u netbox ls -la /opt/netbox/
sudo -u netbox find /opt/netbox -name "*.py" | wc -l

Setting Up Python Virtual Environment

Virtual environments isolate Python dependencies, preventing conflicts with system packages. Create a dedicated virtual environment for NetBox within the installation directory.

sudo -u netbox python3 -m venv /opt/netbox/venv
sudo -u netbox /opt/netbox/venv/bin/pip install --upgrade pip

Virtual environment activation modifies PATH variables to prioritize local Python interpreter and packages. This isolation prevents system-wide package conflicts and simplifies dependency management.

Verify virtual environment creation:

sudo -u netbox /opt/netbox/venv/bin/python --version
sudo -u netbox /opt/netbox/venv/bin/pip --version

Installing NetBox Dependencies

NetBox requires numerous Python packages for full functionality. Install these dependencies using pip within the virtual environment.

sudo -u netbox /opt/netbox/venv/bin/pip install -r /opt/netbox/requirements.txt

Dependency installation compiles packages with C extensions, utilizing previously installed development tools. This process may take several minutes depending on system performance and network connectivity.

Monitor installation progress and address any compilation errors immediately. Common issues include missing development headers or incompatible package versions.

Database Configuration and Migration

Database setup involves creating NetBox schema, running initial migrations, and verifying connectivity. Proper database configuration ensures reliable data storage and optimal performance.

PostgreSQL Database Preparation

Test database connectivity before proceeding with NetBox configuration. Verify user authentication and database access permissions function correctly.

sudo -u netbox psql -U netbox -h localhost -d netbox -c "SELECT version();"

Successful connection displays PostgreSQL version information, confirming proper authentication configuration. Connection failures indicate authentication or network configuration issues requiring resolution.

Database Migration and Schema Creation

Django migrations create NetBox database schema and initialize system tables. Run migrations using NetBox management commands within the virtual environment.

cd /opt/netbox
sudo -u netbox /opt/netbox/venv/bin/python manage.py migrate

Migration process creates tables, indexes, and constraints required for NetBox operation. Progress indicators show migration status and any potential errors requiring attention.

Verify successful migration by checking database table creation:

sudo -u postgres psql -d netbox -c "\dt" | head -20

NetBox Configuration Setup

Configuration management involves creating NetBox settings, generating security keys, and defining system parameters. Proper configuration ensures secure operation and optimal performance.

Configuration File Creation

NetBox includes example configuration requiring customization for your environment. Copy the example configuration and modify parameters for your specific deployment.

sudo -u netbox cp /opt/netbox/netbox/configuration_example.py /opt/netbox/netbox/configuration.py

Configuration file contains numerous settings controlling NetBox behavior, security, and integration options. Review all sections carefully and modify parameters appropriately.

Essential Configuration Parameters

Critical configuration parameters require immediate attention for basic NetBox functionality. Generate secure secret keys and configure database connectivity.

Generate a unique secret key for Django session security:

sudo -u netbox python3 /opt/netbox/generate_secret_key.py

Edit the configuration file with your specific settings:

sudo -u netbox nano /opt/netbox/netbox/configuration.py

Key configuration sections include:

SECRET_KEY = 'your_generated_secret_key_here'

ALLOWED_HOSTS = ['netbox.example.com', '192.168.1.100']

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

REDIS = {
    'tasks': {
        'HOST': 'localhost',
        'PORT': 6379,
        'DATABASE': 0,
    },
    'caching': {
        'HOST': 'localhost',
        'PORT': 6379,
        'DATABASE': 1,
    }
}

Security Configuration Implementation

Security settings protect NetBox from unauthorized access and common web vulnerabilities. Configure authentication methods, session security, and access controls.

Additional security parameters include:

DEBUG = False
CORS_ORIGIN_ALLOW_ALL = False
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

These settings enforce HTTPS communication, protect against cross-site scripting, and secure session management. Production deployments require all security features enabled.

Initial NetBox Setup and Testing

Initial setup involves running database migrations, creating administrative accounts, and performing functionality testing. These steps verify proper installation and configuration.

Running Initial Database Migrations

Execute NetBox’s initial setup command to complete database preparation and create necessary system objects.

sudo -u netbox /opt/netbox/venv/bin/python /opt/netbox/manage.py migrate
sudo -u netbox /opt/netbox/venv/bin/python /opt/netbox/manage.py collectstatic --no-input

Static file collection prepares CSS, JavaScript, and image assets for web server delivery. This process organizes files for optimal performance and proper functionality.

Creating Administrative User Account

Create a superuser account for NetBox administration and initial configuration. This account provides full system access for setup and ongoing management.

sudo -u netbox /opt/netbox/venv/bin/python /opt/netbox/manage.py createsuperuser

Follow prompts to create username, email address, and password for the administrative account. Use strong passwords meeting organizational security requirements.

Testing NetBox Functionality

Verify NetBox installation by starting the development server and accessing the web interface. This test confirms proper configuration and identifies any remaining issues.

sudo -u netbox /opt/netbox/venv/bin/python /opt/netbox/manage.py runserver 0.0.0.0:8001

Access NetBox through web browser at http://your-server-ip:8001 and log in using the created superuser account. Successful login confirms proper installation and configuration.

Install NetBox on AlmaLinux 10

Web Server Configuration with Nginx

Production NetBox deployments require robust web server configuration for performance, security, and reliability. Nginx provides reverse proxy capabilities and SSL termination.

Installing and Configuring Nginx

Install Nginx web server and configure virtual hosts for NetBox. Proper configuration ensures optimal performance and security.

sudo dnf install -y nginx
sudo systemctl enable nginx

Create Nginx configuration file for NetBox:

sudo nano /etc/nginx/conf.d/netbox.conf

Nginx configuration includes proxy settings and security headers:

server {
    listen 80;
    server_name netbox.example.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;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
    
    location /static/ {
        alias /opt/netbox/static/;
    }
    
    location /media/ {
        alias /opt/netbox/media/;
    }
}

SSL Certificate Configuration

Production deployments require SSL encryption for security and user trust. Configure Let’s Encrypt certificates for automated renewal.

sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d netbox.example.com

Certbot automatically modifies Nginx configuration to include SSL settings and redirect HTTP traffic to HTTPS. Verify certificate installation and automatic renewal configuration.

Gunicorn WSGI Server Setup

Gunicorn provides production-ready WSGI server capabilities for Django applications. Configure Gunicorn for optimal NetBox performance.

sudo -u netbox /opt/netbox/venv/bin/pip install gunicorn

Create Gunicorn configuration file:

sudo -u netbox nano /opt/netbox/gunicorn.conf.py

Gunicorn configuration optimizes performance:

bind = '127.0.0.1:8001'
workers = 4
worker_class = 'gevent'
worker_connections = 1000
max_requests = 1000
max_requests_jitter = 50
timeout = 300

Systemd Service Configuration

Service management requires proper systemd configuration for automatic startup and process monitoring. Create service files for NetBox components.

Creating NetBox Systemd Services

Create systemd service files for NetBox web service and background workers. These services ensure automatic startup and proper process management.

Create NetBox web service:

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

Service configuration includes dependencies and restart policies:

[Unit]
Description=NetBox WSGI Service
Documentation=https://netboxlabs.com/docs/
After=network-online.target database.service redis.service
Wants=network-online.target
Requires=database.service redis.service

[Service]
Type=notify
User=netbox
Group=netbox
WorkingDirectory=/opt/netbox
Environment="VIRTUAL_ENV=/opt/netbox/venv"
ExecStart=/opt/netbox/venv/bin/gunicorn --config /opt/netbox/gunicorn.conf.py netbox.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
KillMode=mixed
TimeoutStopSec=5
PrivateTmp=true
Restart=on-failure
RestartSec=30

[Install]
WantedBy=multi-user.target

Create NetBox RQ worker service for background tasks:

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

Service Management and Monitoring

Enable and start NetBox services, then verify proper operation and automatic startup configuration.

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

Monitor service status and logs:

sudo systemctl status netbox
sudo journalctl -u netbox -f

Proper service configuration ensures reliable NetBox operation and automatic recovery from failures.

Firewall and Security Hardening

Security implementation involves firewall configuration, SELinux policies, and access controls. Comprehensive security measures protect NetBox from unauthorized access and attacks.

Firewall Configuration

Configure firewall rules to allow necessary NetBox traffic while blocking unauthorized access. AlmaLinux 10 uses firewalld for firewall management.

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Verify firewall configuration:

sudo firewall-cmd --list-all

SELinux Policy Configuration

SELinux requires specific policies for NetBox components. Configure contexts and booleans for proper operation without compromising security.

sudo setsebool -P httpd_can_network_connect 1
sudo setsebool -P httpd_execmem 1
sudo semanage port -a -t http_port_t -p tcp 8001

Verify SELinux configuration:

sudo getsebool -a | grep httpd
sudo semanage port -l | grep http_port_t

Post-Installation Tasks and Maintenance

Ongoing maintenance ensures optimal NetBox performance and reliability. Implement automated housekeeping, backup procedures, and monitoring systems.

Automated Housekeeping Configuration

Configure cron jobs for routine maintenance tasks including database cleanup and log rotation. These tasks prevent storage issues and maintain performance.

sudo -u netbox crontab -e

Add housekeeping tasks:

0 2 * * * /opt/netbox/venv/bin/python /opt/netbox/manage.py clearsessions
0 3 * * 0 /opt/netbox/venv/bin/python /opt/netbox/manage.py collectstatic --no-input

Backup and Recovery Procedures

Implement comprehensive backup strategies covering database content, configuration files, and media uploads. Regular backups enable quick recovery from system failures.

Database backup script:

#!/bin/bash
pg_dump -U netbox -h localhost netbox > /backup/netbox-$(date +%Y%m%d).sql
find /backup -name "netbox-*.sql" -mtime +7 -delete

Configuration backup includes NetBox settings and system configurations essential for restoration.

Performance Monitoring Setup

Monitor system resources, database performance, and application metrics. Proper monitoring identifies issues before they impact users.

Key metrics include:

  • Database connection counts and query performance
  • Memory usage and CPU utilization
  • Disk space consumption
  • Network connectivity and response times

Troubleshooting Common Issues

Installation and operation issues require systematic troubleshooting approaches. Common problems include dependency conflicts, permission errors, and service failures.

Installation Troubleshooting

Dependency conflicts occur when system packages interfere with NetBox requirements. Resolve conflicts by using virtual environments and specific package versions.

Python version issues require updating AlmaLinux repositories or compiling Python from source. Ensure Python 3.10+ availability before beginning installation.

Permission problems result from incorrect user accounts or SELinux contexts. Verify file ownership and SELinux labels match NetBox requirements.

Runtime Troubleshooting

Service startup failures often indicate configuration errors or missing dependencies. Check service logs and configuration files for specific error messages.

Database connection issues require verifying PostgreSQL service status, authentication settings, and network connectivity. Test connections using command-line tools before troubleshooting NetBox.

Web server problems include proxy configuration errors, SSL certificate issues, and port conflicts. Verify Nginx configuration and test connectivity independently.

Performance Troubleshooting

Memory usage optimization involves adjusting database settings, Python process limits, and system parameters. Monitor memory consumption during peak usage periods.

Database performance tuning includes index optimization, query analysis, and connection pooling configuration. Regular maintenance prevents performance degradation.

Network connectivity issues affect user experience and system integration. Verify firewall rules, DNS resolution, and bandwidth availability.

Congratulations! You have successfully installed NetBox. Thanks for using this tutorial for installing NetBox IRM on your AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official NetBox website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button