Last Updated on 4 weeks by Sachin G

​MRTG (Multi Router Traffic Grapher) is a reliable and lightweight tool for Linux servers’ network traffic monitoring. I had to set up MRTG on both CentOS and RHEL for a legacy environment where simplicity and SNMP-based interface traffic stats were more important than dashboards or APIs.The tech article provides steps for install MRTG on Linux and setting up the Multi Router Traffic Grapher (MRTG) on various Linux distributions. It outlines the necessary steps, including installing the EPEL repository, updating package repositories, installing the Apache web server, and configuring SNMP.

Why Use MRTG for Linux Bandwidth Graphing?

MRTG is still quite useful for visual network utilization in lightweight environments. It generates HTML graphs using data collected via SNMP configuration and presents them in a format that’s easy to read—even for less experienced admins. In small and medium-sized setups where full-stack monitoring is overkill, MRTG strikes the right balance between visibility and simplicity.

Learn Smarter. Level Up Faster →

Want to master Linux, DevOps, Ansible, or Cloud workflows the smart way? I’ve curated a list of top-rated, real-world Udemy courses — based on student reviews and practical feedback.

Visit the Recommended Courses page to explore and enroll in courses trusted by the community.

See Curated Courses →

Installing MRTG on CentOS, RHEL, and Fedora

Here’s the exact method I used:

STEP 1: Install EPEL Repository

Click on the link below and install the EPEL repository according to your operating system.

Setup EPEL YUM Repositories on CentOS RHEL Fedora Linux

STEP 2:  Update Package Repositories:

Make sure your system’s package repositories are up to date by running the following commands:

Here we are creating a basic installation of the Apache web server.

STEP 3:  Install the Apache web server and enable the service

sudo dnf -y install httpd

You will need to start Apache if it’s not already running:

sudo systemctl enable httpd --now

STEP 4:  Install MRTG through YUM

The command below is for the mrtg and snmp installation utility and dependency.

sudo dnf install mrtg net-snmp net-snmp-utils 

On Fedora, the package names are the same, though you may encounter newer versions due to Fedora’s faster release cycle. This article serves as an MRTG setup tutorial for Fedora Linux as well, with only minor changes in file locations.

STEP 5: Configure SNMP 

To monitor network interface and other resources like CPU, memory, we should configure snmpd “/etc/snmp/snmpd.conf”. Here’s a basic /etc/snmp/snmpd.conf Snippet I often use:

rocommunity public
syslocation ServerRoom
syscontact admin@example.com

And check the settings below also.

(A) Comment the line with a hash on line number approx 41 like below.

# com2sec notConfigUser default public

(B) Uncomment these lines and remove NETWORK/24 and replace it with your network.

Before changes

#com2sec local localhost COMMUNITY
#com2sec mynetwork NETWORK/24 COMMUNITY
After Changes 
com2sec local localhost techtransit
com2sec mynetwork 172.24.0.0/24 techtransit

(C) Uncomment the lines below. Replace techtransit with any word.

group MyRWGroup v2c local
group MyROGroup v2c mynetwork

(D) Uncomment the line.

view all included  .1  80

(E) Uncomment these lines below if persistent. Replace techtransit with your name.

access MyROGroup "" v2c noauth 0 all none none
access MyRWGroup "" v2c noauth 0 all all all

STEP 6: Start the snmpd service and enable it from autoboot.

sudo systemctl start snmpd.service

sudo systemctl enable snmpd.service

STEP 7: To test that SNMP is working:

This command helps ensure your SNMP daemon on Linux is running properly.

show status (replace the “techtransit” with your community name)

[root@server ~]# snmpwalk -v2c -c techtransit localhost system
SNMPv2-MIB::sysDescr.0 = STRING: Linux server.techtransit.org 3.10.0-229.14.1.el7.x86_64 #1 SMP Tue Sep 15 15:05:51 UTC 2015 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (8004) 0:01:20.04
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
SNMPv2-MIB::sysName.0 = STRING: server.techtransit.org
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORID.1 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.9 = OID: SNMP-NOTIFICATION-MIB::snmpNotifyFullCompliance
SNMPv2-MIB::sysORID.10 = OID: NOTIFICATION-LOG-MIB::notificationLogMIB
SNMPv2-MIB::sysORDescr.1 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.2 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.3 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORDescr.9 = STRING: The MIB modules for managing SNMP Notification, plus filtering.
SNMPv2-MIB::sysORDescr.10 = STRING: The MIB module for logging SNMP Notifications.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.9 = Timeticks: (2) 0:00:00.02
SNMPv2-MIB::sysORUpTime.10 = Timeticks: (2) 0:00:00.02

Creating the MRTG Configuration File

MRTG includes a tool called cfgmaker to auto-generate the MRTG configuration file. Now we will create a configuration file for MRTG data storage, run the command below, and the output will be redirected to the MRTG configuration file. Replace your community name and ip of your server. You can also change WorkDir.

cfgmaker --snmp-options=:::::2 --ifref=descr --ifdesc=descr --global 'WorkDir: /var/www/html/mymrtg' techtransit@172.24.0.69 > /etc/mrtg/mrtg.cfg

If you want the graph data in bits instead of bytes, uncomment the lines below from /etc/mrtg/mrtg.cfg configuration file.

vim /etc/mrtg/mrtg.cfg

Options[_]: growright, bits

Uncomment the below line, which should be on line approx 75, and save and exit from the configuration file.

Target[172.24.0.69_eth0]: \eth0:techtransit@172.24.0.69:::::2
noHC[172.24.0.69_eth0]: yes
SetEnv[172.24.0.69_eth0]: MRTG_INT_IP="172.24.0.69" MRTG_INT_DESCR="eth0"
MaxBytes[172.24.0.69_eth0]: 250000000
Title[172.24.0.69_eth0]: eth0 -- server.techtransit.org
PageTop[172.24.0.69_eth0]: <h1>eth0 -- server.techtransit.org</h1>
Create Index File on mrtg document root through below command.
indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /var/www/html/mymrtg/index.html

You’ll want to run the last command at least three times to populate the RRD (Round Robin Database) and graphs.
Now, MRTG is configured in Apache configuration file.

Edit the mrtg apache configuration file.

#vim /etc/httpd/conf.d/mrtg.conf

Edit the file as below, change the ip with your ip .

Alias /mrtg /var/www/html/mymrtg

<Location /var/www/html/mymrtg>
Require local
Require ip 172.24.0.69
# Require host example.org
</Location>

Start Apache :

#systemctl start httpd.service

To make the graphs update automatically every 5 minutes, add a cron job

*/5 * * * * /usr/bin/env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

Now the configuration has been done, and the access URL for Graph will be as below.

Accessing MRTG Graphs

Once configured, you can view your graphs by visiting:

http://server-hostname or http://your-server-ip/mrtg/

If you’re wondering where MRTG graph files are stored in Linux, they’re typically in /var/www/html/mrtg/.

In my case, this setup provided clear bandwidth data for multiple interfaces and was extremely useful for system performance monitoring during peak hours.

Monitoring Multiple Interfaces and Remote Devices

The common query: Can MRTG monitor traffic on multiple network interfaces? — Yes, MRTG supports this out of the box if SNMP exposes those interfaces. You can include them in your config using cfgmaker, or manually edit the .cfg file.

Can MRTG monitor remote servers via SNMP? — Absolutely. As long as SNMP is enabled on the remote system and accessible from your monitoring host, MRTG will work .

Frequently Asked Questions (FAQ)

1. How does MRTG compare to other tools like Cacti or Zabbix?

MRTG is more lightweight and easier to configure than Cacti or Zabbix. It doesn’t require a database and uses static HTML output, which is great for resource-limited servers or when simplicity is key.

2. What ports need to be open for MRTG and SNMP to function?

MRTG itself serves graphs over HTTP (usually port 80), while SNMP operates over UDP port 161. Make sure these are open in your firewall or network security groups.

3. Where can I find detailed logs or errors if MRTG isn’t working?


Logs for MRTG are usually written to /var/log/mrtg/mrtg.log to your system’s cron logs. Use tail -f or journalctl to view real-time issues during setup.