Andrea php
Andrea php

Reputation: 393

PHP SNMP how to set port

I have a problem with my PHP code. I have a firewall (ZyWALL), and can have 4 printers. The problem occurs because I can set the 161 (SNMP) port only at one printer, and not at all.

This is a screen of my ZyWall:

enter image description here

And this is my php code:

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

If i set in my ZyWall for the ip: 192.168.1.204, Original port = 161 and Mapped port = 161, and in my php code i replace xxx.xxx.xxx.xxx with the correct ip with or without ":161", it work perfectly.

The problem occurs because i have plus of one printer. If for example i set in my ZyWall for the ip: 192.168.1.204, Original port = 6000 and Mapped port = 161, and in my php code i replace xxx.xxx.xxx.xxx with the correct ip with ":6000", it doesn't work.

Everyone can explain to me where is the error? Thank you

Upvotes: 1

Views: 1246

Answers (1)

SiL3NC3
SiL3NC3

Reputation: 770

You can set the port for the snmp connection as shown in this question:

$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

Upvotes: 1

Related Questions