Net-SNMP
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:
/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 |
bzip2
|
Use the bzlib compression library |
doc
|
Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally |
elf
|
Enable the use of elf utils to check uptime on some systems |
ipv6
|
Add support for IP version 6 |
kmem
|
Enable usage of /dev/kmem |
lm-sensors
|
Add linux lm-sensors (hardware sensors) support |
mfd-rewrites
|
Use MFD rewrites of mib modules where available |
minimal
|
Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features) |
mysql
|
Add mySQL Database support |
netlink
|
Use dev-libs/libnl to fetch TCP statistics instead of using /proc/net/tcp (Linux only). |
pcap
|
Install snmppcap which reads from PCAP files and writes to the SNMP transport |
pci
|
Use libpci (from sys-apps/pciutils) to look up network interface description. This feature is only available on Linux. |
pcre
|
Add support for Perl Compatible Regular Expressions in process table filtering. |
perl
|
Add optional support/bindings for the Perl language |
python
|
Add optional support/bindings for the Python language |
rpm
|
Enable monitoring of app-arch/rpm. This flag requires the bzip2 and zlib flags to be enabled as well. |
selinux
|
!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur |
smux
|
Enable support for the legacy smux protocol (superseded by agentx) |
ssl
|
Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security) |
tcpd
|
Add support for TCP wrappers |
ucd-compat
|
Build UCD compatibility library. Increases significantly the install size. |
valgrind
|
Enable annotations for accuracy. May slow down runtime slightly. Safe to use even if not currently using dev-util/valgrind |
zlib
|
Add support for zlib (de)compression |
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.
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 own SNMP community.
- Substitute the 192.0.2.0/24 network with own IP network where SNMP polling should be allowed from.
- Substitute the syslocation and syscontact with own valid data.
/etc/snmp/snmpd.conf
# Which SNMP MIB's are accessible on this system, here 'all'
view all included .1 80
# From which IP network SNMP polling is allowed. Here 'rocommunity' for Read-Only access.
rocommunity my-own-SNMP-community 192.0.2.0/24
# Location and system contact data
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 the SNMP polling host has be within the allowed IP range of 192.0.2.0/24.
- Substitute the IP 198.51.100.1 with the target host where SNMP access has been enabled
- Substitute the SNMP community my-own-SNMP-community with your own SNMP community
This test command is executed from polling client into the target IP network:
user $
snmpwalk -v2c -c my-own-SNMP-community 198.51.100.1
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