-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebian_netbox_install.txt
More file actions
133 lines (103 loc) · 3.5 KB
/
Debian_netbox_install.txt
File metadata and controls
133 lines (103 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
=== Debian 12 ===
su -l
apt update -y
apt upgrade -y
apt install sudo
usermod -aG sudo user
! logout
sudo apt install -y net-tools
sudo apt -y install -y git gcc nginx redis supervisor python3 python3-dev python3-venv python3-pip python3-setuptools build-essential libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev zlib1g-dev vim
sudo apt install -y postgresql libpq-dev
sudo apt -y install postgresql-contrib postgresql-*-ip4r
sudo -u postgres psql
---
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'admin';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
ALTER DATABASE netbox OWNER TO netbox;
\q
---
! verify
psql -U netbox -h localhost -W
netbox=> \conninfo
\q
sudo apt install redis-server -y
sudo systemctl is-enabled redis-server
sudo systemctl status redis-server
redis-cli ping
# sudo vi /etc/redis/redis.conf
# ---
# requirepass admin
# ---
#
# sudo systemctl restart redis-server
# redis-cli
# AUTH admin
sudo apt install -y git
cd /opt/
sudo git clone -b master https://github.com/netbox-community/netbox.git
sudo adduser --system --group netbox
sudo usermod -aG sudo netbox
sudo chown --recursive netbox /opt/netbox/
cd /opt/netbox/netbox/netbox/
sudo cp configuration_example.py configuration.py
python3 ../generate_secret_key.py
! save SECRET_KEY and add into file
sudo vi configuration.py
===
ALLOWED_HOSTS = ['*'] or ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
DATABASE = {
'NAME': 'netbox', # Database name
'USER': 'netbox', # PostgreSQL username
'PASSWORD': 'admin', # PostgreSQL password
'HOST': 'localhost', # Database server
'PORT': '', # Database port (leave blank for default)
'CONN_MAX_AGE': 300, # Max database connection age (seconds)
}
! seach in file and change !
SECRET_KEY = 'FHRO%lUpbGEL_)wfI4p-HE=7EL%VI&ylU&_ZXjP6*tSWV^2EfH'
===
sudo -u netbox /opt/netbox/upgrade.sh
source /opt/netbox/venv/bin/activate
cd /opt/netbox/netbox
python3 manage.py createsuperuser
admin/admin
! check
cd /opt/netbox/netbox
source /opt/netbox/venv/bin/activate
python3 manage.py runserver 0.0.0.0:8000 --insecure ! You should be greeted with the NetBox home page
source /opt/netbox/venv/bin/activate
cd /opt/netbox/netbox
pip3 install gunicorn
sudo cp /opt/netbox/contrib/gunicorn.py /opt/netbox/gunicorn.py
sudo cp -v /opt/netbox/contrib/*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl start netbox netbox-rq
sudo systemctl enable netbox netbox-rq
systemctl status netbox.service
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /etc/ssl/private/netbox.key \
-out /etc/ssl/certs/netbox.crt
sudo cp /opt/netbox/contrib/nginx.conf /etc/nginx/sites-available/netbox
sudo vi /etc/nginx/sites-available/netbox
---
server {
# CHANGE THIS TO YOUR SERVER'S NAME
server_name 192.168.x.x;
---
deactivate
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/netbox /etc/nginx/sites-enabled/netbox
sudo systemctl restart nginx
systemctl status netbox
systemctl status nginx
!LDAP
apt install -y libldap2-dev libsasl2-dev libssl-dev
source /opt/netbox/venv/bin/activate
pip3 install django-auth-ldap
echo django-auth-ldap >> /opt/netbox/local_requirements.txt
cd /opt/netbox/netbox/netbox/
vi configuration.py
REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend'
! debug
journalctl -xef -u netbox.service