03-21-2018 01:26 PM - edited 03-21-2019 11:23 AM
Hi all,
I want to automate the VLAN change on a specific port. During weekdays this port should be on another VLAN than during weekends.
To achieve this I want to use snmpset. I installed a couple of Cisco SG350-28P switches to accomplish this and installed snmpset from net-snmp.org on a Windows host. Also tried adding the SG350 mib files to the shared mib directory. (unsure if this really helps)
Using snmpset I want to change the VLAN id on a port. I tried to follow the catalyst instructions, but apperently the SG350 switches use another OID structure. (But I am not an expert on snmp.)
I ran a snmpwalk and found the oid for vlan id's for a access port.
C:\usr\bin>snmpget -v 1 -c jptest switch7 1.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23 iso.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23 = INTEGER: 33
When trying to change the VLAN id from 33 to 30 I get an error, and the vlan stays on 33.
C:\usr\bin>snmpset -v 1 -c jptest switch7 1.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23 integer 30
Error in packet.
Reason: (noSuchName) There is no such variable name in this MIB.
Failed object: iso.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23
C:\usr\bin>snmpget -v 1 -c jptest switch7 1.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23
iso.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23 = INTEGER: 33
Of course when changing using Cisco cli the VLAN changes, the results from the snmpget afterwards:
C:\usr\bin>snmpget -v 1 -c jptest switch7 1.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23 iso.0.8802.1.1.2.1.5.32962.1.2.1.1.1.23 = INTEGER: 30
So it must be the right oid!
I also checked if I have the right permissions, by changing another oid:
C:\usr\bin>snmpget -v 1 -c jptest switch7 1.3.6.1.2.1.31.1.1.1.18.23 IF-MIB::ifAlias.23 = STRING: port23-test C:\usr\bin>snmpset -v 1 -c jptest switch7 1.3.6.1.2.1.31.1.1.1.18.23 string "port23-test-test2" IF-MIB::ifAlias.23 = STRING: port23-test-test2 C:\usr\bin>snmpget -v 1 -c jptest switch7 1.3.6.1.2.1.31.1.1.1.18.23 IF-MIB::ifAlias.23 = STRING: port23-test-test2
So snmp rw permissions are also ok.
What am I doing wrong or should I alter to get the snmpset working to change the vlan on a port using snmpset???
Any suggestion appreciated!
03-28-2018 05:42 AM
04-17-2018 12:33 AM - edited 04-17-2018 12:37 AM
Thanks Aleksandra, however using the solution you pointed to I can create a VLAN and name it, but mapping ports to the VLAN does not work in my case. I am troubleshooting this now, but seems that the port bitmap is not working on SG350 with latest code... (2.3.5.63)
My try:
snmpset -v 2c -m CISCOSB-vlan-MIB -c jptest switch7.pijler.intern dot1qVlanStaticTable.1.5.17 i 4 dot1qVlanStaticTable.1.1.17 s 17-test dot1qVlanStaticTable.1.2.17 x 0x8000 dot1qVlanStaticTable.1.3.17 x 0x00 dot1qVlanStaticTable.1.4.17 x 0x8000 Q-BRIDGE-MIB::dot1qVlanStaticRowStatus.17 = INTEGER: createAndGo(4) Q-BRIDGE-MIB::dot1qVlanStaticName.17 = STRING: 17-test Q-BRIDGE-MIB::dot1qVlanStaticEgressPorts.17 = Hex-STRING: 80 00 Q-BRIDGE-MIB::dot1qVlanForbiddenEgressPorts.17 = Hex-STRING: 00 Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts.17 = Hex-STRING: 80 00
So looks good. The result is that vlan17 is created with name 17-test. However no ports are set untagged to this new vlan....
switch7#sh vlan Created by: D-Default, S-Static, G-GVRP, R-Radius Assigned VLAN, V-Voice VLAN Vlan Name Tagged Ports UnTagged Ports Created by ---- ----------------- ------------------ ------------------ ---------------- 1 1 Po1-8 D 12 12-Jeugd gi1-2,gi13,gi25-28 S 16 16-Gast gi1-2,gi13,gi25-28 gi14 S 17 17-test gi1-2,gi13,gi25-28 S
I tried with replacing the 0x8000 by a lot of different combinations, and all give the same result. (Of course I deleted vlan 17 before every retry) VLAN is created but no ports in the created vlan. I also did snmpgets on the vlan ports, but they give only 000000's back. Looks like there is nothing inside it..
For reference also the output with the OID's:
snmpset -v 2c -m CISCOSB-vlan-MIB -O n -c jptest switch7.pijler.intern dot1qVlanStaticTable.1.5.17 i 4 dot1qVlanStaticTable.1.1.17 s 17-test dot1qVlanStaticTable.1.2.17 x 0x0A00 dot1qVlanStaticTable.1.3.17 x 0x00 dot1qVlanStaticTable.1.4.17 x 0x0A00 .1.3.6.1.2.1.17.7.1.4.3.1.5.17 = INTEGER: createAndGo(4) .1.3.6.1.2.1.17.7.1.4.3.1.1.17 = STRING: 17-test .1.3.6.1.2.1.17.7.1.4.3.1.2.17 = Hex-STRING: 0A 00 .1.3.6.1.2.1.17.7.1.4.3.1.3.17 = Hex-STRING: 00 .1.3.6.1.2.1.17.7.1.4.3.1.4.17 = Hex-STRING: 0A 00
Any clue or tip how I can get this working? My goal is very simple, I want to be able to run a script to change a VLAN on a port. (The creation of VLAN's is just the example I followed first to get the basics working.)
06-12-2019 06:32 AM
Please try VlanAccessPortModeVlanId.[portID] UnsignedInteger 200 [vlan id]
.1.3.6.1.4.1.9.6.1.101.48.62.1.1.1 I 200
Obviously assuming you have ports set to access mode
1.3.6.1.4.1.9.6.1.101.48.22.1.1.[port id] i 11
By default all are 11
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide