Reputation: 15
I want to pull all the MAC addresses that the switch knows about. I found in SNMPv2
This command is successful from a linux terminal
snmpwalk -v2c -c SNMPCommunity@10 10.10.10.10 .1.3.6.1.2.1.17.4.3.1.1
This command needs to have the "@10" inserted but I have no idea where.
snmpwalk -v3 -l authPriv -u username -a SHA -A authpriv -x DES -X authkey 10.10.10.10 .1.3.6.1.2.1.17.4.3.1.1
The above command only pulls MAC addresses from VLAN1. I tried username@10 - but then I get bad username
Big picture. I'm trying to pull them with a python script using pysnmp. I got everything working but this last part.
Upvotes: 1
Views: 1591
Reputation: 5555
To get pysnmp using non-default SNMP context name, just pass your context name in form of ContextName
object as contextData
parameter to nextCmd()
.
from pysnmp.hlapi import *
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
UdpTransportTarget(('demo.pysnmp.com', 161)),
ContextData(contextName='vlan-10'),
ObjectType(ObjectIdentity('1.3.6.1.2.1.17.4.3.1.1')))
)
https://docs.lextudio.com/pysnmp/
Upvotes: 0