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.
USE flags for net-analyzer/net-snmp Software for generating and retrieving SNMP data
|Add support for X11
|Enable bzip2 compression support
|Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
|Enable the use of elf utils to check uptime on some systems
|Add support for IP version 6
|Enable usage of /dev/kmem
|Add linux lm-sensors (hardware sensors) support
|Use MFD rewrites of mib modules where available
|Install a very minimal build (disables, for example, plugins, fonts, most drivers, non-critical features)
|Add mySQL Database support
|Use dev-libs/libnl to fetch TCP statistics instead of using /proc/net/tcp (Linux only).
|Install snmppcap which reads from PCAP files and writes to the SNMP transport
|Use libpci (from sys-apps/pciutils) to look up network interface description. This feature is only available on Linux.
|Add support for Perl Compatible Regular Expressions in process table filtering.
|Add optional support/bindings for the Perl language
|Add optional support/bindings for the Python language
|Enable monitoring of app-arch/rpm. This flag requires the bzip2 and zlib flags to be enabled as well.
|!!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
|Enable support for the legacy smux protocol (superseded by agentx)
|Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
|Add support for TCP wrappers
|Build UCD compatibility library. Increases significantly the install size.
|Enable annotations for accuracy. May slow down runtime slightly. Safe to use even if not currently using dev-debug/valgrind
|Add support for zlib compression
The global USE flag snmp enables support for SNMP in other packages. Enabling this USE flag will pull inautomatically:
USE="... snmp ..."
After setting the snmp USE flag globally, your system must be updated for the changes take effect:
emerge --ask --changed-use --deep @world
To installmanually, if it isn't already pulled in:
emerge --ask net-snmp
NEVER use the default communities which are called public and private, these are a potential security risk, even if SNMP access is secured with an IP access list.
Net-SNMP's Agent typically uses 3 configuration files:
- /etc/snmp/snmpd.conf - The main configuration file.
- /usr/share/snmp/snmpd.conf - Secondary configuration files, where SNMPv3 users are defined when using net-snmp-create-v3-user.
- /var/lib/net-snmp/snmpd.conf - The agent service file, rarely edited manually.
SNMPv3 users can only be modified while the agent (snmpd) is stopped.
If using SNMPv3, users must be created before the agent is configured. They can be added by using net-snmp-create-v3-user, or manually editing /var/lib/net-snmp/snmpd.conf before the agent starts.
net-snmp-create-v3-user can be used to create SNMPv3 users. By default it will create a read-write user with MD5 authentication and DES encryption.
To add a read-only user with SHA-512 authentication and AES encryption.
net-snmp-create-v3-user -ro -A "super secret auth passphrase" -X "super secret priv passphrase" -a SHA-512 -x AES my_user
adding the following line to /var/lib/net-snmp/snmpd.conf: createUser my_ser SHA "super secret auth passphrase" AES "super secret priv passphrase" adding the following line to /usr/share/snmp/snmpd.conf: rouser my_user
The config file for SNMPv3 users is under /var/lib/ not /etc/.
createUser my_user SHA "super secret auth passphrase" AES "super secret priv passphrase"
createUser my_user SHA-512 "super secret auth passphrase" AES "super secret priv passphrase"
More information is available under the SNMPv3 USM Users section of man snmpd.conf.
SNMP Agent configuration is specified in /etc/snmp/snmpd.conf. An example is available at /etc/snmp/snmpd.conf.example.
More examples are available under man snmpd.examples.
agentAddress config directive defines what interfaces snmpd will listen on. To which specific IP interface the SNMP daemon will be bound to:
If left undefined, snmpd will listen on
By default, Net-SNMP derives the management engine ID from the eth0's MAC address, to change which network interface is used:
To allow read-only access from the
This entry is automatically added when using net-snmp-create-v3-user.
This can be configured in either /usr/share/snmp/snmpd.conf or /etc/snmp/snmpd.conf.
SNMPv1 and SNMPv2c
To allow read-only access from the from
192.0.2.0/24 network using the
# 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 'my-own-SNMP-community' for Read-Only access.
rocommunity my-own-SNMP-community 192.0.2.0/24
It is suggested to put valid data into the system group fields. This data will be visible in monitoring software if alerts are thrown. Failure to provide descriptive system information can make alert responses much more difficult.
#Location and system contact data
sysContact Admin <Admin@example.com>
sysDescr Gentoo NFS Server Node1
In a large networks or enterprises, it can be hard to describe where particular network equipment has been placed. A descriptive location can seriously help, and should make sense to someone who has never worked with the alerting device before. The person responding to the alert will likely be thankful that a location tag was helpful.
By default, smnpd will monitor network interfaces, disk usage, processes, and system load.
To restrict the agent to only list information about specific network interfaces:
net-snmp tools read config from ~/.snmp.
To add a MIB, create ~/.snmp/mibs then copy the file there:
mkdir --parents ~/.snmp/mibs
cp ~/Downloads/my-new.mib ~/.snmp/mibs
To start the SNMP daemon:
rc-service snmpd start
To test access to a SNMP agent, snmpwalk can be used:
snmpwalk -v 3 -a SHA-512 -A "super secret auth passphrase" -x AES -X "super secret priv passphrase" -u my_user -l authPriv 198.51.100.1
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:
snmpwalk -v2c -c my-own-SNMP-community 198.51.100.1
Verify the SNMP daemon is running on a particular host:
ss -tulpn | grep snmp
udp UNCONN 0 0 0.0.0.0:161 0.0.0.0:* users:(("snmpd",pid=2138,fd=6))