Net-SNMP

From Gentoo Wiki
(Redirected from SNMP)
Jump to: navigation, search
Resources

From Wikipedia, the free encyclopedia:

Net-SNMP is a suite of software for using and deploying the SNMP protocol (v1, v2c and v3 and the AgentX subagent protocol). It supports IPv4, IPv6, IPX, AAL5, Unix domain sockets and other transports. It contains a generic client library, a suite of command line applications, a highly extensible SNMP agent, perl modules and python modules.

This document describes how to install and to configure SNMP Read Only access to your equipment. The SNMP version used in the configuration below is SNMP v2c.

Installation

Portage knows the global USE flag snmp for enabling support for SNMP in other packages. Enabling this USE flag will pull in net-analyzer/net-snmp automatically:

FILE /etc/portage/make.conf
USE="... snmp ..."

The USE flags of net-snmp are:

USE flags for net-analyzer/net-snmp Software for generating and retrieving SNMP data

X Add support for X11 global
bzip2 Use the bzlib compression library global
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally global
elf Enable the use of elf utils to check uptime on some systems local
ipv6 Add support for IP version 6 global
libressl Use dev-libs/libressl as SSL provider (might need ssl USE flag), packages should not depend on this USE flag global
lm_sensors Add linux lm_sensors (hardware sensors) support global
mfd-rewrites Use MFD rewrites of mib modules where available local
minimal Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features) global
mysql Add mySQL Database support global
netlink Use dev-libs/libnl to fetch TCP statistics instead of using /proc/net/tcp (Linux only). local
pci Use libpci (from sys-apps/pciutils) to look up network interface description. This feature is only available on Linux. local
perl Add optional support/bindings for the Perl language global
python Add optional support/bindings for the Python language global
rpm Enable monitoring of app-arch/rpm. This flag requires the bzip2 and zlib flags to be enabled as well. local
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur global
smux Enable support for the legacy smux protocol (superseded by agentx) local
ssl Add support for Secure Socket Layer connections global
tcpd Add support for TCP wrappers global
ucd-compat Build UCD compatibility library. Increases significantly the install size. local
zlib Add support for zlib (de)compression global

After setting this you want to update your system so the changes take effect:

root #emerge --ask --changed-use --deep @world

You want to install net-snmp yourself, if it isn't already pulled in:

root #emerge --ask net-snmp

Configuration

Edit /etc/snmpd/snmpd.conf and add the community and the IP access list.

Warning
NEVER use the default communities which are called public and private, these are considered a potential security risk, also if SNMP access is secured by an IP access list
  • Substitute the SNMP community my-own-SNMP-community with your own SNMP community.
  • Substitute the 10.255.255.0/24 network with your own IP network where SNMP access should be allowed from.
  • Substitute the syslocation and syscontact with your own valid data.
FILE /etc/snmp/snmpd.conf
com2sec local     127.0.0.1/32          my-own-SNMP-community
com2sec local     10.255.255.0/24       my-own-SNMP-community
#
group MyROGroup v1         local
group MyROGroup v2c        local
group MyROGroup usm        local
view all    included  .1                               80
access MyROGroup "" any     noauth    exact  all    none   none
#
syslocation London
syscontact Admin {Admin@example.com}

It is suggested to put valid data into the syslocation and syscontact fields, so in a support case when your hardware is monitored by a NMS (Network Management System) the responsible staff has the data right there where it is needed (in the NMS).

In a large networks or enterprises it is hard to describe for the network staff where particular network equipment has been placed. Sometimes there is a high fluctuation of the network staff, and after some time network equipment gets lost because nobody knows anymore where it has been placed, or whom to contact when a network equipment has failed.

Be aware to put valid data in there, your network staff will be thankful if you do so. It helps to resolve network outages quicker.

Starting the daemon

To start the SNMP daemon use following command:

root #/etc/init.d/snmpd start

Testing SNMP access

To test SNMP access or rather to poll SNMP data your SNMP client has to be within the allowed IP range of the previously configured access list (here 10.255.255.0/24).

  • Substitute the IP 192.168.10.254 with the target host where SNMP access has been enabled
  • Substitute the SNMP community my-own-SNMP-community with your own SNMP community
user $snmpwalk -v2c -c my-own-SNMP-community 192.168.10.254

Troubleshooting

Verify the SNMP daemon is running on a particular host:

root #netstat -tulpen | grep 161
udp        0      0 0.0.0.0:161             0.0.0.0:*                           0          4307       2393/snmpd
  • SNMP v1 and SNMP v2c uses UDP
  • SNMP v3 uses TCP