Header Only - DO NOT REMOVE - Extreme Networks

Modify port Vlan ID with PySnmp

Userlevel 1
Hi, im trying to modify the vlan id of port 24 on slot 2 (2:24) which as the ifindex of 152 according to snmpGet. I have been reading the documentation of PySnmp and from my point of view it is a bit vague, probably because i dont have yet a deep knowledge of programming and also on how SNMP is structured.

Using the script provided from pysnmp documentation im unable to configure port 2:24 vlan ID. Im getting the following error:

pysnmp.smi.error.SmiError: No symbol SNMPv2-SMI::mib- at [/code]my code:

from pysnmp.hlapi import *
g = setCmd(SnmpEngine(),
UdpTransportTarget(MyIP, 161)),
ObjectType(ObjectIdentity('SNMPv2-SMI', 'mib-', 152), '201'))
Can someone help me?

3 replies

Userlevel 6
It seems pysnmp cannot find the mib, try using the oid. Below an example with a get.

def SNMPGet(oid,host,community):
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
cmdgen.UdpTransportTarget((host, 161)),

# Check for errors and print out results
if errorIndication:
if errorStatus:
print('%s at %s' % (
errorIndex and varBinds[int(errorIndex)-1] or '?'
for name, val in varBinds:
return val.prettyPrint()

Userlevel 1
Hi, Oscar. Hope you are doing well, thanks for the reply. I was finally able to set the vlan Id via pySNMP with a different piece of code.
from pysnmp.entity.rfc3413.oneliner import cmdgen
from pysnmp.proto import rfc1902
errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CommandGenerator().setCmd(
cmdgen.CommunityData('my-agent', My_Community, 1),
cmdgen.UdpTransportTarget(('', 161)),
((1,3,6,1,2,1,17,7,1,4,5,1,1,1), rfc1902.Gauge32('201'))
print errorIndication
print errorStatus [/code]output form the switch:

* (pacman) EXOS-VM.36 # sh port 1 vid
Port /Tagged VID(s)
-------- -------- ------------------------------------------------------------
1 Untagged 201

Thanks for trying to help.
Userlevel 6
Glad to help.