Monday, September 21, 2009

Setting up SNMPD

Versions tested; FreeBSD 6.2, 7.2
Here's what you have to do (logged in as root);

Installing
#cd /usr/ports/net-mgmt/net-snmp
#make install

Configuration
#cd /usr/local/etc/snmp
snmpconf -g basic_setup

Answer all the questions to suit your requirements, paying particular attention to the parts relating to access controls and the "snmp community". Also note, if you don't change your cwd to /usr/local/etc/snmp then the conf file will be created in whatever directory you are currently in therefore you will have to copy the file manually.

Here is a particularly simple example of snmp.conf using a read only "public" community. Using the "public" community is not advised for security reasons, I have used it here for simplicities sake.
syslocation  "Virtual machine on underworld"

syscontact user@example.com.au

sysservices 12

rocommunity public

trap2sink 10.100.1.198

trapcommunity public

I have removed the comments from here for brevity. If you look at your own generated snmpd.conf file it will be fully commented describing these various lines.

Placing the Config File
#mkdir /usr/local/etc/snmp/
#mv snmpd.conf /usr/local/etc/snmp/snmpd.conf


Checking your configuration from the local host
snmpwalk -Os -c public -v 1 localhost system

This should return a bunch of lines relating to various parts of your system. You can execute the same command from another host, changing "localhost" to the name of the system.