Packetwatch.net

Net-SNMP in OpenBSD



Last modified: Oct. 20, 2008

Contents
1 - Summary
2 - Net-SNMP installation
3 - Service configuration
4 - Snmpwalk example
5 - Service check


1 - Summary

This guide will show you how to install net-snmp in OpenBSD. This has been
tested in OpenBSD 4.3.


2 - Net-SNMP installation

Update the ports tree using cvsup. Now, install the net-snmp port.
# sudo cvsup -g -L 2 /usr/local/etc/cvsup/sup/ports-supfile
# cd /usr/ports/net/net-snmp
# sudo make
# sudo make install
# sudo make clean


3 - Service configuration

Find where the net-snmp daemon was installed to.
# pkg_info -L net-snmp-5.4.1p0 | grep sbin
/usr/local/sbin/snmpd
/usr/local/sbin/snmptrapd

Edit /etc/rc.local so that net-snmp will start when the system starts up.
Somewhere in the file add the following.

  if [ -x /usr/local/sbin/snmpd ]; then
          echo -n ' snmpd';       /usr/local/sbin/snmpd -a -p /var/run/snmpd.pid
  fi

# sudo vi /etc/rc.local

According to the installation notes the configuration file that net-snmp will
use is located at /etc/snmp/snmpd.conf. You can create your own configuration
file. Here is a simple example.

  rocommunity public 127.0.0.1

# sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.original
# sudo vi /etc/snmp/snmpd.conf

Start the net-snmp service.
# sudo /usr/local/sbin/snmpd -a -p /var/run/snmpd.pid
# sudo cat /var/run/snmpd.pid
27274


4 - Snmpwalk example

Run snmpwalk to view the SNMP tree. This example displays the system
description.
# snmpwalk -v 2c -c public localhost system | grep sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: OpenBSD server.test.com 4.3 GENERIC#698 i386


5 - Service check

Reboot your computer. Log in like normal and check to see that the net-snmp
service is running. That's it, now you have net-snmp running in OpenBSD.
# sudo shutdown -r now
# sudo ls -1 /var/run/snmpd.pid
/var/run/snmpd.pid
# sudo cat /var/run/snmpd.pid
12830


Last modified: Wed Dec 31 19:00:00 1969 EST
Packetwatch Research 2002-2008.