After installing SNMP and its daemon(sudo apt-get install snmp snmpd
), you will need to edit the file /etc/snmp/snmp.conf
and comment out the line containing "mibs:"
Within this file, change the line:
mibs :
to
#mibs :
Next, assuming you haven't done this already, you will need to obtain the full set of IETF MIBs. These files do not ship, by default, on Debian/Ubuntu systems due to licensing issues.
From the terminal(Ctrl-Alt-t), enter the following commands:
sudo apt-get install snmp-mibs-downloader
sudo download-mibs
Then, you will need to modify /etc/snmp/snmpd.conf
.
To allow SNMP the system to receive queries on interfaces other than its loopback address. The lines for this should look like this:
# Listen for connections from the local system only
# agentAddress udp:127.0.0.1:161
# Listen for connections on all interfaces (both IPv4 *and* IPv6)
agentAddress udp:161,udp6:[::1]:161
Note that this will allow ANY system to query your machine. You will need to adjust this to limit SNMP access to your device.
You will now want to change your Read-only SNMP string from public
to a custom string of your choosing, as below:
#rocommunity public default -V systemonly
rocommunity <My$ecret$tr1nG> (Don't use this example!)
Note: Removing -V systemonly
from the line will allow access to the entire MIB tree and not restrict it to the system part of the tree.
Restart the SNMP daemon
sudo service snmpd restart
Finally, your SNMP query should now respond properly.
e.g.:
snmpwalk -v 2c -c <My$ecret$tr1nG> <MachineName> ipadd
IP-MIB::ipAdEntAddr.127.0.0.1 = IpAddress: 127.0.0.1
IP-MIB::ipAdEntAddr.192.168.1.7 = IpAddress: 192.168.1.7
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
IP-MIB::ipAdEntIfIndex.192.168.1.7 = INTEGER: 2
IP-MIB::ipAdEntNetMask.127.0.0.1 = IpAddress: 255.0.0.0
IP-MIB::ipAdEntNetMask.192.168.1.7 = IpAddress: 255.255.255.0
IP-MIB::ipAdEntBcastAddr.127.0.0.1 = INTEGER: 0
IP-MIB::ipAdEntBcastAddr.192.168.1.7 = INTEGER: 1
The same query can be run using a GUI based MIB browser, as well. Personally, I prefer using SNMPb for my graphical queries. Once you have SNMPb installed, open SNMPb and navigate to the desired OID in the MIB tree. In your specific case, it would be 1.3.6.1.2.1.4.20
or iso-> org-> internet-> mgmt-> mib-2 -> ip -> ipAddrTable
and perform a Get Bulk to receive the same data.
