如何在 TP-Link JetStream 交換器上透過 SNMP 確認並修改 VLAN

TL-SG2008P , SG2428LP , Festa FS308GP , SX3008F , SG3428MP , SG3428X , SG3452P , SX3016F , TL-SG2210P , SG2428P , SG2008P , SG2210MP , TL-SX3008F , TL-SG3428 , TL-SG2218 , SG2210P , TL-SX3016F , S4500-8G , SG2218 , SG3428 , TL-SG3452P , TL-SG3428X , S5500-8MHP2XF , TL-SG3428MP , S4500-8GHP2F , TL-SG2008 , S4500-16G2F , TL-SG2210MP , TL-SG3210 , TL-SG3452 , SG3210 , SG3452 , Festa FS310GP , TL-SG3210XHP-M2 , S5500-24GP4XF , SG3428XMP , TL-SG2428P , TL-SG3428XMP
Recent updates may have expanded access to feature(s) discussed in this FAQ. Visit your product's support page, select the correct hardware version for your device, and check either the Datasheet or the firmware section for the latest improvements added to your product. Please note that product availability varies by region, and certain models may not be available in your region.
此篇文章展示如何確認 VLAN 設定、建立並新增/刪除 VLAN 的連接埠,透過 Simple Network Management Protocol (SNMP) 在 TP-Link JetStream 交換器上設定。
1. 需求。
閱讀此文章前,您需要先閱讀以下文章:
- TP-Link JetStream 交換器上的 VLAN 如何運作且設定? 官方手冊。
- TP-Link JetStream 交換器上設定 SNMP v2c/v3? 官方手冊。
- 閱讀、了解並使用 MIB。
- 設定並使用 NET-SNMP 指令,包含 snmpget, snmpset, snmptable, snmpwalk 或其他 SNMP 軟體。
2. 準備.
以下我們簡短描述 SNMP v2c 的設定。如需 SNMP 的詳細設定手冊,請參考 官方手冊。
- 前往 Maintenance --> SNMP --> Global Config,啟用 SNMP。
- 前往 SNMP v1/v2c,新增 community,Community 名稱為 tplink,且 Access Mode 為 Read & Write。
- Net-SNMP 可用於http://www.net-snmp.org/ Search your TP-Link switch models 從官方網站搜尋您的 TP-Link 交換器型號搜尋並從技術支援頁面下載 MIBs 檔,接著複製 MIBs 檔至 Net-SNMP MIBs 資料夾。
3. 操作。
所有指令將以藍色斜體和粗體呈現,此處用以 VLAN 設定的 MIB 檔案為 “tplink-vlan-dot1qVlan.mib”,且交換器 IP 位址為 192.168.0.1。
3.1 顯示 VLAN 表格。
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 建立 VLAN 100,將它命名為 “VLAN100”,並新增 untag ports 1/0/2-4。
使用 snmpset 指令以設定 VLAN ID、VLAN 名稱、要新增的連接埠,和要執行的動作 “createAndGo”。
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)
注意:
- OID 中的最後一個數字是要建立或刪除的 VLAN ID。
- dot1qVlanStatus 有兩個動作,createAndGo (4) 為建立 VLAN 且 destroy (6) 為刪除 VLAN。
- “i” 為 “integer&rdquo,“s” 為 “String”.
顯示 VLAN 表格, 且 VLAN 設定已更新生效。
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 從 VLAN 100 移除 untag port 1/0/2。
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 已從 from VLAN 100 中移除。
3.4 新增 untag port 1/0/5 為 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 已被新增至 VLAN 100。
3.5 透過 snmpwalk 檢查 Port ID。
每個連接埠有自己的 SNMP ifIndex,又稱為 Port ID。若要確認並管理 port VLAN 設定,我們需要透過 snmpwalk 了解 port 和 ID 之間的對應。
根據下列結果,GigaEthernet 1/0/1 的 port ID 為 49153,GigaEthernet 1/0/2 的為 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 管理型交換器(含 4 個 SFP 插槽)"
……
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 顯示 port VLAN 表格。
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 將 port 1/0/1 PVID 修改為 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 |
…… |
…… |
…… |
…… |
…… |
Related FAQs
這篇faq是否有用?
您的反饋將幫助我們改善網站
What’s your concern with this article?
- Dissatisfied with product
- Too Complicated
- Confusing Title
- Does not apply to me
- Too Vague
- 其他
謝謝
感謝您的反饋。
點擊此處與TP-Link技術支持聯繫。
Your Privacy Choices
本網站使用 cookie 來改善網站引導、分析線上活動並在我們的網站上提供最佳的使用者體驗。您可以隨時反對使用 cookie。您可以在我們的隱私權政策中找到更多資訊。 不再顯示
基本 Cookies
These cookies are necessary for the website to function and cannot be deactivated in your systems.
TP-Link
SESSION, JSESSIONID, accepted_local_switcher, tp_privacy_banner, tp_privacy_base, tp_privacy_marketing, tp_top-banner, tp_popup-bottom, tp_popup-center, tp_popup-right-middle, tp_popup-right-bottom, tp_productCategoryType
Youtube
id, VISITOR_INFO1_LIVE, LOGIN_INFO, SIDCC, SAPISID, APISID, SSID, SID, YSC, __Secure-1PSID, __Secure-1PAPISID, __Secure-1PSIDCC, __Secure-3PSID, __Secure-3PAPISID, __Secure-3PSIDCC, 1P_JAR, AEC, NID, OTZ
Zendesk
OptanonConsent, __cf_bm, __cfruid, _cfuvid, _help_center_session, _pendo___sg__.<container-id>, _pendo_meta.<container-id>, _pendo_visitorId.<container-id>, _zendesk_authenticated, _zendesk_cookie, _zendesk_session, _zendesk_shared_session, ajs_anonymous_id, cf_clearance
分析和行銷 Cookies
Analysis cookies enable us to analyze your activities on our website in order to improve and adapt the functionality of our website.
The marketing cookies can be set through our website by our advertising partners in order to create a profile of your interests and to show you relevant advertisements on other websites.
Google Analytics & Google Tag Manager
_gid, _ga_<container-id>, _ga, _gat_gtag_<container-id>
Google Ads & DoubleClick
test_cookie, _gcl_au