Packetwatch.net

Net-SNMP in FreeBSD



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 FreeBSD. This has been
tested in FreeBSD 7.0.


2 - Net-SNMP installation

Install the net-snmp package from an FreeBSD FTP mirror server.
# sudo setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.0-release/All/
# sudo pkg_add -r net-snmp-5.3.1_7.tbz


3 - Service configuration

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

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

  snmpd_enable="YES"
  snmpd_flags="-a"
  snmpd_pidfile="/var/run/snmpd.pid"
  snmpd_conffile="/etc/snmpd.conf"

# sudo vi /etc/rc.conf.local

According to the installation notes the configuration file that net-snmp will
use is located at /etc/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-5.3.1_7 | grep snmpd.conf
/usr/local/man/man5/snmpd.conf.5.gz
/usr/local/share/snmp/snmpd.conf.example
# sudo cp /usr/local/share/snmp/snmpd.conf.example /etc/snmpd.conf
# sudo cp /etc/snmpd.conf /etc/snmpd.conf.example
# sudo chmod u+w /etc/snmpd.conf
# sudo vi /etc/snmpd.conf

Start the net-snmp service.
# sudo /usr/local/etc/rc.d/snmpd start
Starting snmpd.
# sudo cat /var/run/snmpd.pid
882


4 - Snmpwalk example

Run snmpwalk to view the SNMP tree. This example displays the system
description.
# /usr/local/bin/snmpwalk -v 2c -c public localhost system | grep sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: FreeBSD server.test.com 7.0-RELEASE
FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008
root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC 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 FreeBSD.
# sudo shutdown -r now
# sudo ls -1 /var/run/snmpd.pid
/var/run/snmpd.pid
# sudo cat /var/run/snmpd.pid
581


Last modified: Thu Jan 1 12:00:00 1970 NZST
Packetwatch Research 2002-2010.