Multiple snmp open port

684 views Asked by At

I have a problem with SNMP. I connect to SNMP with PHP using this code:

<?php
 $session = new SNMP(SNMP::VERSION_1, "xxx.xxx.xxx.xxx", "public");
 $fulltree = $session->walk(".");
 print_r($fulltree);
 echo "<br>";
 $session->close();
?>

The code works perfectly, it isn't the problem. The problem is can I have more IPs that I need connect with SNMP. I have a firewall (ZyWALL), and can have 4 printers. The problem occurs because I can set the 161 port only at one printer, and not at all.

enter image description here

How I can add the port 161 for all printers? Now i can see only one printers with the SNMP, but i need see all.

1

There are 1 answers

7
Alex Andrei On

option 1 is to pass the port explicitly if it's not the default 161

$sessionA = new SNMP(SNMP::VERSION_1, "192.168.1.204", "public"); //for port 161
$sessionB = new SNMP(SNMP::VERSION_1, "192.168.1.204:162", "public"); //for port 162

option 2, depending on your network set-up, is to assign different IPs to each printer so you can poll port 161 for each printer

you need to set up your firewall rules properly and according to the rules you access the printers.

so you if you have 4 printers all directly behind the firewall, each printer with it's own IP address, you map different incoming ports on the firewall to point to each respective printer's 161 port.

you would then open SNMP sessions like this

$sessionA = new SNMP(SNMP::VERSION_1, "public.firewall.ip.address:port1", "public"); 

for printer A, where port1 is the incoming port on the firewall that points to 161 on the printer

rinse and repeat for as many printers you have.