模式提醒:
<HP>代表 User View (類似 Cisco 的 Enable Mode),主要用於查看與儲存。[HP]代表 System View (類似 Cisco 的 Config Mode),用於修改設定。
模式切換與離開
| 功能 | 完整指令 | 常用縮寫 | 說明 |
|---|---|---|---|
| 進入設定模式 | system-view |
sys 或 system |
進入 [HP] 模式 |
| 退回上一層 | quit |
q |
離開目前階層 |
| 直接回頂層 | return |
Ctrl+Z |
不論多深直接回 <HP> |
基礎查詢儲存
-
顯示儲存在記憶體中的當前設定檔,如ports, vlan, group,對應cisco show running-configuration
[HP]display current-configuration -
顯示儲存在非揮發性記憶體(NVRAM)的設定檔,對應cisco show startup-configuration
[HP]display startup-configuration -
儲存設定檔(Restart時才會維持)
[HP]save -
顯示現有階層下的狀態
[HP]display this -
顯示LACP目前狀態
[HP]dis link-aggregation summary -
顯示版本
[HP]dis version -
變更名稱
[HP]sysname XXX
設定 VLAN 管理 IP (SVI) 與 預設網關 (Gateway)
注意:
- 在 L3 Switch 中,IP 是設定在
vlan-interface上,而非實體 Port。save指令必須回到用戶視圖<HP>執行。
-
Step 1: 建立 L2 環境 (建立 VLAN)
[HP] vlan 10 [HP-vlan10] quit -
Step 2: 建立 L3 介面 (設定 Gateway IP / Range)
[HP] interface vlan-interface 10 [HP-Vlan-interface10] ip address 10.0.10.254 255.255.255.0 [HP-Vlan-interface10] quit注意:若沒做 Step 1 建立 VLAN,直接做 Step 2 有些版本會失敗或無法生效
路由設定 (Routing) - 決定 Outbound 通訊
Q: 什麼時候需要設定 Static Route?
- Case A (Access SW): 僅作為 L2 傳輸,不設路由不影響 Server 上網,但會導致跨網段無法遠端管理 Switch。
- Case B (Core SW): 作為網段 Gateway,若不設預設路由 (0.0.0.0),底下的設備將無法連往外網。
- 設定預設路由 (Default Route)
# 指令邏輯:目的地是不認識的外網時 (0.0.0.0),請交給上層出口設備 # 格式:ip route-static [目的地] [遮罩] [下一跳 IP (Next-hop)] [HP] ip route-static 0.0.0.0 0.0.0.0 192.168.1.254
啟用 Terminal 服務 (純密碼版本)
<HP>system
[HP] user-interface vty 0 4
[HP-ui-vty0-4] authentication-mode password
[HP-ui-vty0-4] set authentication password cipher xxxxx
[HP-ui-vty0-4] user privilege level 3
[HP-ui-vty0-4] quit
[HP] telnet server enable
VLAN 劃分 (Access Port 設定)
-
方法 A:以介面 (Interface) 為中心 (適合單一調整)
[HP] interface gi 1/0/1 [HP-GigabitEthernet1/0/1] port link-type access [HP-GigabitEthernet1/0/1] port access vlan 100 -
方法 B:以 VLAN 為中心 (適合批次大量劃分)
<HP>system [HP] vlan 2 [HP-vlan2] port gi 1/0/3 [HP-vlan3] port gi 1/0/4 to gi 1/0/10 [HP-vlan3] quit
回復原廠預設值
<HP> reset saved-configuration
<HP> reset saved-configuration backup
<HP> reboot
設定 Trunk Port 與 Native VLAN (PVID)
Trunk Port(中繼埠) 的主要用途是讓「多個不同的 VLAN 流量,可以透過同一條實體線路傳輸」。
如果沒有 Trunk Port,當你有 10 個 VLAN 時,兩台交換器之間就必須接 10 條線。
[HP-GigabitEthernet1/0/1] port link-type trunk
[HP-GigabitEthernet1/0/1] port trunk permit vlan all # (必選) 允許所有 VLAN 通過
# (可選) 設定 PVID
# 如果你不需要處理「不帶標籤」的流量,這行可以不打(預設為 1)
[HP-GigabitEthernet1/0/1] port trunk pvid vlan 2
網路聚合 - Link Aggregation (Link Bundling)
以設定光纖模組的 port 25,26 trunk 為例:
# 步驟一:建立聚合群組 1,並設定為動態 LACP 模式 (Link Aggregation Control Protocol)
[HP] interface Bridge-Aggregation 1
[HP-Bridge-Aggregation1] link-aggregation mode dynamic
[HP-Bridge-Aggregation1] quit
# 步驟二:將實體埠 25, 26 加入聚合組
[HP] interface GigabitEthernet 1/0/25
[HP-GigabitEthernet1/0/25] port link-aggregation group 1
[HP-GigabitEthernet1/0/25] quit
[HP] interface GigabitEthernet 1/0/26
[HP-GigabitEthernet1/0/26] port link-aggregation group 1
[HP-GigabitEthernet1/0/26] quit
# 步驟三:在聚合介面上設定 VLAN Trunk
[HP] interface Bridge-Aggregation 1
[HP-Bridge-Aggregation1] port link-type trunk
[HP-Bridge-Aggregation1] port trunk permit vlan all
# 步驟四:檢查聚合狀態 (驗證)
[HP] display link-aggregation summary
# 預期結果說明:
# 1. 觀察 BAGG 1 的 Status 是否為 S (Selected)。
# 2. 如果顯示 U (Unselected),代表實體埠設定不一致或對接端 LACP 未啟動。
# 步驟五:儲存設定 (避免重啟後失效)
[HP] save force
Reference: https://www.lazyfu.com/2016/08/25/switch-command/
Hi! Ⅰ’m at work browsing youг blog from my new iphone!
Just wanted to sаy I love reading through your blog and look
forward to all your posts! Keep up the eҳсellent
work!
Hi, I do think this is a great blog. I stumbledupon it 😉 I may come back yet again since i have saved as a favorite it.
Money and freedom is the greatest way to change, may you be rich and continue
to help other people.
How can I export HPE/Aruba 2530 config setting to another switch? Thanks a lot.
Hi,
You could try the tutorial from this post to see if it works, thanks!
https://community.arubanetworks.com/discussion/hpe-aruba-2530-48g-config-export-to-another-2530-48g-switch