Last modified: Oct. 29, 2010

1 - Summary
2 - Dependencies
3 - Service configuration
4 - Snmpget example
5 - Service check

1 - Summary

This guide will show how to install SNMP in FreeBSD. SNMP is a network protocol
used to monitor network devices. FreeBSD includes BSNMP in the base install.
This has been tested in FreeBSD 8.1.

2 - Dependencies

Install the bsnmp-ucd packge.
# sudo pkg_add -r bsnmp-ucd

3 - Service configuration

Edit /etc/rc.conf.local so that the bsnmp service will start when the system
starts up. Somewhere in the file add the following.
# sudo vi /etc/rc.conf.local

The configuration file is located at /etc/snmpd.config. You can create your own
configuration file. For this example, we will use a read only community name of
public. Keep the default configuration file as is except set the following
lines. Also, add the last line to use the UCD MIB files.
  location := "Test"
  contact := "John Doe"
  read := "public"
  #write := "geheim"
  begemotSnmpdModulePath."hostres" = "/usr/lib/"
  begemotSnmpdModulePath."ucd" = "/usr/local/lib/"
# sudo cp /etc/snmpd.config /etc/snmpd.config.example
# sudo vi /etc/snmpd.config

Before starting the service, make sure that udp port 161 is open in case you
are running firewall software. Here is a sample rule.
# su - root
  udp_services={ 161 }"
  pass in on $ext_if proto udp from any to ($ext_if) port $udp_services flags keep state
# cp /etc/pf.conf /etc/pf.conf.previous
# vi /etc/pf.conf
# pfctl -F all && pfctl -f /etc/pf.conf
# logout

Start the bsnmp service.
# sudo /etc/rc.d/bsnmpd start
Starting bsnmpd.
# sudo /etc/rc.d/bsnmpd status
bsnmpd is running as pid 69561.

4 - Snmpget example

The FreeBSD MIB files will need to be copied to the computer that is running
snmpget. The FreeBSD MIB files are stored in /usr/share/snmp/mibs/. In our
example, we are running snmpget from a FreeBSD computer. Find where the MIB
files are stored and copy the files to that directory. Afterwards, run snmpget.
# pkg_info -L net-snmp-* | grep /mibs/
# sudo chown root:wheel ~/freebsd_mibs/*
# sudo cp ~/freebsd_mibs/* /usr/local/share/snmp/mibs/

From another computer, run snmpget to view some SNMP information.
# sudo snmpget -Os -c public -v 2c sysName.0 sysLocation.0 sysContact.0
sysName.0 = STRING:
sysLocation.0 = STRING: Test
sysContact.0 = STRING: John Doe

5 - Service check

Reboot your computer. Log in like normal and check to see that the bsnmp
service is running. That's it, now you have SNMP running in FreeBSD.
# sudo shutdown -r now
# sudo /etc/rc.d/bsnmpd status
bsnmpd is running as pid 977.

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