Packetwatch.net

Net-SNMP in OpenBSD



Last modified: Dec. 6, 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 and 4.4.


2 - Net-SNMP installation

Install the net-snmp package from an OpenBSD FTP mirror server.
# sudo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$rel/packages/$arch/
# sudo pkg_add net-snmp-*.tgz


3 - Service configuration

Find where the net-snmp daemon was installed to.
# pkg_info -L net-snmp-* | 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 -Lsd -Lf /dev/null -p /var/run/snmpd.pid
  fi

# sudo vi /etc/rc.local

Find where the configuration file should be put.
# strings /usr/local/sbin/snmpd | grep snmpd.conf 

You can create your own configuration file. Here is a simple example.

  rocommunity public 127.0.0.1

# pkg_info -L net-snmp-* | grep snmpd.conf
/usr/local/man/man5/snmpd.conf.5
# sudo cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.example
# sudo vi /etc/snmp/snmpd.conf

Start the net-snmp service.
# sudo /usr/local/sbin/snmpd -a -Lsd -Lf /dev/null -p /var/run/snmpd.pid
# sudo cat /var/run/snmpd.pid
6940


4 - Snmpwalk example

Run snmpwalk to view the SNMP tree. This example displays the system
description.
# snmpwalk -c public -OQ -Os -Ov -v 2c localhost sysDescr.0 
OpenBSD server.test.com 4.4 GENERIC#1021 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
27733


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.