Homepage of Lars E. Pettersson

SNMP setup

Goal

To set up a SNMP server to be used by mrtg and/or rrdtool.

Prerequisites

This little guide was written for Fedora Core 2, other versions of RedHat/Fedora Linux may differ.

Make sure that you have net-snmp and net-snmp-utils installed.

Start up script

I made a small change to the /etc/rc.d/init.d/snmpd startup file. The OPTIONS line was moved to /etc/sysconfig/snmpd (to get the same behavior as other packages.) I.e. I changed

OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd -a"
into
if [ -f /etc/sysconfig/snmpd ];then
    . /etc/sysconfig/snmpd
else
    OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd -a"
fi

in the /etc/rc.d/init.d/snmpd file. And the file /etc/sysconfig/snmpd was created with the contents

# Options to the snmpd daemon
#
# Setup to only listen on the local LAN and the loopback
#
OPTIONS="-Lsd -Lf /dev/null -p /var/run/snmpd -a 127.0.0.1 192.168.0.9"

As this particular machine has an interface connected to the hostile Internet, I have chosen to only activate the local LAN, and the loopback interfaces. These two addresses have been added to the OPTIONS parameter.

Initial setup

We will make use of a new configuration file, so move the original, and open a fresh configuration file with your favorite editor.

cd /etc/snmp
mv snmpd.conf snmpd.conf.original
emacs snmpd.conf &

Now add a read-only line by typing

syslocation Gothenburg
syscontact admin@test.org

# Read only for community called public
rocommunity public

Make sure that the daemon gets started on each reboot

chkconfig --level 345 snmpd on

Test the SNMP server

If not started, start the daemon with

/etc/rc.d/init.d/snmpd start
And then write
snmpwalk -v 2c -c public localhost system

You should get an answer, if not, check that the steps above have been done correctly