Multiple snmp open port

拟墨画扇 提交于 2019-12-11 19:33:41

问题


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.

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:


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.



来源:https://stackoverflow.com/questions/31045458/multiple-snmp-open-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!