How to check and modify VLANs on a TP-Link JetStream switch via SNMP
This article demonstrates how to check VLAN settings, create and delete VLANs, as well as add and remove ports to VLANs, on the TP-Link JetStream switch via the Simple Network Management Protocol (SNMP).
1. Requirements.
You should understand the following before reading this document:
- How do VLANs work and how to set up VLANs on TP-Link JetStream switch? Official Guide.
- How to set up SNMP v2c/v3 on TP-Link JetStream switch? Official Guide.
- Reading, understanding, and using MIBs.
- Configure and use NET-SNMP commands, including snmpget, snmpset, snmptable, snmpwalk, or other SNMP software.
2. Preparations.
Here we briefly describe the configuration of SNMP v2c. For a detailed Configuration Guide of SNMP, please refer to the Official Guide.
- Go to Maintenance --> SNMP --> Global Config, enable SNMP.
- Go to SNMP v1/v2c, add a new community, the Community name is tplink, and the Access Mode is Read & Write.
- Net-SNMP available at http://www.net-snmp.org/ Search your TP-Link switch models from the official website and download the MIBs file from the Support page, then copy the MIBs files to Net-SNMP MIBs folder.
3. Operations.
All commands will be listed in blue italics and bold. MIBs file used here for VLAN settings is “tplink-vlan-dot1qVlan.mib”, and the switch IP address here is 192.168.0.1.
3.1 Show VLAN table.
snmptable -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanConfigTable
dot1qVlanId |
dot1qVlanDescription |
vlanTagPortMemberAdd |
vlanUntagPortMemberAdd |
vlanPortMemberRemove |
dot1qVlanStatus
|
1 |
“System-VLAN” |
“” |
“1/0/1-28” |
“” |
active |
3.2 Create VLAN 100, name it “VLAN100”, and add untag ports 1/0/2-4.
Use the snmpset command to set the VLAN ID, VLAN Name, ports to be added, and the action “createAndGo” to be performed.
snmpset -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 dot1qVlanId.100 i 100 dot1qVlanDescription.100 s VLAN100 vlanUntagPortMemberAdd.100 s 1/0/2-4 dot1qVlanStatus.100 i 4
TPLINK-DOT1Q-VLAN-MIB::dot1qVlanId.100 = INTEGER: 100
TPLINK-DOT1Q-VLAN-MIB::dot1qVlanDescription.100 = STRING: "VLAN100"
TPLINK-DOT1Q-VLAN-MIB::vlanUntagPortMemberAdd.100 = STRING: "1/0/2-4"
TPLINK-DOT1Q-VLAN-MIB::dot1qVlanStatus.100 = INTEGER: createAndGo(4)
Note:
- The last number in the OID is the VLAN number to be created or deleted.
- dot1qVlanStatus has two actions, createAndGo (4) for creating VLANs and destroy (6) for deleting VLANs.
- “i” for integer, “s” for “String”.
Show VLAN table, and the VLAN settings have been updated to take effect.
snmptable -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanConfigTable
dot1qVlanId |
dot1qVlanDescription |
vlanTagPortMemberAdd |
vlanUntagPortMemberAdd |
vlanPortMemberRemove |
dot1qVlanStatus
|
1 |
“System-VLAN” |
“” |
“1/0/1-28” |
“” |
active |
100 |
“VLAN100” |
“” |
“1/0/2-4” |
“” |
active |
3.3 Remove untag port 1/0/2 from VLAN 100.
snmpset -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanPortMemberRemove.100 s 1/0/2
TPLINK-DOT1Q-VLAN-MIB::vlanPortMemberRemove.100 = STRING: "1/0/2"
snmptable -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanConfigTable
dot1qVlanId |
dot1qVlanDescription |
vlanTagPortMemberAdd |
vlanUntagPortMemberAdd |
vlanPortMemberRemove |
dot1qVlanStatus
|
1 |
“System-VLAN” |
“” |
“1/0/1-28” |
“” |
active |
100 |
“VLAN100” |
“” |
“1/0/3-4” |
“” |
active |
Port 1/0/2 has been removed from VLAN 100.
3.4 Add untag port 1/0/5 to VLAN 100.
snmpset -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanUntagPortMemberAdd.100 s 1/0/5
TPLINK-DOT1Q-VLAN-MIB::vlanUntagPortMemberAdd.100 = STRING: "1/0/5"
snmptable -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanConfigTable
dot1qVlanId |
dot1qVlanDescription |
vlanTagPortMemberAdd |
vlanUntagPortMemberAdd |
vlanPortMemberRemove |
dot1qVlanStatus
|
1 |
“System-VLAN” |
“” |
“1/0/1-28” |
“” |
active |
100 |
“VLAN100” |
“” |
“1/0/3-5” |
“” |
active |
Port 1/0/5 has been added to VLAN 100.
3.5 Check Port ID by snmpwalk.
Each port has its own SNMP ifIndex, or you can say the Port ID. To check and manage the port VLAN settings, we need to know the correspondence between the ports and IDs through snmpwalk.
According to the following result, the port ID of GigaEthernet 1/0/1 is 49153, of GigaEthernet 1/0/2 is 49154 ……
snmpwalk -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1
RFC1213-MIB::sysDescr.0 = STRING: "JetStream 24-Port Gigabit L2 Managed Switch with 4 SFP Slots"
……
RFC1213-MIB::ifIndex.1 = INTEGER: 1
RFC1213-MIB::ifIndex.49152 = INTEGER: 49152
RFC1213-MIB::ifIndex.49153 = INTEGER: 49153
RFC1213-MIB::ifIndex.49154 = INTEGER: 49154
RFC1213-MIB::ifIndex.49155 = INTEGER: 49155
RFC1213-MIB::ifIndex.49156 = INTEGER: 49156
RFC1213-MIB::ifIndex.49157 = INTEGER: 49157
……
RFC1213-MIB::ifDescr.1 = STRING: "Vlan-interface1"
RFC1213-MIB::ifDescr.49152 = STRING: "AUX0"
RFC1213-MIB::ifDescr.49153 = STRING: "gigabitEthernet 1/0/1 : copper"
RFC1213-MIB::ifDescr.49154 = STRING: "gigabitEthernet 1/0/2 : copper"
RFC1213-MIB::ifDescr.49155 = STRING: "gigabitEthernet 1/0/3 : copper"
RFC1213-MIB::ifDescr.49156 = STRING: "gigabitEthernet 1/0/4 : copper"
RFC1213-MIB::ifDescr.49157 = STRING: "gigabitEthernet 1/0/5 : copper"
……
3.6 Show port VLAN Table.
snmptable -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanPortConfigTable
SNMP table: TPLINK-DOT1Q-VLAN-MIB::vlanPortConfigTable
vlanPortNumber |
vlanPortPvid |
vlanPortIngressCheck |
vlanPortAcceptFrameType |
vlanPortLag |
"1/0/1" |
1 |
enable |
all |
N/A |
“1/0/2” |
1 |
enable |
all |
N/A |
“1/0/3” |
1 |
enable |
all |
N/A |
…… |
…… |
…… |
…… |
…… |
snmpwalk -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanPortPvid
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49153 = INTEGER: 1
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49154 = INTEGER: 1
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49155 = INTEGER: 1
……
3.7 Change port 1/0/1 PVID to VLAN 100.
snmpset -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanPortPvid.49153 i 100
TPLINK-DOT1Q-VLAN-MIB::vlanPortPvid.49153 = INTEGER: 100
snmptable -c tplink -v 2c -m TPLINK-DOT1Q-VLAN-MIB 192.168.0.1 vlanPortConfigTable
SNMP table: TPLINK-DOT1Q-VLAN-MIB::vlanPortConfigTable
vlanPortNumber |
vlanPortPvid |
vlanPortIngressCheck |
vlanPortAcceptFrameType |
vlanPortLag |
"1/0/1" |
100 |
enable |
all |
N/A |
“1/0/2” |
1 |
enable |
all |
N/A |
“1/0/3” |
1 |
enable |
all |
N/A |
…… |
…… |
…… |
…… |
…… |
Is this faq useful?
Your feedback helps improve this site.
TP-Link Community
Still need help? Search for answers, ask questions, and get help from TP-Link experts and other users around the world.