https://netbox.readthedocs.io/en/stable/installation/3-netbox/
Install netbox from port
portmaster -d net-mgmt/netbox sysutils/py-supervisor databases/redis databases/postgresql14-server www/nginx net-mgmt/py-napalm
Setup DB
/usr/local/etc/rc.d/postgresql initdb --no-locale --encoding=UTF8
service postgresql start
su postgres
psql
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
Config Netbox
python3.9 /usr/local/share/netbox/generate_secret_key.py
cd /usr/local/share/netbox/netbox/
cp configuration.example.py configuration.py
vi /usr/local/share/netbox/netbox/configuration.py
ALLOWED_HOSTS =
DATABASE =
SECRET_KEY =
Create DB
cd /usr/local/share/netbox
python3.9 manage.py migrate
python3.9 manage.py createsuperuser
python3.9 manage.py collectstatic --no-input
Netbox service
cp /usr/local/share/examples/netbox/netboxrc.sample /usr/local/etc/rc.d/netbox
chmod 555 /usr/local/etc/rc.d/netbox
vi /usr/local/etc/supervisord.conf
[program:netbox-rqworker]
command = /usr/local/bin/python3.9 /usr/local/share/netbox/manage.py rqworker
directory = /opt/netbox/
user = nobody
Enable upload media file
chmod -R 777 /usr/local/share/netbox/media/
Config Nginx
https://github.com/netbox-community/netbox/blob/develop/contrib/nginx.conf
vi /usr/local/etc/nginx/nginx.conf
#
client_max_body_size 25m;
location /static/ {
alias /usr/local/share/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;
}
}
Start server
vi /etc/rc.conf
redis_enable="YES"
postgresql_enable="YES"
netbox_enable="YES"
netbox_bind="localhost:8001"
netbox_workers="2"
netbox_threads="1"
nginx_enable="YES"
supervisord_enable="YES"
service redis start
redis-cli ping
service postgresql start
service supervisord start
service netbox start
service nginx start
Netbox from github
Download
mkdir -p /opt/netbox/ && cd /opt/netbox/
pkg install git
git clone -b master https://github.com/netbox-community/netbox.git .
Upgarde
cd /opt/netbox/
git fetch --all
git reset --hard origin/master
Add netbox user
adduser netbox
chown -R netbox /opt/netbox/netbox/media/
Install
cd /opt/netbox
pip install -r requirements.txt
pip install napalm
cp /usr/local/share/netbox/netbox/configuration.py /opt/netbox/netbox/netbox/configuration.py
Upgrade DB
cd /opt/netbox/netbox/
python3.9 manage.py migrate
python3.9 manage.py createsuperuser
Update static file
vi /opt/netbox/netbox/netbox/settings.py
STATIC_ROOT = '/usr/local/share/netbox/static'
cd /opt/netbox/netbox/
python3.9 manage.py collectstatic --no-input
Test run
python3.9 manage.py runserver 0.0.0.0:8001 --insecure
Install service
vi /usr/local/etc/rc.d/netbox
netbox_path=/opt/netbox/netbox
vi /usr/local/etc/supervisord.conf
[program:netbox-rqworker]
command = /usr/local/bin/python3.9 /opt/netbox/netbox/manage.py rqworker
directory = /opt/netbox/netbox/
user = netbox
Install plugin
Example https://github.com/iDebugAll/nextbox-ui-plugin
Install
pip install nextbox-ui-plugin
Config
vi /opt/netbox/netbox/netbox/configuration.py
PLUGINS = [
'nextbox_ui_plugin',
]
PLUGINS_CONFIG = {
'nextbox_ui_plugin': {
'layers_sort_order': (
'undefined',
'edge-switch',
'edge-router',
'firewall',
'core-router',
'core-switch',
'distribution-router',
'distribution-switch',
'leaf',
'spine',
'access-switch',
),
'icon_role_map': {
'edge-switch': 'switch',
'edge-router': 'router',
'core-router': 'router',
'core-switch': 'switch',
'distribution-router': 'router',
'distribution-switch': 'switch',
'leaf': 'switch',
'spine': 'switch',
'access-switch': 'switch',
'firewall': 'firewall',
}
}
}