1

我正在尝试对链接本地地址上的代理进行 SNMP 查询FE80::1:1%enp0s8。这是代码:

#!/usr/bin/python3

from pysnmp.hlapi import *

USER_KEY='manager1'
AUTH_PROT=usmHMACMD5AuthProtocol
PRIV_PROT=usmAesCfb256Protocol

userData = UsmUserData('manager', authKey=USER_KEY, 
                                  privKey=USER_KEY, 
                                  authProtocol=AUTH_PROT,
                                  privProtocol=PRIV_PROT)
target=Udp6TransportTarget(('FE80::1:1%enp0s8',161))

g = getCmd(SnmpEngine(),
       userData,
       target,
           ContextData(),
           ObjectType(ObjectIdentity('SNMPv2-MIB','sysUpTime',0)))

print(next(g))

enp0s8我可以在哪里找到代理的界面在哪里。但是,当我使用它时,我收到此错误消息:

Traceback (most recent call last):
  File "get-SNMP-var.py", line 21, in <module>
    print(next(g))
  File "/usr/lib/python3.5/site-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 107, in getCmd
    lookupMib=options.get('lookupMib', True)))
  File "/usr/lib/python3.5/site-packages/pysnmp/hlapi/asyncore/cmdgen.py", line 122, in getCmd
    addrName, paramsName = lcd.configure(snmpEngine, authData, transportTarget)
  File "/usr/lib/python3.5/site-packages/pysnmp/hlapi/lcd.py", line 107, in configure
    transportTarget.tagList
  File "/usr/lib/python3.5/site-packages/pysnmp/entity/config.py", line 269, in addTargetAddr
    transportAddress = TransportAddressIPv6(transportAddress)
  File "/usr/lib/python3.5/site-packages/pyasn1/type/univ.py", line 312, in __init__
    base.AbstractSimpleAsn1Item.__init__(self, value, tagSet, subtypeSpec)
  File "/usr/lib/python3.5/site-packages/pyasn1/type/base.py", line 74, in __init__
    value = self.prettyIn(value)
  File "<string>", line 217, in prettyIn
OSError: illegal IP address string passed to inet_pton

当我没有为此链接本地地址指定接口时,我会超时。使用snmpget具有指定范围的实用程序有效。

我的问题是:如何使用 指定 IPv6 链接本地地址的范围Udp6TransportTarget

4

0 回答 0