We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – How To Install NetBox IPAM on Rocky Linux 8 / CentOS 8

Learn how to – How To Install NetBox IPAM on Rocky Linux 8 / CentOS 8.

Netbox is a free and open-source tool used to manage and document computer networks via the web. This has helped reduce the tedious task of networking in organizations by creating a virtual implementation of every device in a data center. Back in the day, this task was done by drawing the network structure on paper but with NetBox, organized and presentable operations are visualized via the web.

Netbox is written in Django and uses the PostgreSQL database to document computer networks and manage IP addresses. It has the following amazing features:

  • IPAM – IP Address Management
  • Vlan Management
  • Rack Elevation
  • VRF Management
  • Multi-Site (tenancy)
  • Connection Management – Interfaces/Console/Power
  • Customization Header For Logo’s etc
  • Circuit Provider Management
  • Single Converged Database
  • DCIM – Data Center Infrastructure Management
  • Report Alert

1. Update System and Install dependencies

In this guide, we will install and configure NetBox IPAM Tool on Rocky Linux 8. For this guide, you will require:

  • A Rocky Linux 8 system.
  • A user with sudo privileges.
  • Python 3.8 and above
  • PostgreSQL 10
  • Redis 4.0

Update your system.

sudo yum update -y

Install the EPEL repository required for installing dependencies.

sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Install the required dependencies.

sudo yum install -y gcc libxml2-devel libxslt-devel libffi-devel libpq-devel openssl-devel redhat-rpm-config git vim

Set SELinux in permissive mode since we will be using TCP ports.

sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
cat /etc/selinux/config | grep SELINUX=

2. Install Python on Rocky Linux 8 / CentOS 8

In this guide, we will install Python 3.9 since this version of Netbox IPAM requires Python 3.7 and above. Python 3.9 is available in the default repositories and can be installed with the command:

Install Python 3.9 on Rocky Linux 8|CentOS 8 with the command:

sudo yum install python3.9 

Dependency tree;

Dependencies resolved.
 Package            Arch   Version                              Repo       Size
 python39           x86_64 3.9.7-1.module_el8.6.0+930+10acc06f  appstream  33 k
Installing dependencies:
 python39-libs      x86_64 3.9.7-1.module_el8.6.0+930+10acc06f  appstream 8.2 M
 python39-pip-wheel noarch 20.2.4-6.module_el8.6.0+930+10acc06f appstream 1.3 M
                    noarch 50.3.2-4.module_el8.6.0+930+10acc06f appstream 497 k
Installing weak dependencies:
 python39-pip       noarch 20.2.4-6.module_el8.6.0+930+10acc06f appstream 2.0 M
                    noarch 50.3.2-4.module_el8.6.0+930+10acc06f appstream 871 k
Enabling module streams:
 python39                  3.9                                                 

Transaction Summary
Install  6 Packages

Total download size: 13 M
Installed size: 45 M
Is this ok [y/N]: y

Identify the path to python.

$ whereis python3.9
python3: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3 /usr/bin/python3.9 /usr/lib/python3.6 /usr/lib/python3.9 /usr/lib64/python3.6 /usr/lib64/python3.9 /usr/include/python3.6m /usr/include/python3.9 /usr/share/man/man1/python3.1.gz

Create a symbolic link to /usr/bin/python. If there already exists a link, remove the existing file sudo rm -rf /usr/bin/python3 and pip3 as well

sudo ln -fs /usr/bin/python3.9 /usr/bin/python3
sudo ln -fs /usr/bin/pip3.9 /usr/bin/pip3

Verify the installed version.

$ python3 --version
Python 3.9.13

3. Install and configure PostgreSQL database server

Since Netbox IPAM uses the PostgreSQL database, it is required that we install it on Rocky Linux. First, check the latest available version.

$ sudo dnf module list postgresql
Rocky Linux 8 - AppStream
Name         Stream   Profiles             Summary                              
postgresql   9.6      client, server [d]   PostgreSQL server and client module  
postgresql   10 [d]   client, server [d]   PostgreSQL server and client module  
postgresql   12       client, server [d]   PostgreSQL server and client module  
postgresql   13       client, server [d]   PostgreSQL server and client module  

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

From the output, we will install version 13. Enable it as below

$ sudo dnf module enable postgresql:13
Dependencies resolved.
 Package           Architecture     Version             Repository         Size
Enabling module streams:
 postgresql                         13                                         

Transaction Summary

Is this ok [y/N]: y

The proceed and install the enabled PostgreSQL version.

sudo dnf install postgresql-server

Initialize PostgreSQL.

sudo postgresql-setup --initdb

With a successful installation, start and enable PostgreSQL to run on boot.

sudo systemctl start postgresql
sudo systemctl enable postgresql

Now create a database for NetBox IPAM.

sudo -u postgres psql

While in the PostgreSQL shell, create a database as below.


Enable password login in PostgreSQL.

sudo sed -i -e 's/ident/md5/' /var/lib/pgsql/data/pg_hba.conf
sudo systemctl restart postgresql

Confirm if you can log in to the database created using the password set.

$ psql -U netbox -h localhost -W
Password: <Input-Password>
psql (13.3)
Type "help" for help.

netbox=> q

4. Install and Configure Redis on Rocky Linux 8 / CentOS 8

The required Redis version is 4.0 and above, install it as below:

sudo yum install -y redis

Start and enable Redis.

sudo systemctl start redis
sudo systemctl enable redis

Check the installed version.

$ redis-server -v
Redis server v=5.0.3 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=9529b692c0384fb7

Verify the server status.

$ redis-cli ping

5. Install and Configure Netbox on Rocky Linux 8 / CentOS 8

Now we have come to the nub of this guide where we are required to clone NetBox IPAM from git and configure it on Rocky Linux 8|CentOS 8.

First, navigate to the /opt/ directory and clone NetBox.

sudo mkdir -p /opt/netbox/ && cd /opt/netbox/
sudo git clone -b master --depth 1 https://github.com/netbox-community/netbox.git .

Create the Netbox user.

sudo groupadd --system netbox
sudo adduser --system -g netbox netbox
sudo chown --recursive netbox /opt/netbox/netbox/media/

Now create a configuration file for Netbox.

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

Now edit the configuration file.

sudo vim configuration.py

Edit the file as below.

# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']

# PostgreSQL database configuration.
    'NAME': 'netbox',                           # Database name you created
    'USER': 'netbox',                           # PostgreSQL username you created
    'PASSWORD': 'Passw0rd',               # PostgreSQL password you set
    'HOST': 'localhost',                        # Database server
    'PORT': '',                                 # Database port (leave blank for default)
    'CONN_MAX_AGE': 300,                        # Max database connection age

Since Netbox requires two databases for tasks and caching, we will proceed and edit the Redis database as well. The defaults are okay.

    'tasks': {
        'HOST': 'localhost',      # Redis server
        'PORT': 6379,             # Redis port
        'PASSWORD': '',           # Redis password (optional)
        'DATABASE': 0,            # Database ID
        'SSL': False,             # Use SSL (optional)
    'caching': {
        'HOST': 'localhost',
        'PORT': 6379,
        'PASSWORD': '',
        'DATABASE': 1,            # Unique ID for second database
        'SSL': False,

Generate the Django Secret Key

Now generate the Django SECRET Key as below.

python3 ../generate_secret_key.py

Sample Output:


With the key generated, proceed and set it in the configuration.py as below.

$ sudo vim /opt/netbox/netbox/netbox/configuration.py
# https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-SECRET_KEY
SECRET_KEY = 'Tzvw(9w1tc2^lRzwLc@cDgdrX^3AwDDWXBgMM7OU$vR7LLAh#V'

Run the Upgrade Script

The Upgrade Script automatically runs the following:

  • Creates a Python environment and installs all required Python packages
  • Run database schema migrations
  • Builds the documentation locally (for offline use)
  • Aggregate static resource files on disk

The command used is as below:

sudo /opt/netbox/upgrade.sh

Sample output:

Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying extras.0001_squashed... OK
  Applying tenancy.0001_squashed_0012... OK
  Applying tenancy.0002_tenant_ordering... OK
  Applying dcim.0001_squashed... OK
  Applying dcim.0002_squashed... OK
  Applying ipam.0001_squashed... OK
  Applying virtualization.0001_squashed_0022... OK
  Applying extras.0002_squashed_0059... OK
  Applying extras.0060_customlink_button_class... OK
Collecting static files (python3 netbox/manage.py collectstatic --no-input)...

478 static files copied to '/opt/netbox/netbox/static'.
Removing stale content types (python3 netbox/manage.py remove_stale_contenttypes --no-input)...
Removing expired user sessions (python3 netbox/manage.py clearsessions)...
Upgrade complete! Don't forget to restart the NetBox services:
  > sudo systemctl restart netbox netbox-rq

Create Netbox User Account.

The next step requires us to create a superuser account since Netbox doesn’t come with predefined user accounts. From the Netbox directory execute the command

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

Proceed as below.

Username (leave blank to use 'thor'): admin
Email address: admin@ownyourlife.com.ng
Password (again): 
Superuser created successfully.

Proceed and schedule housekeeping tasks. This handles repetitive cleanup tasks.

sudo ln -s /opt/netbox/contrib/netbox-housekeeping.sh /etc/cron.daily/netbox-housekeeping

Test the Instalation.

Now test the application. But before that, allow port 8000 through the firewall.

sudo firewall-cmd --add-port=8000/tcp --permanent
sudo firewall-cmd --reload

Now test Netbox

$ python3 manage.py runserver --insecure
Performing system checks...

System check identified no issues (0 silenced).
May 05, 2022 - 15:52:46
Django version 4.0.4, using settings 'netbox.settings'
Starting development server at
Quit the server with CONTROL-C.

Now you can access Netbox using the URL http://IP_Address:8000. You can also try logging in using the created superuser.

Stop the server using CTL+C and proceed as below.

Install and configure the Gunicorn module

Netbox ships default Gunicorn configuration that can be copied to the Netbox path as below.

sudo cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py

You may wish to edit the file and make configurations for your Bind Ip and port.

sudo vim /opt/netbox/gunicorn.py

In the file, add the below lines.

bind = ''

workers = 5

threads = 3

timeout = 120

# The maximum number of requests a worker can handle before being respawned
max_requests = 5000
max_requests_jitter = 500

Create a systemd service file.

To be able to manage Netbox like other system services, we need to create the system file.

sudo cp -v /opt/netbox/contrib/*.service /etc/systemd/system/
sudo systemctl daemon-reload

Start and enable Netbox services.

sudo systemctl start netbox netbox-rq
sudo systemctl enable netbox netbox-rq

Verify if the service is running:

$ systemctl status netbox.service
● netbox.service - NetBox WSGI Service
   Loaded: loaded (/etc/systemd/system/netbox.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-05-05 12:07:27 EDT; 11s ago
     Docs: https://docs.netbox.dev/
 Main PID: 12914 (gunicorn)
    Tasks: 6 (limit: 23505)
   Memory: 384.4M
   CGroup: /system.slice/netbox.service
           ├─12914 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --c>
           ├─12916 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --c>
           ├─12917 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --c>
           ├─12918 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --c>
           ├─12919 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --c>
           └─12920 /opt/netbox/venv/bin/python3 /opt/netbox/venv/bin/gunicorn --pid /var/tmp/netbox.pid --pythonpath /opt/netbox/netbox --c

The service should be running on port 8001.

$ ss -tunelp | grep 8001
tcp   LISTEN 0      128*    uid:993 ino:24304646 sk:1e <->

6. Install and Configure Nginx for Netbox IPAM

In this guide, we will be showing the configuration of the Nginx web server. Install the Nginx web-server on Rocky Linux 8 with the command.

sudo yum -y install nginx

We will first create a virtual host file for our web page.

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

In the file, add the below lines. Replace netbox.example.com with your FQDN or IP_address.

server {
    listen 80;
    server_name netbox.example.com;
    client_max_body_size 25m;

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

    location / {
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;

Check the syntax of the file created.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Start and enable Nginx to run on boot.

sudo systemctl restart nginx
sudo systemctl enable nginx

Allow port 8001 on SELinux.

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

If you are using firewalld, allow the ports through the firewall.

sudo firewall-cmd --permanent --add-port={80,443}/tcp
sudo firewall-cmd --reload

7. Access the Netbox IPAM Tool Web UI

With everything configured accordingly, we are now set to access the Netbox IPAM web interface using the URL http://Hostname or http://IP_Address. You will be granted this page.

To make changes, you need to be logged in. Click “Log in” in the right corner. Enter the credentials created for the superuser account in step 2 above.

On successful login, you will be granted this window.

While here, you can navigate to the panel on the left side as below.

From the panel, you can add devices, connections, IPAM, clusters, circuits, power supply, and other options. This simply implies that with Netbox, one can fully manage a data center by adding the required devices here. For example, to add a device, you will be required to enter the information below.


That is it for now. I hope you found this guide on how to install and configure NetBox IPAM Tool on Rocky Linux 8 enjoyable.

That was a lot of learning! See more on this page.


Your Cart is Empty

Back To Shop