How to Install LibreNMS on Kali Linux Latest

LibreNMS is an open-source network monitoring tool that provides comprehensive network monitoring features. In this tutorial, we will guide you through the steps to install LibreNMS on Kali Linux Latest.

Prerequisites

  • Kali Linux Latest installed on your system
  • Sudo access or root privileges
  • Internet connectivity

Step 1: Update System Packages

Before installing any software, it is important to update the package list in the system. Use the following command to update the package list:

sudo apt-get update

Step 2: Install Required Dependencies

LibreNMS requires certain dependencies to be installed in the system for its proper functioning. Use the following command to install the dependencies:

sudo apt-get install -y apache2 libapache2-mod-php7.4 php7.4-cli php7.4-mysql php7.4-gd php7.4-json php7.4-ldap php7.4-mbstring php7.4-snmp php7.4-curl snmp fping mariadb-server mariadb-client python-mysqldb rrdtool git curl

Step 3: Configure MariaDB

LibreNMS requires a database to store its data. In this step, we will configure MariaDB for LibreNMS. Use the following commands to complete this step:

sudo systemctl start mariadb
sudo mysql_secure_installation
  • The first command starts the MariaDB service.
  • The second command creates a root password for the MariaDB server and sets up some security measures.

After this step is completed, you will be prompted to enter MariaDB root password.

Note: If you face any issues, you can refer to the official MariaDB documentation.

Step 4: Create a Database for LibreNMS

Next, we will create a new database and user for LibreNMS. Use the following commands to complete this step:

sudo mysql -u root -p

Enter the MariaDB root password when prompted.

CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'librenms'@'localhost' IDENTIFIED BY '<your-password>';
GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
FLUSH PRIVILEGES;
exit;
  • The first command will open the MariaDB command-line interface.
  • The second command creates a new database named ‘librenms’.
  • The third command creates a new user named ‘librenms’ with a password of your choice.
  • The fourth command grants all the privileges to the user for the ‘librenms’ database.
  • The last command flushes the privileges.

Step 5: Install and Configure LibreNMS

Use the following commands to download and install LibreNMS:

sudo mkdir -p /opt/librenms
sudo chown -R www-data:www-data /opt/librenms
cd /opt
sudo git clone https://github.com/librenms/librenms.git librenms
cd librenms
sudo cp .env.examples .env
sudo sed -i 's/MYSQL_USERNAME=librenms/MYSQL_USERNAME=root/g' .env
sudo sed -i 's/MYSQL_PASSWORD=/MYSQL_PASSWORD=<your-password>/g' .env
  • The first command creates a new directory ‘librenms’ in the ‘opt’ directory.
  • The second command sets the owner and group of the directory to ‘www-data’.
  • The third command changes the directory to the ‘librenms’ directory.
  • The fourth command copies the ‘.env.examples’ file to ‘.env’ file.
  • The fifth command replaces the ‘MYSQL_USERNAME’ from ‘librenms’ to ‘root’.
  • The sixth command replaces the ‘MYSQL_PASSWORD’ with a password of your choice.

After running these commands, open the .env file in any text editor and modify the SNMP community string, time zone, and hostname according to your preferences.

Step 6: Configure Apache Virtual Host

Next, we will configure the virtual host for Apache. Use the following commands:

sudo cp /opt/librenms/librenms.nonssl.conf /etc/apache2/sites-available/librenms.conf
sudo ln -s /etc/apache2/sites-available/librenms.conf /etc/apache2/sites-enabled/
sudo a2enmod rewrite
sudo systemctl restart apache2
  • The first command copies the configuration file ‘librenms.nonssl.conf’ to ‘/etc/apache2/sites-available’ directory.
  • The second command creates a symbolic link between the ‘sites-available’ and ‘sites-enabled’ directories.
  • The third command enables the ‘rewrite’ module.
  • The fourth command restarts Apache service.

Step 7: Configure Cron Job

LibreNMS requires a cron job to update the network devices data. Use the following command to configure the cron job:

sudo cp /opt/librenms/librenms.nonroot.cron /etc/cron.d/librenms

Step 8: Verify Installation

Finally, open your web browser and access the URL ‘http://localhost/librenms/install.php’. Follow the on-screen instructions and provide the details like database name, user, and password, etc., on the ‘Settings’ page. After completing all the steps, remove the ‘install.php’ file from the document root.

sudo rm /opt/librenms/public/install.php

Now you can access the LibreNMS dashboard at ‘http://localhost/librenms’.

Conclusion

We have successfully installed and configured LibreNMS on Kali Linux Latest. You can now monitor your network with the help of LibreNMS.