Installing NetBox on Fedora CoreOS Latest

NetBox is an open-source web-based IPAM (IP Address Management) and DCIM (Data Center Infrastructure Management) tool used to manage network address space and other critical infrastructure components. In this tutorial, we will go through the steps to install NetBox on Fedora CoreOS Latest.

Prerequisites

Before proceeding, make sure you have the following:

Steps

  1. Update the system:

    sudo dnf update -y
    
  2. Install the required system packages:

    sudo dnf install -y python3 python3-pip python3-devel nginx redis redis-devel gcc git openssl-devel
    
  3. Clone NetBox from Github:

    git clone -b master https://github.com/digitalocean/netbox.git
    
  4. Create a virtual environment and activate it:

    python3 -m venv netboxenv
    
    source netboxenv/bin/activate
    
  5. Install the required Python packages:

    cd netbox
    pip install -r requirements.txt
    
  6. Create a configuration file:

    cp netbox/netbox/configuration.example.py netbox/netbox/configuration.py
    
  7. Edit the configuration file with your preferences:

    nano netbox/netbox/configuration.py
    

    For example, update the following settings with your preferences:

    ALLOWED_HOSTS = ['your.host.name']
    SECRET_KEY = 'your-secret-key'
    
    # Database
    DATABASES = {
         'default': {
             'NAME': 'netbox',
             'USER': 'netbox',
             'PASSWORD': 'yourpassword',
             'HOST': 'localhost',
             'PORT': '',
             'ENGINE': 'django.db.backends.postgresql',
         },
     }
    
    # Redis
    REDIS = {
         'tasks': {
             'HOST': 'localhost',
             'PORT': 6379,
             'PASSWORD': '',
             'DATABASE': 0,
             'DEFAULT_TIMEOUT': 300,
         },
     }
    
  8. Create the PostgreSQL database:

    sudo -u postgres psql -c "CREATE DATABASE netbox;"
    sudo -u postgres psql -c "CREATE USER netbox WITH PASSWORD 'yourpassword';"
    sudo -u postgres psql -c "ALTER USER netbox CREATEDB;"
    sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;"
    
  9. Migrate the database:

    python3 manage.py migrate
    
  10. Create a superuser:

    python3 manage.py createsuperuser
    
  11. Start the development server:

    python3 manage.py runserver 0.0.0.0:8000
    
  12. Open your web browser and navigate to http://your.host.name:8000/ to access the NetBox web interface.

  13. Shutdown the development server by pressing CTRL + C.

  14. Setup the Gunicorn launcher:

    sudo cp contrib/gunicorn.py /etc/netbox/
    sudo nano /etc/netbox/gunicorn.py
    

    Edit the following lines:

    bind = '127.0.0.1:8001'
    worker_class = 'gevent'
    workers = 4
    
  15. Start Gunicorn service:

    sudo cp contrib/gunicorn.service /etc/systemd/system/
    sudo systemctl enable gunicorn
    sudo systemctl start gunicorn
    sudo systemctl status gunicorn
    
  16. Setup the Nginx web server:

    sudo cp contrib/nginx.conf.sample /etc/nginx/conf.d/netbox.conf
    sudo nano /etc/nginx/conf.d/netbox.conf
    

    Edit the following lines:

    server {
        listen 80;
        server_name your.host.name;
    
        location /static/ {
            alias /opt/netbox/netbox/static/;
        }
    
        location / {
            proxy_pass http://localhost: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;
        }
    }
    
  17. Start the Nginx service:

    sudo systemctl enable nginx
    sudo systemctl start nginx
    sudo systemctl status nginx
    
  18. Open your web browser and navigate to http://your.host.name/ to access the NetBox web interface.

Conclusion

In this tutorial, we learned how to install NetBox on Fedora CoreOS Latest. Now you can start managing your network infrastructure using NetBox.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!