Comments (7)
There is no limit on what networks or interfaces this library will receive
on.
Can you please provide a code sample that demonstrates this problem? Your
tcpdump logs would also be helpful.
Thanks
On Thu, Oct 8, 2015 at 2:12 PM, Ipartner TI Experience <
[email protected]> wrote:
Hi.
Every time I try to pull data from a snmp agent it returns timeout if the
host (server) is in another network.if the agent is in the same network it works fine.
tcpdump shows the petition and the response but the snmpget still jumps
with timeout error.
if the test run in a host from the same network the data comes ok.tested snmpget (part of snmp-utils) and works w/o problems there is sime
limites over this library?—
Reply to this email directly or view it on GitHub
#55.
Whitham D. Reeve II
907-764-5263
from gosnmp.
My code
package main
import (
"fmt"
"log"
"net"
"os"
"time"
"github.com/paulstuart/ping"
"github.com/soniah/gosnmp"
)
func main() {
var snmp gosnmp.GoSNMP
snmp.Target = "172.25.12.1" //pfsense box
snmp.Port = 161
snmp.Version = gosnmp.Version2c
snmp.Timeout = time.Duration(30) * time.Second
snmp.Community = "public"
snmp.Retries = 2
gosnmp.LoggingDisabled = false
fmt.Printf("Conectando\n")
ec := snmp.Connect()
if ec != nil {
fmt.Printf("Error snmp %s\n", ec)
return
}
fmt.Printf("Conectado\n")
result, error_get := snmp.Get([]string{".1.3.6.1.2.1.1.1.0"})
if error_get != nil {
fmt.Printf("Error get %s \n", error_get, result)
return
}
for _, v := range result.Variables {
fmt.Printf("%+v\n", v)
if v.Type != gosnmp.BitString {
os := v.Value.([]byte)
fmt.Printf("Nombre %s\n", v.Name, string(os))
}
}
}
Output from my VM
root@localhost detector]# ./detector
Conectando
Conectado
logSNMP-2015/10/09 13:21:02 Retry number 1. Last error was: Error reading from UDP: read udp 172.25.12.1:161: i/o timeout
logSNMP-2015/10/09 13:21:12 Retry number 2. Last error was: Error reading from UDP: read udp 172.25.12.1:161: i/o timeout
logSNMP-2015/10/09 13:21:22 Retry number 3. Last error was: Error reading from UDP: read udp 172.25.12.1:161: i/o timeout
Error get Request timeout (after 2 retries)
%!(EXTRA *gosnmp.SnmpPacket=)
tcdump output
tcpdump -i eno16777736 port 161
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eno16777736, link-type EN10MB (Ethernet), capture size 65535 bytes
13:20:52.344549 IP 172.16.68.144.36898 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:20:52.419162 IP 10.0.8.1.snmp > 172.16.68.144.36898: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"
13:21:02.346104 IP 172.16.68.144.36898 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:21:02.414936 IP 10.0.8.1.snmp > 172.16.68.144.36898: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"
13:21:12.347555 IP 172.16.68.144.36898 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:21:12.391494 IP 10.0.8.1.snmp > 172.16.68.144.36898: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"
Snmpget runing in the same box
snmpget -v2c -c public 172.25.12.1 .1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysDescr.0 = STRING: pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386
tcpdump output
13:23:27.516676 IP 172.16.68.144.51095 > 172.25.12.1.snmp: GetRequest(28) system.sysDescr.0
13:23:27.569517 IP 10.0.8.1.snmp > 172.16.68.144.51095: GetResponse(107) system.sysDescr.0="pfSense fw.jconcha.ipartner.cl 2.1-RELEASE pfSense FreeBSD 8.3-RELEASE-p11 i386"
If the programs run on a machine in the same network that the pfsense box it works just fine,
the conection betwerrn the pf sense box is trough OpenVPN udpVPN, the test run from a VM with Fedora 20 and my MacBook with the same results.
from gosnmp.
Looking at the tcpdump(sorry I just noticed) it seems that the pfsense box responds from the vpn interface 10.0.8.1 and not from the target IP.
changed the target to that IP and it worked nicely. the weird thing is the origin and why snmpget worked, looks it intercepts any data that match even if its from other ip
from gosnmp.
I already wrote about this issue: #47
from gosnmp.
Abulata, from my interpretation, the people commenting on that issue liked
the proposed solution. Is there a reason you decided to close the issue?
On Thu, Oct 22, 2015 at 3:35 AM, abaluta [email protected] wrote:
I already wrote about this issue: #47
#47—
Reply to this email directly or view it on GitHub
#55 (comment).
Whitham D. Reeve II
907-764-5263
from gosnmp.
wdreeveii, I decided to use another language (the library) in the project. It is an open source project, I do not pay money for it, and I can only offer. :)
from gosnmp.
Closing this issue as a duplicate of #47
from gosnmp.
Related Issues (20)
- multiple device concurrent polling fails unless you create your own snmp object HOT 2
- Question: Use on Windows HOT 1
- VULNERABILITY [CWE-347] CVE-2020-9283] golang.org/x/crypto Improper Signature Verification HOT 1
- Sometimes a previous privacy passphrase is reused instead of the specified one
- usmStatsUnknownUserNames as terminating error? HOT 3
- Chinese coding is garbled HOT 2
- How to configure read/write community? HOT 1
- marshal: marshalPDU: unable to marshal varbind list: unable to marshal OID: Value out of range HOT 2
- Should cancelling a context interrupt an ongoing operation?
- out of bounds error when parsing AuthNoPriv packet HOT 4
- msgMaxSize to be supported in SNMP v3 bulkwalk requests
- V3 feat needed: Load keys manually if the passphrases are not allowed be saved locally HOT 1
- Connect function in gosnmp always returns nil even if the credentials are not valid HOT 1
- Panic in unmarshalV3Header
- Compatibility with GoSNMPServer HOT 7
- `net-snmp` based validation testing HOT 5
- Request ID size too large
- Not handling `0` values correctly for `OpaqueDouble` or `OpaqueFloat`
- Using SnmpDecodePacket for Encrypted/Authenticated Packets in GoSNMP HOT 5
- Retry netConnect() on resolution failure HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gosnmp.