How to Install NetBox on Debian Latest?
NetBox is an open-source web application used for managing and tracking IP addresses, network devices, and infrastructure. In this tutorial, we will guide you through the process of installing NetBox on a Debian latest operating system.
1. Prerequisites
Before proceeding with the installation, it is best to check if your Debian system is up-to-date. Run the following commands to update the index of available packages and upgrade your existing packages:
sudo apt update
sudo apt upgrade
After updating, we need to install some required packages for NetBox to run successfully. Use the following command:
sudo apt install python3 python3-pip python3-venv python3-dev build-essential libxml2 libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libpq-dev git
2. Install NetBox
We will download the NetBox source code from the official Github repository by issuing the following commands:
git clone https://github.com/digitalocean/netbox.git
cd netbox/
Once you are in the NetBox directory, create and activate a new Python virtual environment for NetBox using the following commands:
python3 -m venv venv
source venv/bin/activate
Next, install Python dependencies for NetBox by running:
pip3 install -r requirements.txt
3. Configure NetBox
We need to configure some settings to enable NetBox to connect to the database. For this, we will create a configuration file by making a copy of the netbox/netbox/configuration.example.py file:
cp netbox/netbox/configuration.example.py netbox/netbox/configuration.py
Next, open the netbox/netbox/configuration.py file in your preferred text editor and set the following database settings:
DATABASE = {
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'your-password-here',
'HOST': '127.0.0.1',
'PORT': '',
'CONN_MAX_AGE': 300,
'ENGINE': 'django.db.backends.postgresql',
}
Replace the database name, username, and password with your own.
4. Prepare the Database
We created a configuration file in the previous step. Now, we need to prepare the database for NetBox's initial use. Run the following commands to create a new PostgreSQL database:
sudo -u postgres psql -c "CREATE DATABASE netbox;"
sudo -u postgres psql -c "CREATE USER netbox WITH PASSWORD 'your-password-here';"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;"
sudo -u postgres psql -c "ALTER USER netbox CREATEDB;"
5. Apply Initial Configuration
Before running NetBox, we need to Apply the initial database migrations using the following commands:
./manage.py migrate
After the migrations are applied, we need to create a superuser account:
./manage.py createsuperuser
You will be prompted to enter your credentials to create your superuser account.
6. Run NetBox
Finally, run the following command to start NetBox:
./manage.py runserver 0.0.0.0:8000
Now you can access the NetBox web application by visiting http://server-ip:8000/ in your browser.
Conclusion
In this tutorial, we explained how to install NetBox on a Debian latest operating system. By now, you should have successfully installed and started NetBox, and you can start using it to manage and track IP addresses, network devices, and infrastructure.