-1

I have tried to get the name of snmp device through the below source.

$sysname1 = snmpget("192.168.0.9:161", "public", ".1.3.6.1.2.1.1.5.0.0");
$sysname2 = snmpget("192.168.0.10:164", "public", ".1.3.6.1.2.1.1.5.0.0");
$sysname3 = snmpget("192.168.0.11:165", "public", ".1.3.6.1.2.1.1.5.0.0");
$sysname4 = snmpget("192.168.0.12:166", "public", ".1.3.6.1.2.1.1.5.0.0");

Am getting only output for the first snmpget() method which is accessed through port 161. Other snmpget() is not working. As per the study 161 is default port. But I need to set different port for different IP address. Let me know how to set other port option for net-snmp

1 Answers1

0

You are trying to query an SNMP agent at different IP addresses and UDP ports. As you say, the first one is the default so you have SNMP agent (snmpd?) listening there. The other ports are non-default what may be the reason why no process is listening there.

You may want to run snmpd (if it's the SNMP agent you are using) to bind to all these ports:

# snmpd 164
# snmpd 165

or you can make a single snmpd instance listening on multiple UDP ports (and IP addresses if they are local to the same host):

# snmpd 192.168.0.10:164 192.168.0.11:165
Ilya Etingof
  • 5,440
  • 1
  • 17
  • 21
  • I tried by adding in the snmpd.conf file with below port options as agentAddress udp:127.0.0.1:164 agentAddress udp:127.0.0.1:165 adentAddress udp:127.0.0.1:166 . But snmpget() is only working in port 161. – Senthilkumar Ramasamy Mar 02 '17 at 13:26