How to Install NetBox on Ubuntu 18.04 LTS is the heading of our article today. NetBox is an open source IPAM / DCIM web application used for managing and documenting computer networks and managing IP addresses. It was Initially conceived by the network engineering team at DigitalOcean.
Netbox encompasses the following aspects of network management:
- IP address management (IPAM) – IP networks and addresses, VRFs, and VLANs
- Equipment racks – Organized by group and site
- Devices – Types of devices and where they are installed
- Connections – Network, console, and power connections among devices
- Virtualization – Virtual machines and clusters
- Data circuits – Long-haul communications circuits and providers
- Secrets – Encrypted storage of sensitive credentials
If you’re interested in deploying Netbox on CentOS 7, check:
Install NetBox on Ubuntu 18.04 LTS
This section will discuss the actual steps you need to follow to have NetBox installed on your Ubuntu 18.04 LTS server. Follow them in order of the appearance, though you can skip a part if you have the software being installed already configiured.
Step 1: Install required dependencies
Start by installing all dependency applications required to run NetBox on Ubuntu 18.04 LTS.
sudo apt-get update
sudo apt-get install -y git gcc nginx redis supervisor python3 python3-dev python3-pip python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev zlib1g-devStep 2: Install and configure PostgreSQL database server
NetBox uses PostgreSQL database server to store its data. So install and configure it on Ubuntu 18.04 using our previous guide below:
Then Create a database and user for NetBox.
$ sudo -u postgres psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'StrongPassword';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\qConfirm that you can login to database as netbox user.
# psql -U netbox -h localhost -W
Password:
psql (11.1 (Ubuntu 11.1-1.pgdg18.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
netbox=> Step 3: Install and configure Netbox
Change to /opt/ directory
cd /opt/
sudo git clone -b master https://github.com/digitalocean/netbox.gitCreate a configuration file
cd netbox/netbox/netbox/
sudo cp configuration.example.py configuration.pyEdit the configuration file and set allowed host and database login details
# Example: ALLOWED_HOSTS = ['netbox.example.com', 'netbox.internal.local']
ALLOWED_HOSTS = ['localhost']
# PostgreSQL database configuration.
DATABASE = {
'NAME': 'netbox', # Database name
'USER': 'netbox', # PostgreSQL username
'PASSWORD': 'StrongPassword', # PostgreSQL password
'HOST': 'localhost', # Database server
'PORT': '', # Database port (leave blank for default)
}Generate Django SECRET Key:
cd /opt/netbox/netbox
sudo ./generate_secret_key.pyThen set the key on the file /opt/netbox/netbox/netbox/configuration.py
Example:
$ sudo vim /opt/netbox/netbox/netbox/configuration.py
SECRET_KEY = '30m&[email protected]=^l8wqtjw2$!3j%=f2!zh_sey+13jg%3$'Install Netbox dependencies
sudo pip3 install -r /opt/netbox/requirements.txtMigrate database data:
cd /opt/netbox/netbox/
sudo python3 manage.py migrateSample output for database migration.
Applying circuits.0014_circuittermination_description... OK
Applying dcim.0067_device_type_remove_qualifiers... OK
Applying dcim.0068_rack_new_fields... OK
Applying tenancy.0004_tags... OK
Applying tenancy.0005_change_logging... OK
Applying extras.0001_initial_squashed_0010_customfield_filter_logic... OK
Applying extras.0011_django2... OK
Applying extras.0012_webhooks... OK
Applying extras.0013_objectchange... OK
Applying extras.0014_configcontexts... OK
Applying extras.0015_remove_useraction... OK
Applying extras.0016_exporttemplate_add_cable... OK
Applying ipam.0021_vrf_ordering... OK
Applying ipam.0022_tags... OK
Applying ipam.0023_change_logging... OK
Applying secrets.0001_initial_squashed_0003_unicode_literals... OK
Applying secrets.0004_tags... OK
Applying secrets.0005_change_logging... OK
Applying sessions.0001_initial... OK
Applying users.0001_api_tokens_squashed_0002_unicode_literals... OK
Applying users.0003_token_permissions... OK
Applying virtualization.0002_virtualmachine_add_status_squashed_0004_virtualmachine_add_role... OK
Applying virtualization.0005_django2... OK
Applying virtualization.0006_tags... OK
Applying virtualization.0007_change_logging... OK
Applying virtualization.0008_virtualmachine_local_context_data... OK
Create admin user:
$ sudo python3 manage.py createsuperuser
Username (leave blank to use 'root'): admin
Email address: [email protected]
Password: <Enter Password>
Password (again): <Re-enter Password>
Superuser created successfully.Move static files
$ cd /opt/netbox/netbox
$ sudo python3 manage.py collectstatic
280 static files copied to '/opt/netbox/netbox/static'.Step 4: Install and Configure gunicorn
Install gunicorn using pip3:
$