5

I am using snmp and trying to get with

snmpwalk -v 2c -c public x.x.x.x ipadd

where x.x.x.x is the ip of the pc with ubuntu 12.04 i get this answer :

IP-MIB::ipAddrTable = No Such Object available on this agent at this OID

so how can I get the ip addres from a ubuntu 12.04 LT pc , there is maybe another comand that I can use?

Thanks for the answer .

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
usermfg
  • 51
  • If you have the IP address in the command, why would you need to get it again through SNMP? You already know it to run the command. – nanofarad Nov 28 '12 at 01:09
  • 1
    with snmpwalk -v 2c -c public x.x.x.x ipadd you can get ipaddres from diferent interfaces not only the one you are using in the comand so i need to know this thing but my point is just know how to configure IP-MIB and get this information because it is really diferent from the later ubuntu versions – usermfg Nov 28 '12 at 01:25

2 Answers2

4

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.

  1. 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.

  2. 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.

  3. 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.

Kevin Bowen
  • 19,615
  • 55
  • 79
  • 83
0

I had the same problem, and I had already done the above, but then I realised that all I needed to do was add the following line to /etc/snmp/snmpd.conf

# For IF-MIB data to show up in snmpwalk
view   systemonly  included   .1.3.6.1.2.1.4.20

and then restart the snmpd:

/etc/init.d/snmpd restart

then I get:

% ~/computer/snmp$ snmpwalk -v 2c -c public -O e mymachinename ipadd
IP-MIB::ipAdEntAddr.10.11.12.3 = IpAddress: 10.11.12.66
IP-MIB::ipAdEntAddr.127.0.0.1 = IpAddress: 127.0.0.1
IP-MIB::ipAdEntIfIndex.10.11.12.66 = INTEGER: 2
IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1
IP-MIB::ipAdEntNetMask.10.11.12.66 = IpAddress: 255.255.255.0
IP-MIB::ipAdEntNetMask.127.0.0.1 = IpAddress: 255.0.0.0
IP-MIB::ipAdEntBcastAddr.10.11.12.66 = INTEGER: 1
IP-MIB::ipAdEntBcastAddr.127.0.0.1 = INTEGER: 0

HTH

Will
  • 301
  • 2
  • 5