LibreNMS – A Fully Featured Network Monitoring Tool for Linux

LibreNMS is an open source, powerful and feature-rich auto-discovering PHP based network monitoring system which uses the SNMP protocol. It supports a broad range of operating systems including Linux, FreeBSD, as well as network devices including Cisco, Juniper, Brocade, Foundry, HP and many more.

LibreNMS Features:

  1. It auto-discovers a whole network using these protocols: CDP, FDP, LLDP, OSPF, BGP, SNMP and ARP.
  2. It has a mobile friendly Web UI, with customizable dashboards.
  3. Supports a Unix agent.
  4. Supports horizontal scaling to expand with your network.
  5. Supports a highly flexible and customizable alerting system; sends notifications through email, irc, slack and more.
  6. Supports an API for managing, graphing and retrieving data from your system.
  7. Offers a traffic billing system.
  8. Also supports an Android and iOS apps which offer core functionalities.
  9. Supports integration with NfSen, collectd, SmokePing, RANCID and Oxidized.
  10. Supports multiple authentication methods such as MySQL, HTTP, LDAP, Radius and Active Directory.
  11. Allows for auto updating and many other features.

An online demo is available for you to try before installing LibreNMS on Linux systems.

Demo URL:
Username: demo
Password: demo

Test Environment:

  1. Ubuntu 16.04 with LEMP Stack
  2. CentOS 7 with LEMP Stack

In this tutorial we will learn how to install LibreNMS Network Monitoring Tool on a freshly installed Ubuntu or CentOS Linux (same instructions also works on Debian and RHEL based distributions).

NOTE: All these instructions in this article should be run as the root user, if you are not, use the sudo command to gain root user privileges.

Step 1: Install Required Packages

1. First start by installing all the required packages using the default package manager as shown.

On Ubuntu/Debian

$ sudo apt install composer fping git graphviz imagemagick mariadb-client mariadb-server mtr-tiny nginx-full nmap php7.0-cli php7.0-curl php7.0-fpm php7.0-gd php7.0-mcrypt php7.0-mysql php7.0-snmp php7.0-xml php7.0-zip python-memcache python-mysqldb rrdtool snmp snmpd whois


# yum install epel-release
# rpm -Uvh
# yum install composer cronie fping git ImageMagick jwhois mariadb mariadb-server mtr MySQL-python net-snmp net-snmp-utils nginx nmap php72w php72w-cli php72w-common php72w-curl php72w-fpm php72w-gd php72w-mysql php72w-process php72w-snmp php72w-xml php72w-zip python-memcached rrdtool

2. Once all the packages are installed, nginx, php-fpm, mariadb and snmp services will be started and enabled to auto-start at boot time (this is normally the case with Ubuntu), otherwise, you can run the commands below to start and enable them.

------------ On Debian/Ubuntu ------------ $ sudo systemctl nginx start php7.0-fpm mysql snmp $ sudo systemctl enable nginx php7.0-fpm mysql snmp
------------ On CentOS/RHEL ------------ # systemctl nginx start php-fpm mariadb snmp # systemctl enable nginx php-fpm mariadb snmp

Step 2: Install LibreNMS Monitoring Tool

3. Next, create a system user called librenms, with the useradd command; where the -M flag disables creation of user’s home directory, and -r enables creating of a system account. Then add the librenms user to the group www-data (on Ubuntu) or nginx (on CentOS) as follows.

------------ On Debian/Ubuntu ------------ $ sudo useradd librenms -d /opt/librenms -M -r
$ sudo usermod -a -G librenms www-data ------------ On CentOS/RHEL ------------ # useradd librenms -d /opt/librenms -M -r
# usermod -a -G librenms nginx 

4. Then install LibreNMS via composer command as shown.

------------ On Debian/Ubuntu ------------ $ cd /opt
$ sudo composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master
------------ On CentOS/RHEL ------------ # cd /opt
# composer create-project --no-dev --keep-vcs librenms/librenms librenms dev-master

Step 3: Create LibreNMS Database

5. Before you can start using the MariaDB server, you need to secure your installation, run the security script provided in the binary package. It will ask you set a root password, remove anonymous users, disable root login remotely and remove test database.

You can launch the script by issuing the below command and answer all questions with yes/y.

$ sudo mysql_secure_installation [On Debian/Ubuntu]
# mysql_secure_installation [On CentOS/RHEL]

6. Then login to MariaDB database to create a database for LibreNMS (remember to use a strong/secure password in a production environment).

$ sudo mysql -u root -p
MariaDB [(none)]> CREATE DATABASE librenms CHARACTER SET utf8 COLLATE utf8_unicode_ci;
MariaDB [(none)]> CREATE USER 'librenms'@'localhost' IDENTIFIED BY '[email protected]!#@%$libre';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON librenms.* TO 'librenms'@'localhost';
MariaDB [(none)]> exit

7. Afterwards, disable MySQL strict mode for now (compatibility with MySQL strict mode is yet to be added).

$ sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf [On Debian/Ubuntu]
# vi /etc/my.cnf [On CentOS/RHEL]

Within the [mysqld] section please add.


Then restart the database server to effect the changes.

$ sudo systemctl restart mysql [On Debian/Ubuntu]
# systemctl restart mariadb [On CentOS/RHEL]

Step 4: Configure and Start PHP-FPM

8. Next, set your date.timezone in the php.ini to your current time zone, for example “Africa/Kampala”, as shown in the following screenshot.

------------ On Debian/Ubuntu ------------ $ sudo vim /etc/php/7.0/fpm/php.ini
$ sudo vim /etc/php/7.0/cli/php.ini
------------ On CentOS/RHEL ------------ # vi /etc/php.ini

Set Time Zone in PHP File

9. Next enable the mcrypt PHP module in Ubuntu and restart php-fpm as shown.

------------ On Debian/Ubuntu ------------ $ sudo phpenmod mcrypt
$ sudo systemctl restart php7.0-fpm

10. On CentOS/RHEL you need to make following changes in php-fpm configuration file.

# vi /etc/php-fpm.d/www.conf

Make following changes.

;user = apache
user = nginx
group = apache ; keep group as apache
;listen =
listen = /var/run/php-fpm/php7.2-fpm.sock
listen.owner = nginx = nginx
listen.mode = 0660

11. Restart php-fpm service as shown.

# systemctl restart php-fpm

Step 5: Configure Nginx for LibreNMS

12. In this step, you need to configure a Nginx server block for librenms in order to access the web UI. Create a .conf file for it as shown.

$ sudo vim /etc/nginx/conf.d/librenms.conf [On Debian/Ubuntu]
# vi /etc/nginx/conf.d/librenms.conf [On CentOS/RHEL] 

Add the following config, edit server_name as required.

server {
listen 80;
root /opt/librenms/html;
index index.php;
charset utf-8;
gzip on;
gzip_types text/css application/javascript text/javascript application/x-javascript image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location / {
try_files $uri $uri/ /index.php?$query_string;
location /api/v0 {
try_files $uri $uri/ /api_v0.php?$query_string;
location ~ \.php {
include fastcgi.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
location ~ /\.ht {
deny all;

13. Then save and exit the file. Also remove the default server block configuration and restart the Nginx server.

------------ On Debian/Ubuntu ------------ $ sudo rm /etc/nginx/sites-enabled/default
$ sudo systemctl restart nginx
------------ On CentOS/RHEL ------------ # systemctl restart nginx

NOTE: On CentOS/RHEL, you will need to disable the default site section, if this is the only site you are hosting. Delete the server section from /etc/nginx/nginx.conf file.

14. Also on CentOS/RHEL, you need to install the policy tool for SELinux and Configure the contexts needed by LibreNMS using following commands.

------------ On CentOS/RHEL ------------ # yum install policycoreutils-python
# semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/logs(/.*)?'
# semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/logs(/.*)?'
# restorecon -RFvv /opt/librenms/logs/
# semanage fcontext -a -t httpd_sys_content_t '/opt/librenms/rrd(/.*)?'
# semanage fcontext -a -t httpd_sys_rw_content_t '/opt/librenms/rrd(/.*)?'
# restorecon -RFvv /opt/librenms/rrd/
# setsebool -P httpd_can_sendmail=1
# setsebool -P httpd_execmem 1

15. Allow fping by creating the file with the following contents.


module http_fping 1.0;
require {
type httpd_t;
class capability net_raw;
class rawip_socket { getopt create setopt write read };
#============= httpd_t ==============
allow httpd_t self:capability net_raw;
allow httpd_t self:rawip_socket { getopt create setopt write read };

16. Then run these commands.

------------ On CentOS/RHEL ------------ # checkmodule -M -m -o http_fping.mod
# semodule_package -o http_fping.pp -m http_fping.mod
# semodule -i http_fping.pp

17. If you are using Firewall on CentOS/RHEL, enable HTTP/HTTPS access through firewall.

------------ On CentOS/RHEL ------------ # firewall-cmd --zone public --add-service http
# firewall-cmd --permanent --zone public --add-service http
# firewall-cmd --zone public --add-service https
# firewall-cmd --permanent --zone public --add-service https

Step 6: Configure SNMPD for LibreNMS

18. Now use the sample snmp configuration to create your configuration file and open it for editing, as follows.

------------ On Debian/Ubuntu ------------ $ sudo cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
$ sudo vim /etc/snmp/snmpd.conf
------------ On CentOS/RHEL ------------ # cp /opt/librenms/snmpd.conf.example /etc/snmp/snmpd.conf
# vi /etc/snmp/snmpd.conf

Find the string RANDOMSTRINGGOESHERE and change it to your own community string as shown in screenshot.

Set SNMP String

19. Next, download a shell script on your system, which helps to detect which OS and if it is Linux then it will detect which Linux distribution, you are using:

------------ On Debian/Ubuntu ------------ $ sudo curl -o /usr/bin/distro
$ sudo chmod +x /usr/bin/distro
$ sudo systemctl restart snmpd
------------ On CentOS/RHEL ------------ # curl -o /usr/bin/distro
# chmod +x /usr/bin/distro
# systemctl restart snmpd

Step 7: Create Cron and Configure Logrotate

20. Now run the command below to setup a cron job for LibreNMS.

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

21. Next, all LibreNMS logs are recorded in /opt/librenms/logs, you can need to configure these logs to be auto-rotated, using the logrotate config file provided, like this.

# cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

Then set the appropriate permissions on the LibreNMS installation root directory and log files.

------------ On Debian/Ubuntu ------------
$ sudo chown -R librenms:librenms /opt/librenms
$ sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs
$ sudo setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs
------------ On CentOS/RHEL ------------ # chown -R librenms:librenms /opt/librenms
# setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs
# setfacl -R -m g::rwx /opt/librenms/rrd /opt/librenms/logs

Step 8: Access LibreNMS Web Installer

22. Next, use the following URL to access the web installer and follow the on-screen instructions.


For this address to work on a local machine, you need to setup a local DNS using the hosts file (/etc/hosts), for local domain resolution or testing purposes before going live. tecmint.lan librenms.tecmint.lan

Setup Local DNS for Domain

23. You will see the installation welcome page as shown in the following screenshot, click Next Stage to continue.

LibreNMS Web Installer

24. Then enter the settings (database host, port, username and user password) for the LibreNMS database and click Next Stage to proceed.

LibreNMS Database Settings

25. The web installer will now start importing the MySQL database, this will take some time. Note that the process will try to pause at certain points, simple click on Retry to continue with the importation process.

LibreNMS Database Importing

26. Once the database importation is complete, you should see the message “Database is up to date!”, as shown in the screenshot below. Then click on Goto Add User to proceed.

LibreNMS Database Updated

27. Next, add a LibreNMS user, specify username, password and email, then click on Add User to effect the changes.

Add LibreNMS User

28. Now click on create the LibreNMS configuration for your system, by clicking Generate Config.

Generate Librenms Config

LibreNMS Configuration

29. Once the config is generated, as shown in the previous screenhot, copy it and save it in the root directory of your installation, in a file called /opt/librenms/config.php.

# vi /opt/librenms/config.php

LibreNMS Configuration

## Have a look in for examples of settings you can set here. DO NOT EDIT!
### Database config
$config['db_host'] = 'localhost';
$config['db_port'] = '3306';
$config['db_user'] = 'librenms';
$config['db_pass'] = '[email protected]!#@%$libre';
$config['db_name'] = 'librenms';
$config['db_socket'] = '';
// This is the user LibreNMS will run as
//Please ensure this user is created and has the correct permissions to your install
$config['user'] = 'librenms';
### Locations - it is recommended to keep the default
#$config['install_dir'] = "/opt/librenms";
### This should *only* be set if you want to *force* a particular hostname/port
### It will prevent the web interface being usable form any other hostname
#$config['base_url'] = "";
### Enable this to use rrdcached. Be sure rrd_dir is within the rrdcached dir
### and that your web server has permission to talk to rrdcached.
#$config['rrdcached'] = "unix:/var/run/rrdcached.sock";
### Default community
$config['snmp']['community'] = array("public");
### Authentication Model
$config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
#$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth
### List of RFC1918 networks to allow scanning-based discovery
#$config['nets'][] = "";
#$config['nets'][] = "";
#$config['nets'][] = "";
# Update configuration
#$config['update_channel'] = 'release'; # uncomment to follow the monthly release channel
#$config['update'] = 0; # uncomment to completely disable updates

30. Save and close the file. Then return to the web installer to continue with the installation process, by clicking Finish Install.

Finish LibreNMS Installation

31. Now your LibreNMS installation is complete, you can click on “validate your install and fix any issues”, the login page should appear.

Validate LibreNMS Install

32. Next, enter your user credentials to access the validation page.

LibreNMS Login Page

33. From the installation validation process, LibreNMS has discovered two issues, one is that devices have not been added (this is a warning for now), and secondly, we have not set the appropriate permission on the config file (/opt/librenms/config.php) which was manually added, as shown in the screen shot below.

LibreNMS Permission Issues

Now run the following command to set the correct permission on the config file.

$ sudo chown -R librenms:librenms /opt/librenms/config.php 

34. To add devices, go to: http://librenms.tecmint.lan/addhost. After adding devices, you can go to the home page and add various dashboards.

LibreNMS Dashboard

That’s It! You can find more information, including installation and setup on the LibreNMS Documentation at

LibreNMS is a fully featured network monitoring system that supports a variety of network hardware. We hope that this was a lucid installation guide, if you have any questions, reach us via the feedback form below.

Spread the love

Posted by News Monkey