input license here

Instructions for installing netbox on ubuntu 20.04


What is Netbox?


NetBox is an infrastructure resource modeling (IRM) application designed to empower network automation. Originally conceived by a group of network engineers at DigitalOcean , NetBox was developed specifically to address the needs of network and infrastructure engineers. NetBox is provided as open source under the Apache 2 license.
The installation steps are like stars.
Bước 1 Install Database Postgresql
+Update and install Postgresql
#sudo apt update
#sudo apt install -y postgresql
+ Start and enable the postgresql service
#sudo systemctl start postgresql
#sudo systemctl enable postgresql
+Create a database for the netbox and assign it a username and password for authentication.
#sudo -u postgres psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD ‘bkns@123’;
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
Step 2 Install Redis
+
Install redis
#apt install redis-server -y
+Start and enable the redis-server service
#systemctl start redis-server
#systemctl enable redis-server
+Use the redis-cli utility to make sure the Redis service is up and running
#redis-cli ping
Step 3 Install and Configure NetBox
+
Create a base directory to install NetBox
#sudo mkdir -p /opt/netbox/
#cd /opt/netbox/
+If git is not installed, install it
#sudo apt install -y git
+Clone the master branch of the NetBox GitHub repository to the current directory
#git clone -b master https://github.com/netbox-community/netbox.git
+Create a system user named netbox.We will configure the WSGI and HTTP services to run under this account. We will also assign this user ownership of the media folder
#adduser –system –group netbox
#chown –recursive netbox /opt/netbox/netbox/media/
+Move into the NetBox configuration folder and make a copy of configuration.example.py name is, has a name which is configuration.py
#cd /opt/netbox/netbox/netbox/

#cp configuration.example.py configuration.py
+Create a symbolic link of the Python binary
#ln -s /usr/bin/python3 /usr/bin/python
+Generate a random SECRET_KEY of at least 50 alphanumeric characters
#/opt/netbox/netbox/generate_secret_key.p
+Open and edit files configure configuration.py
#nano /opt/netbox/netbox/netbox/configuration.py
You need to edit the following parameters
ALLOWED_HOSTS = [‘tên miền của các bạn’ , ‘ip của vps’]

(Note that the domain name must point to the ip of the vps to access it with the domain)
DATABASE = {
‘NAME’: ‘netbox’, # Database name you created
‘USER’: ‘netbox’, # PostgreSQL username you created
‘PASSWORD’: ‘bkns@123’, # PostgreSQL password you set
‘HOST’: ‘localhost’, # Database server
‘PORT’: ‘, # Database port (leave blank for default)
}
SECRET_KEY = ‘YOUR SECRET KEY’#Get it at the step of creating SECRET_KEY
Once NetBox has been configured, we are ready to proceed with the actual installation with the following command.
#/opt/netbox/upgrade.sh
+Import the Python virtual environment created by the upgrade script
#source /opt/netbox/venv/bin/activate
+Create superuser account using createuperuser
#cd /opt/netbox/netbox
python3 manage.py createsuperuser
+Output
Email address: admin@example.com
Password:
Password (again):
Superuser created successfully
Step 4 Gunicorn Puzzle
+NetBox provides a default configuration file for gunicorn. To use it, copy /opt/netbox/contrib/gunicorn.py sang /opt/netbox/gunicorn.py
#cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py
+Copy Contrib /netbox.service and Contrib /netbox-rq.service go to folder /etc/systemd/system / and reload dameon systemd
#cp -v /opt/netbox/contrib/*.service /etc/systemd/system/
#systemctl daemon-reload
+Start up and activate the service netbox-rq
#systemctl start netbox netbox-rq
#systemctl enable netbox netbox-rq
Step 5 Set up an HTTP server
+
Get ssl . certificate
#sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048
-keyout /etc/ssl/private/netbox.key
-out /etc/ssl/certs/netbox.crt
Install Nginx web server using the following command
#apt install -y nginx
+Copy nginx configuration file provided by NetBox /etc/nginx/sites-available/netbox
#cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox
+Edit netbox config file and delete all content and copy paste below content
#nano /etc/nginx/sites-available/netbox
server {
listen 80;
server_name 127.0.0.1;#Replace it with your ip address
client_max_body_size 25m;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
+Then delete /etc/nginx/sites-enabled/default and create a symlink in the directory containing the configuration file you just created
#rm /etc/nginx/sites-enabled/default
#ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox
+Now check Nginx configuration and restart Nginx service
#nginx -t
#systemctl restart nginx
Step 6 If you turn on the firewall, you should allow IP and Port to be able to access the netbox service
+Allow port 8000 and ip of server on ufw firewall on ubuntu
#ufw allow 8000/tcp
#ufw allow from “your IP server”











Related Posts
Diệp Quân
Nguyen Manh Cuong is the author and founder of the vmwareplayerfree blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.
SHARE

Related Posts

Subscribe to get free updates

Post a Comment

Sticky