交換命令大全
1.路由器:
dispaly version 顯示系統軟件版本及硬件信息 system-view 切換到系統視圖 quit 返回 interface +接口 進入接口視圖 ip address +IP +mask 配置IP和子網掩碼 return 返回用戶視圖 <Ctrl+Z> 返回用戶視圖 sysname R1 修改路由器名稱為R1 clock timezone BJ add 08:00:00 設置所在的時區為北京 clock datetime 11:23:24 2019-4-9 修改系統日期和時間為2019年4月9日11點23分24秒 header login information “hello” 設置登錄時的標題文本為hello header shell information “Welcom” 設置設備登陸成功后的標題文本信息為“Welcome” display current-configuration 查看路由器當前配置 dispaly interface +接口 查看路由器接口的狀態信息 save 保存當前配置 display ip interface brief 查看接口與IP相關摘要信息 display ip routing-table 查看路由表
2.命令行幫助:
獲取該命令視圖下所有的命令及其簡單描述
interface ? 列出interface全部關鍵字或參數及其簡單描述 rou? 列出以“rou”字符串開頭的所有命令及其簡單描述
3.telnet遠程登陸配置:
user-interface vty 0 4 進入0~4前五個的VTY用戶界面進行整體配置 authentication-mode password 設置驗證方式為密碼 user privilege level 3 設置用戶登陸級別 aaa 進入aaa視圖 local-user admin password cipher hello privilege level 3 在aaa視圖下設置賬號密碼 和用戶級別 local-user admin service-type telnet 配置該用戶接入類型為aaa quit 退回到用戶視圖 user-interface vty 0 4 進入到VTY用戶視圖 authentication-mode aaa 設置驗證方式aaa
4.配置Stelnet:
配置SSH server:rsa local-key-pair create 生成本地RSA主機密鑰對 display rsa local-key-pair public 查看本地密鑰對中的公鑰信息 user-interface vty 0 4 進入VTY用戶視圖 authentication-mode aaa 設置用戶驗證方式為aaa授權驗證方式 protocol inbound ssh 指定VTY用戶只支持ssh quit 返回到系統視圖 aaa 進入aaa視圖 local-user huawei1 password cipher huawei1 創建用戶和設置用戶密碼 local-user huawei1 service-type ssh 配置本地用戶接入類型為ssh quit 退回到用戶視圖 ssh user huawei1 authentication-type password 新建ssh用戶指定ssh用戶認證方式為password aaa 進入aaa視圖 local-user huawei1 privilege level 3 設置huawei1用戶級別為3 級別范圍0~15 stelnet server enable 開啟ssh功能 display ssh user-information huawei1 查看ssh用戶配置信息不指定用戶默認查看所有用戶 display ssh server status 查看ssh服務器全局配置信息
5.配置SSH-client:
server:aaa 進入aaa視圖 local-user huawei2 password cipher huawei2 設置用戶名和密碼 local-user huawei2 service-type ssh 配置本地用戶的接入類型為ssh local-user huawei2 privilege level 3 設置用戶級別為3 local-user huawei2 ftp-directory flash: 指定FTP用戶的可訪問目錄,如果不配置用戶將無法登陸 ssh user huawei2 authentication-type password 新建ssh用戶指定用戶認證方式為密碼 sftp server enable 開啟sftp服務器功能 display ssh server status 查看ssh服務器配置信息 display ssh server session 查看ssh服務器端的當前會話連接信息 client:sftp 10.1.1.2 登陸S2
6.配置通過FTP進行文件操作
ftp 10.0.2.1 連接遠程ftp服務器 ls 查看FTP服務器文件夾狀態 cd +文件夾名 進入文件夾 dir 查看詳細的文件屬性 get +文件名 下載文件到本地 put +舊文件名 +新文件名 上傳文件到FTP服務器 配置路由器為ftp Server sys 進入系統視圖 aaa 進入aaa視圖 local-user ftp password cipher huawei 設置用戶名ftp和密碼huawei local-user ftp ftp-directory flash: 指定FTP用戶的可訪問目錄,如果不配置用戶將無法登陸 local-user ftp service-type ftp 設置服務類型為ftp local-user ftp privilege level 15 設置用戶優先級為15
7.配置交換機雙工模式
interface +接口 進入到某一接口 undo negotiation auto 命令關掉自協商功能 duplex full 指定雙工模式為全雙工 speed 10 配置接口速率為10Mbit/s arp static 10.1.2.3 5489-9827-0ECD 配置靜態arp表 arp-proxy enable 開啟arp代理功能具體到接口
8.劃分vlan
vlan 10 劃分Vlan10 vlan batch 30 40 同時創建vlan30和40 dispaly vlan 查看vlan信息 int e0/0/1 進入某一個接口 port link-type access 配置接口類型為access port default vlan 10 配置接口加入相應的vlan int e0/0/1 進入某一個接口 port link-type trunk 配置接口類型為trunk port trunk allow-pass vlan 10 20 允許vlan 10 20 的數據通過 port trunk allow-pass vlan all 允許所有vlan通過 int e0/0/1 undo port default vlan 恢復接口默認vlan port link-type hybrid 修改接口類型為hybrid port hybrid untagged vlan 20 命令交換機在該接口轉發VLAN 20的幀時,剝離掉相應的VLAN Tag 20,以Untagged的方式發送給PC port hybrid pvid vlan 20 設置hybrid接口的默認VLAN ID port hybrid tagged vlan 10 20 設置該鏈路僅接收帶有VLAN Tag 10 和 20 的幀
9.配置路由器子接口封裝VLAN
interface GigabitEthernet 0/0/1.1 路由器上創建子接口 dot1q termination vid 10 配置子接口對一層tag報文的終結功能 arp broadcast enable 開啟子接口的arp廣播功能
10.三層交換機實現VLAN間路由
vlan batch 10 20 創建VLAN 10 20 int g0/0/1 port link-type access 設置接口類型 port default vlan 10 劃分接口g0/0/1到vlan 10 interface Vlanif 10 創建Vlanif接口設置其對應接口ID為10 ip address 192.168.1.254 24 設置其Vlanif 接口ip地址
11.STP配置和選路規則
stp enable 在交換機上啟用STP stp mode stp dis stp 查看stp配置 dis stp brief 查看接口摘要信息 stp priority 4096 修改交換機優先級為4096 stp root primary 設置交換機為主根交換機 stp root secondary 命令配置備份交換機 display stp interface Ethernet 0/0/2 查看e0/0/2接口的開銷值 int e0/0/2 stp cost 2000 配置接口e0/0/2的帶價值為2000 stp timer forward-delay 3000 修改STP的Forward Delay時間為3000cs也就是30s stp bridge-diameter 3 命令設置網絡的直徑為3 stp mode rstp 啟用RSTP使用RSTP可以縮短收斂時間 int e0/0/1 stp edged-port enable 配置接口e0/0/1為邊緣端口不參與生成樹的計算
12.配置MSTP多實例
1 stp region-configuration 進入MST域視圖 2 region-name huawei 配置MST域名為huawei 3 revision-level 1 配置MSTP的修訂級別為1 4 instance 1 vlan 10 指定VLAN 10映射到MSTI 1 5 active region-configuration 激活MST域配置 6 display stp region-configuration 查看交換機上當前生效的MST域配置信息 7 dis stp instance 0 brief 查看實例0中的生成樹狀態和統計的摘要信息 8 stp instance 2 priority 0 配置交換機成位實例2中的根交換機
13.GVRP基礎配置
int G0/0/1 port link-type trunk 配置接口類型為trunk port trunk allow-pass vlan all 允許所有VLAN通過 int e0/0/1 port link-type access 配置接口類型為access port default vlan 10 將接口e0/0/1劃入VLAN 10 grvp 交換機上開啟GVRP功能 int g0/0/1 gvrp 在接口g0/0/1開啟gGVRP功能,還需在某個交換機的右側接口手動配置VLAN實現雙向注冊GVRP
14.配置Eth-Trunk 1聚合鏈路
interface Eth-Trunk 1 創建Eth-Trunk 1 接口 mode manual load-balance 指定為手工負載分擔模式 int g0/0/1 進入接口 eth-trunk 1 將接口g0/0/1加入到Eth-Trunk 1接口 display eth-trunk 1 查看Eth-Trunk 1接口狀態 int g0/0/1 進入接口 undo eth-trunk 刪除聚合鏈路接口下的g0/0/1 mode lacp-static 將工作模式改為靜態LACP,然后將所有接口加入到聚合鏈路Eth-trunk 1 lacp priority 100 修改交換機優先級為一百 (值越低優先級越高) interface Eth-Trunk 1 max active-linknumber 2 設置活動接口的上限閾值,接下來修改聚合鏈路中接口g0/0/1和g0/0/2的優先級
15.配置浮動靜態路由實現路由備份(網絡冗余)
ip route-static 192.168.20.0 24 10.0.12.2 preference 100 設置備份路由并將優先級設置為100 display ip routing-table protocol static 查看靜態路由的路由信息
16.RIP路由協議配置
rip 創建開啟協議進程 network + ip 對指定網段接口使能RIP功能IP地址是與路由器直連的網段 debugging rip 1 查看RIP定期更新情況 terminal debugging terminal monitor 在屏幕上顯示debug信息 undo debugging rip 1undo debug all 命令關閉debug調試功能 在上面的配置基礎上配置RIP2 rip 進入子視圖模式 version 2 配置版本 或者直接配置 rip 1 version 2 network + ip rip簡單認證 rip authentication-mode simple huawei 在需要的路由器上配置密碼要相同
17.配置RIPv2 MD5 密文驗證
rip authentication-mode md5 usual huawei 方式使用MD5密文驗證,使用通用報文格式,兩端報文格式必須一致 dis default-parameter rip 查看RIP配置信息
18.配置RIPv2自動匯總路由(默認關閉)
方法1: rip 1 version 2 summary always 方法2: int + 接口 undo rip split-horizon 關閉水平分割功能
19.配置RIPv2手動匯總(需停止RIPv2自動匯總功能)
int + 接口 rip summary-address 3.3.0.0 255.255.252.0 手動匯總ip+掩碼 配置RIP版本兼容 rip version 2 broadcast 命令路由器以廣播的形式發送RIPv2報文 rip version 2 multicast 命令路由器以組播的形式發送RIPv2報文
20.配置RIP定時器,優先級
int + 接口 undo rip output 讓路由器停止發送RIP路由更新 display rip 1 database 檢查RIP發布數據庫中的所有路由激活 rip timers rip 20 120 60 設置更新報文時間為20s,超時計時器為120s,垃圾收集計時器為60s preference 90 修改RIP協議優先級為90
21.配置抑制接口(只接受RIP更新報文,不發送更新報文)
rip 1 silent-interface GigabitEthernet 0/0/0 設置要抑制的接口配置RIP單播更新(由于配置了抑制接口,接口無法以廣播或者組播的方式發送RIP更新報文) rip 1 peer 172.16.1.100 IP地址為鄰居路由器的IP地址另一種方法(刪除上面的配置) undo rip output 禁止這個接口發送RIP報文 undo rip input 禁止這個接口接收RIP報文
22.RIP與不連續子網(解決不連續子網問題)
方法1給接口配置第二個IP地址,應該取配置網段的子網,適合小型網絡 ip address 10.0.23.2 sub 方法2使用RIPv2,關閉自動匯總 rip version 2 undo summary undo rip split-horizon 關閉水平分割功能(進入接口) rip split-horizon 開啟水平分割功能 rip poison-reverse 開啟毒性逆轉功能 增加度量值(進入接口) rip metricin 2 增加度量值2端口出去的跳數 rip metricout 2 增加度量值2端口進來的跳數 Rip路由引入(需保證被引入的路由條目已經存在于當前設備中) rip import-route direct 直連路由,一般是本地接口的地址 rip import-route static 靜態路由,是引入的你在設備上配置的靜態路由。
23.OSPF單區域配置
ospf 1 進入ospf視圖1代表進程號 area 0 創建區域并進入OSPF區域視圖,輸入要創建的區域ID,骨干區域即區域0 network +IP +匹配碼 display ospf interface 命令查看OSPF接口通告是否正確、 display ospf peer 查看OSPF鄰居狀態 display ip routing-table protocol ospf 查看OSPF路由表
24.配置OSPF區域明文認證
ospf 1 area 1 authentication-mode simple plain huawei plain是口令以明文方式顯示 authentication-mode md5 1 huawei 配置區域密文認證
25.配置鏈路認證
int g0/0/1 ospf authentication-mode md5 1 huawei 在一條鏈路中的兩個接口配置要相同
26.配置抑制接口
ospf 1 silent-interface GigabitEthernet 0/0/1 禁止接口g0/0/1接收和發送ospf報文技巧對多個接口配置接口抑制 ospf 1 silent-interface all 抑制所有接口 un display ip routing-table 10.0.1.1 查看10.0.1.1所在網段的路由條目 基于接口修改 int g0/0/0 ospf network-type p2mp 修改ospf的網絡類型為多到多點 ospf network-type broadcast 修改ospf的網絡類型為廣播 ospf dr-priority 100 修改g0/0/0接口的DR優先級為100 reset ospf process 重啟ospf進程 ospf cost 1000 修改ospf的開銷值為1000 ospf timer hello 20 修改HELLO計時器為20s ospf timer dead 80 修改dead計時器為80s ospf 1 preference 110 修改ospf優先級為110 值越大優先級越低
27.路由引入:
ospf 1 import-route rip 1 在ospf進程中引入rip default-route-advertise always 在ospf進程中引入默認路由 rip import-route ospf 1 在rip進程中引入ospf import-route ospf cost 3 ospf 引入rip時配置開銷值 default-route originate 在RIP進程中發布默認路由
28.vrrp(虛擬路由器冗余協議)基本配置
int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 創建VRRP備份組,備份組號為1,配置虛擬IP為172.16.1.254 vrrp vrid 1 priority 120 修改優先級為120 display vrrp 查看vrrp信息 display vrrp brief display vrrp interface g0/0/0 查看VRRP的工作狀態
29.配置VRRP多備份組
int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 創建VRRP備份組,備份組號為1,配置虛擬IP為172.16.1.254 vrrp vrid 1 priority 120 修改優先級為120 vrrp vrid 2 virtual-ip 172.16.1.253 創建VRRP備份組,備份組號為2,配置虛擬IP為172.16.1.253 int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 創建VRRP備份組,備份組號為1,配置虛擬IP為172.16.1.254 vrrp vrid 2 virtual-ip 172.16.1.253 創建VRRP備份組,備份組號為2,配置虛擬IP為172.16.1.253 vrrp vrid 2 priority 120 修改優先級為120 vrrp vrid 2 preempt-mode disable 開啟非搶占方式
30.配置VRRP的跟蹤接口及認證
int g0/0/1 vrrp vrid 1 track interface GigabitEthernet 0/0/0 reduced 50 監視上行接口G0/0/0,當此接口斷掉時,裁減優先級50,使優先級為70 vrrp vrid 1 authentication-mode md5 huawei 認證配置

浙公網安備 33010602011771號