華為交換機設(shè)備基礎(chǔ)命令大全,拿走不謝!
七彩-穎欣老師
大家好,我是穎欣老師。華為、華三、銳捷網(wǎng)絡(luò)設(shè)備是我們經(jīng)常用到的,對于交換機的配置,我們有的不是網(wǎng)絡(luò)工程師,很復(fù)雜的配置,我們也不需要學(xué)會,除非你專職網(wǎng)絡(luò)工作的,但是對于一些基礎(chǔ)的網(wǎng)絡(luò)配置,我們還是需要了解的,比如一些VLAN的命令,記不住的話,也可以收藏,到時用的時候拿出來就可以了。
01交換機的基礎(chǔ)命令匯總
system-view? ? ?進入系統(tǒng)視圖
quit? ? ?退到系統(tǒng)視圖
sysname? ? ?交換機命名
vlan 20? ? ?創(chuàng)建vlan(進入vlan20)
display vlan? ? 顯示vlan
undo vlan 20? ? 刪除vlan20
display vlan 20 顯示vlan里的端口20
Interface e1/0/24 進入端口24
portlink-type access? ? ?vlan 20 把當(dāng)前端口放入vlan20
undo porte1/0/10 刪除當(dāng)前VLAN端口10
display current-configuration 顯示當(dāng)前配置
02配置交換機支持TELNET
interfacevlan 1 進入VLAN1
ip address192.168.3.100 255.255.255.0 配置IP地址
user-interfacevty 0 4 進入虛擬終端
authentication-modepassword (aut password) 設(shè)置口令模式
setauthentication password simple 222 (set aut pass sim 222) 設(shè)置口令
userprivilege level 3(use priv lev 3) 配置用戶級別
dispcurrent-configuration (disp cur) 查看當(dāng)前配置
display ipinterface 查看交換機VLANIP配置
resetsaved-configuration(reset saved) 刪除配置(必須退到用戶模式)
reboot重啟交換機
03跨交換機VLAN的通訊
在sw1上:
vlan 10建立VLAN 10
interfacee1/0/5 進入端口5
Portdefault vlan 10 把端口5加入vlan10
vlan 20建立VLAN 20
interfacee1/0/15 進入端口15
portdefault vlan 20 把端口15加入VLAN20
interfacee1/0/24 進入端口24
portlink-type trunk 把24端口設(shè)為TRUNK端口
port trunkpermit vlan all 所有端口都能經(jīng)過此路徑
在SW2上:
vlan 10建立VLAN 10
interfacee1/0/20 進入端口20
portdefault vlan 10 把端口20放入VLAN10
interfacee1/0/24 進入端口24
portlink-type trunk 把24端口設(shè)為TRUNK端口
port trunkpermit vlan all (port trunk permit vlan 10 只能為vlan10使用)24端口為所有VLAN使用
displayinterface e1/0/24 查看端口24是否為TRUNK
undo porttrunk permit vlan all 刪除該句
04路由器的基礎(chǔ)命令匯總
dispaly version 顯示系統(tǒng)軟件版本及硬件信息
system-view 切換到系統(tǒng)視圖
quit 返回
interface +接口 進入接口視圖
ip address +IP +mask 配置IP和子網(wǎng)掩碼
return 返回用戶視圖
<Ctrl+Z> 返回用戶視圖
sysname R1 修改路由器名稱為R1
display current-configuration 查看路由器當(dāng)前配置
dispaly interface +接口查看路由器接口的狀態(tài)信息
save 保存當(dāng)前配置
display ip interface brief 查看接口與IP相關(guān)摘要信息
display ip routing-table 查看路由表
05telnet遠程登陸配置
user-interface vty 0 4 進入0~4前五個的VTY用戶界面進行整體配置
authentication-mode password 設(shè)置驗證方式為密碼
user privilege level 3 設(shè)置用戶登陸級別
aaa 進入aaa視圖
local-user admin password cipher hello privilege level 3在aaa視圖下設(shè)置賬號密碼和用戶級別
local-user admin service-type telnet 配置該用戶接入類型為aaa
q 退回到用戶視圖
user-interface vty 0 4 進入到VTY用戶視圖
authentication-mode aaa 設(shè)置驗證方式aaa
06配置Stelnet
配置SSHserver:rsalocal-key-pair create 生成本地RSA主機密鑰對
display rsa local-key-pair public 查看本地密鑰對中的公鑰信息
user-interface vty 0 4 進入VTY用戶視圖
authentication-mode aaa 設(shè)置用戶驗證方式為aaa授權(quán)驗證方式
protocol inbound ssh 指定VTY用戶只支持ssh
q 返回到系統(tǒng)視圖
aaa 進入aaa視圖
local-user huawei1 password cipher huawei1 創(chuàng)建用戶和設(shè)置用戶密碼
local-user huawei1 service-type ssh 配置本地用戶接入類型為ssh
q 退回到用戶視圖
ssh user huawei1 authentication-type password新建ssh用戶指定ssh用戶認證方式為password
aaa 進入aaa視圖
local-user huawei1 privilege level 3 設(shè)置huawei1用戶級別為3級別范圍0~15
stelnet server enable 開啟ssh功能
display ssh user-information huawei1 查看ssh用戶配置信息不指定用戶默認查看所有用戶
display ssh server status 查看ssh服務(wù)器全局配置信息
07STP配置和選路規(guī)則
stp enable 在交換機上啟用STP
stp mode stp
dis stp 查看stp配置
dis stp brief 查看接口摘要信息
stp priority 4096 修改交換機優(yōu)先級為4096
stp root primary 設(shè)置交換機為主根交換機
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的ForwardDelay時間為3000cs也就是30s
stp bridge-diameter 3 命令設(shè)置網(wǎng)絡(luò)的直徑為3
stp mode rstp 啟用RSTP使用RSTP可以縮短收斂時間
int e0/0/1
stp edged-port enable 配置接口e0/0/1為邊緣端口不參與生成樹的計算
08配置MSTP多實例
stp region-configuration 進入MST域視圖
region-name huawei 配置MST域名為huawei
revision-level 1 配置MSTP的修訂級別為1
instance 1 vlan 10 指定VLAN10映射到MSTI1
active region-configuration 激活MST域配置
display stp region-configuration 查看交換機上當(dāng)前生效的MST域配置信息
dis stp instance 0 brief 查看實例0中的生成樹狀態(tài)和統(tǒng)計的摘要信息
stp instance 2 priority 0 配置交換機成位實例2中的根交換機
09RIP路由協(xié)議配置
rip 創(chuàng)建開啟協(xié)議進程
network + ip 對指定網(wǎng)段接口使能RIP功能IP地址是與路由器直連的網(wǎng)段
debugging rip 1 查看RIP定期更新情況
terminal debugging
terminal monitor 在屏幕上顯示debug信息
undo debugging rip 1undo debug all 命令關(guān)閉debug調(diào)試功能
在上面的配置基礎(chǔ)上配置RIP2
rip 進入子視圖模式
version 2 配置版本
或者直接配置
rip 1
version 2
network + ip
10OSPF單區(qū)域配置
ospf 1 進入ospf視圖1代表進程號
area 0 創(chuàng)建區(qū)域并進入OSPF區(qū)域視圖,輸入要創(chuàng)建的區(qū)域ID,骨干區(qū)域即區(qū)域0
network +IP +匹配碼
display ospf interface 命令查看OSPF接口通告是否正確、
display ospf peer 查看OSPF鄰居狀態(tài)
display ip routing-table protocol ospf 查看OSPF路由表
11配置OSPF區(qū)域明文認證
ospf 1
area 1
authentication-mode simple plain huawei plain是口令以明文方式顯示
authentication-mode md5 1 huawei 配置區(qū)域密文認證
12配置鏈路認證
int g0/0/1
ospf authentication-mode md5 1 huawei 在一條鏈路中的兩個接口配置要相同
13配置抑制接口
ospf 1
silent-interface GigabitEthernet 0/0/1 禁止接口g0/0/1接收和發(fā)送ospf報文
14技巧對多個接口配置接口抑制
ospf 1
silent-interface all 抑制所有接口
un
display ip routing-table 10.0.1.1 查看10.0.1.1所在網(wǎng)段的路由條目
15基于接口修改
int g0/0/0
ospf network-type p2mp 修改ospf的網(wǎng)絡(luò)類型為多到多點
ospf network-type broadcast 修改ospf的網(wǎng)絡(luò)類型為廣播
ospf dr-priority 100 修改g0/0/0接口的DR優(yōu)先級為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優(yōu)先級為110值越大優(yōu)先級越低
16路由引入
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進程中發(fā)布默認路由
17vrrp(虛擬路由器冗余協(xié)議)基本配置
int g0/0/0
vrrp vrid 1 virtual-ip 172.16.1.254創(chuàng)建VRRP備份組,備份組號為1,配置虛擬IP為172.16.1.254
vrrp vrid 1 priority 120 修改優(yōu)先級為120
display vrrp 查看vrrp信息
display vrrp brief
display vrrp interface g0/0/0 查看VRRP的工作狀態(tài)
18配置VRRP多備份組
int g0/0/0
vrrp vrid 1 virtual-ip 172.16.1.254創(chuàng)建VRRP備份組,備份組號為1,配置虛擬IP為172.16.1.254
vrrp vrid 1 priority 120 修改優(yōu)先級為120
vrrp vrid 2 virtual-ip 172.16.1.253創(chuàng)建VRRP備份組,備份組號為2,配置虛擬IP為172.16.1.253
int g0/0/0
vrrp vrid 1 virtual-ip 172.16.1.254創(chuàng)建VRRP備份組,備份組號為1,配置虛擬IP為172.16.1.254
vrrp vrid 2 virtual-ip 172.16.1.253創(chuàng)建VRRP備份組,備份組號為2,配置虛擬IP為172.16.1.253
vrrp vrid 2 priority 120 修改優(yōu)先級為120
vrrp vrid 2 preempt-mode disable 開啟非搶占方式
19配置VRRP的跟蹤接口及認證
int g0/0/1
vrrp vrid 1 track interface GigabitEthernet 0/0/0 reduced 50監(jiān)視上行接口G0/0/0,當(dāng)此接口斷掉時,裁減優(yōu)先級50,使優(yōu)先級為70
vrrp vrid 1 authentication-mode md5 huawei 認證配置
20配置基本的訪問控制表
acl 2000 創(chuàng)建一個編號型ACL,基本ACL的范圍是2000~29999
rule 5 permit source 1.1.1.1 0指定規(guī)則ID為5,允許數(shù)據(jù)源地址為1.1.1.1的報文通過,反掩碼全為0,即精確匹配
rule 10 deny source any 指定ID為10,拒絕任意源地址的數(shù)據(jù)包通過
display acl all 查看設(shè)備上所有的訪問控制列表
