華為交換機(jī)基本配置命令,附三大品牌命令對比表
我們從事弱電集成工作,會一些簡單的交換機(jī)配置還是有必要的,想深入學(xué)習(xí)的話,還是要偏向于網(wǎng)絡(luò)工程師了。
正文:
一、單交換機(jī)VLAN劃分
命令 命令解釋
system 進(jìn)入系統(tǒng)視圖
system-view 進(jìn)入系統(tǒng)視圖
quit 退到系統(tǒng)視圖
undo vlan 20 刪除vlan 20
sysname 交換機(jī)命名
disp vlan 顯示vlan
vlan 20 創(chuàng)建vlan(也可進(jìn)入vlan 20)
port e1/0/1 to e1/0/5 把端口1-5放入VLAN 20 中
5700系列
單個端口放入VLAN
[Huawei]int g0/0/1
[Huawei]port link-type access (注:接口類型access,hybrid、trunk)
[Huawei]port default vlan 10
批量端口放入VLAN
[Huawei]port-group 1
[Huawei-port-group-1]group-member ethernet G0/0/1 to ethernetG0/0/20
[Huawei-port-group-1]port hybrid untagged vlan 3
刪除group(組)vlan 200內(nèi)的15端口
[Huawei]int g0/0/15
[Huawei-GigabitEthernet0/0/15]undo port hybrid untagged vlan 200
通過group端口限速設(shè)置
[Huawei]Port-group 2
[Huawei]group-member g0/0/2 to g0/0/23
[Huawei]qos lr outbound cir 2000 cbs 20000
disp vlan 20 顯示vlan里的端口20
int e1/0/24 進(jìn)入端口24
undo port e1/0/10 表示刪除當(dāng)前VLAN端口10
disp curr 顯示當(dāng)前配置
return 返回
Save 保存
info-center source DS channel 0 log state off trap stateoff 通過關(guān)閉日志信息命令改變DS模塊來實現(xiàn)(關(guān)閉配置后的確認(rèn)信息顯示)
info-center source DS channel 0 log state on trap stateon 通過打開日志信息命令改變DS模塊來實現(xiàn)(打開配置后的確認(rèn)信息顯示)
二、配置交換機(jī)支持TELNE
system 進(jìn)入系統(tǒng)視圖
sysname 交換機(jī)命名
int vlan 1 進(jìn)入VLAN 1
ip address 192.168.3.100 255.255.255.0 配置IP地址
user-int vty 0 4 進(jìn)入虛擬終端
authentication-mode password (aut password) 設(shè)置口令模式
set authentication password simple 222 (set aut pass sim 222) 設(shè)置口令
user privilege level 3(use priv lev 3) 配置用戶級別
disp current-configuration (disp cur) 查看當(dāng)前配置
disp ip int 查看交換機(jī)VLAN IP配置
刪除配置必須退到用戶模式
reset saved-configuration(reset saved) 刪除配置
Reboot 重啟交換機(jī)
三、跨交換機(jī)VLAN的通訊
在sw1上:
vlan 10 建立VLAN 10
int e1/0/5 進(jìn)入端口5
port access vlan 10 把端口5加入vlan 10
vlan 20 建立VLAN 20
int e1/0/15 進(jìn)入端口15
port access vlan 20 把端口15加入VLAN 20
int e1/0/24 進(jìn)入端口24
port link-type trunk 把24端口設(shè)為TRUNK端口
port trunk permit vlan all 同上
在SW2上:
vlan 10 建立VLAN 10
int e1/0/20 進(jìn)入端口20
port access vlan 10 把端口20放入VLAN 10
int e1/0/24 進(jìn)入端口24
port link-type trunk 把24端口設(shè)為TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能為vlan 10使用)24端口為所有VLAN使用
disp int e1/0/24 查看端口24是否為TRUNK
undo port trunk permit vlan all 刪除該句
四、路由的配置命令
system 進(jìn)入系統(tǒng)模式
sysname 命名
int e1/0 進(jìn)入端口
ip address 192.168.3.100 255.255.255.0 設(shè)置IP
undo shutdown 打開端口
disp ip int e1/0 查看IP接口情況
disp ip int brief 查看IP接口情況
user-int vty 0 4 進(jìn)入口令模式
authentication-mode password(auth pass) 進(jìn)入口令模式
set authentication password simple 222 37 設(shè)置口令
user privilege level 3 進(jìn)入3級特權(quán)
save 保存配置
reset saved-configuration 刪除配置(用戶模式下運行)
undo shutdown 配置遠(yuǎn)程登陸密碼
int e1/4
ip route 192.168.3.0(目標(biāo)網(wǎng)段) 255.255.255.0 192.168.12.1(下一跳:下一路由器的接口) 靜態(tài)路由
ip route 0.0.0.0 0.0.0.0 192.168.12.1 默認(rèn)路由
disp ip rout 顯示路由列表
華3C AR-18
E1/0(lan1-lan4)
E2/0(wan0)
E3/0(WAN1)
路由器連接使用直通線。wan0接wan0或wan1接wan1
計算機(jī)的網(wǎng)關(guān)應(yīng)設(shè)為路由器的接口地址。
五、三層交換機(jī)配置VLAN-VLAN通訊
sw1(三層交換機(jī)):
system 進(jìn)入視圖
sysname 命名
vlan 10 建立VLAN 10
vlan 20 建立VLAN 20
int e1/0/20 進(jìn)入端口20
port access vlan 10 把端口20放入VLAN 10
int e1/0/24 進(jìn)入24端口
port link-type trunk 把24端口設(shè)為TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能為vlan 10使用)24端口為所有VLAN使用
sw2:
vlan 10
int e1/0/5
port access vlan 10
int e1/0/24
port link-type trunk 把24端口設(shè)為TRUNK端口
port trunk permit vlan all (port trunk permit vlan 10 只能為vlan 10使用)24端口為所有VLAN使用
sw1(三層交換機(jī)):
int vlan 10 創(chuàng)建虛擬接口VLAN 10
ip address 192.168.10.254 255.255.255.0 設(shè)置虛擬接口VLAN 10的地址
int vlan 20 創(chuàng)建虛擬接口VLAN 20
ip address 192.168.20.254 255.255.255.0 設(shè)置虛擬接口IP VLAN 20的地址
注意:vlan 10里的計算機(jī)的網(wǎng)關(guān)設(shè)為 192.168.10.254
vlan 20里的計算機(jī)的網(wǎng)關(guān)設(shè)為 192.168.20.254
六、動態(tài)路由RIP
R1:
int e1/0 進(jìn)入e1/0端口
ip address 192.168.3.1 255.255.255.0 設(shè)置IP
int e2/0 進(jìn)入e2/0端口
ip adress 192.168.5.1 255.255.255.0 設(shè)置IP
rip 設(shè)置動態(tài)路由
network 192.168.5.0 定義IP
network 192.168.3.0 定義IP
disp ip rout 查看路由接口
R2:
int e1/0 進(jìn)入e1/0端口
ip address 192.168.4.1 255.255.255.0 設(shè)置IP
int e2/0 進(jìn)入e2/0端口
ip adress 192.168.5.2 255.255.255.0 設(shè)置IP
rip 設(shè)置動態(tài)路由
network 192.168.5.0 定義IP
network 192.168.4.0 定義IP
disp ip rout 查看路由接口
(注意:兩臺PC機(jī)的網(wǎng)關(guān)設(shè)置PC1 IP:192.168.3.1PC2 IP:192.168.4.1)
七、IP訪問列表
int e1/0
ip address 192.168.3.1 255.255.255.0
int e2/0
ip address 192.168.1.1 255.255.255.0
int e3/0
ip address 192.168.2.1 255.255.255.0
acl number 2001 (2001-2999屬于基本的訪問列表)
rule 1 deny source 192.168.1.0 0.0.0.255 (拒絕地址192.168.1.0網(wǎng)段的數(shù)據(jù)通過)
rule 2 permit source 192.168.3.0 0.0.0.255(允許地址192.168.3.0網(wǎng)段的數(shù)據(jù)通過)
以下是把訪問控制列表在接口下應(yīng)用:
firewall enable
firewall default permit
int e3/0
firewall packet-filter 2001 outbound
disp acl 2001 顯示信息
undo acl number 2001 刪除2001控制列表
擴(kuò)展訪問控制列表
acl number 3001
rule deny tcp source 192.168.3.0 0.0.0.255 destination 192.168.2.00.0.0.255 destination-port eq ftp
必須在r-acl-adv-3001下才能執(zhí)行
rule permit ip source an destination any (rule permit ip)
int e3/0
firewall enable 開啟防火墻
firewall packet-filter 3001 inbound
必須在端口E3/0下才能執(zhí)行
八、華為/思科/華三交換機(jī)配置命令華為/思科/華三交換機(jī)配置命令有些分不清楚,這里對三者配置命令做了個匯總對比,希望對大家有所幫助。
CISCO |
H3C |
HUAWEI |
描述 |
no |
undo |
undo |
取消、關(guān)閉當(dāng)前設(shè)置 |
show |
display |
display |
顯示查看 |
exit |
quit |
quit |
退回上級 |
hostname |
sysname |
sysname |
設(shè)置主機(jī)名 |
en, config terminal |
system-view |
system-view |
進(jìn)入全局模式 |
delete |
delete |
delete |
刪除文件 |
reload |
reboot |
reboot |
重啟 |
write |
save |
save |
保存當(dāng)前配置 |
username |
local-user |
local-user |
創(chuàng)建用戶 |
shutdown |
shutdown |
shutdown |
禁止、關(guān)閉 端口 |
show version |
display version |
display version |
顯示當(dāng)前系統(tǒng)版本 |
show startup-config |
display saved-configuration |
display saved-configuration |
查看已保存過的配置 |
show running-config |
display current-configuration |
display current-configuration |
顯示當(dāng)前配置 |
no debug all |
ctrl+d |
ctrl+d |
取消所有debug命令 |
erase startup-config |
reset saved-configuration |
reset saved-configuration |
刪除配置 |
end |
return |
return |
退到用戶視圖 |
exit |
logout |
logout |
登出 |
logging |
info-center |
info-center |
指定信息中心配置信息 |
line |
user-interface |
user-interface |
進(jìn)入線路配置(用戶接口)模式 |
start-config |
saved-configuration |
saved-configuration |
啟動配置 |
running-config |
current-configuration |
current-configuration |
當(dāng)前配置 |
host |
ip host |
ip host |
host名字和ip地址對應(yīng) |
交換部分 |
|||
enable password |
set authentication password simple |
set authentication password simple |
配置明文密碼 |
interface type/number |
interface type/number |
interface type/number |
進(jìn)入接口 |
interface vlan 1 |
interface vlan 1 |
interface vlan 1 |
進(jìn)入vlan配置vlan管理地址 |
interface rang |
interface ethID to ID |
interface ethID to ID |
定義多個端口的組 |
enabl esecret |
super password |
super password |
設(shè)置特權(quán)口令 |
duplex (half|full|auto) |
duplex (half|full|auto) |
duplex (half|full|auto) |
配置接口狀態(tài) |
speed (10/100/1000) |
speed (10/100/1000) |
speed (10/100/1000) |
配置端口速率 |
switchport mode trunk |
port link-type trunk |
port link-type trunk |
配置trunk |
vlan ID /no vlan ID |
vlan batch ID /undo vlan batch ID |
vlan batch ID /undo vlan batch ID |
添加、刪除vlan |
switchport access vlan |
port default vlan ID |
port acces vlan ID |
將端口接入vlan |
show interface |
display interface |
display interface |
查看接口 |
show vlan ID |
display vlan ID |
display vlan ID |
查看vlan |
encapsulation |
link-protocol |
link-protocol |
封裝協(xié)議 |
channel-group 1 mode on |
port link-aggregation group 1 |
port link-aggregation group 1 |
鏈路聚合 |
ip routing |
默認(rèn)開啟 |
默認(rèn)開啟 |
開啟三層交換的路由功能 |
no switchport |
不支持 |
不支持 |
開啟接口三層功能 |
vtp domain |
GVRP |
GVRP |
對跨以太網(wǎng)交換機(jī)的VLAN進(jìn)行動態(tài)注冊和刪除 |
spanning-tree vlan ID root primary |
stp instance id root primary |
stp instance id root primary |
stp配置根網(wǎng)橋 |
spanning-tree vlan ID priority |
stp primary vlaue |
stp primary vlaue |
配置網(wǎng)橋優(yōu)先級 |
show spanning-tree |
dis stp brief |
dis stp brief |
查看STP配置 |
路由部分 |
|||
ip route 0.0.0.0 0.0.0.0 |
ip route-static 0.0.0.0 0.0.0.0 |
ip route-static 0.0.0.0 0.0.0.0 |
配置默認(rèn)路由 |
ip route 目標(biāo)網(wǎng)段+掩碼 下一跳 |
ip route-static 目標(biāo)網(wǎng)段+掩碼 下一跳 |
ip route-static 目標(biāo)網(wǎng)段+掩碼 下一跳 |
配置靜態(tài)路由 |
show ip route |
display ip routing-table |
display ip routing-table |
查看路由表 |
router rip /network 網(wǎng)段 |
rip /network 網(wǎng)段 |
rip /network 網(wǎng)段 |
啟用rip、并宣告網(wǎng)段 |
router ospf |
ospf |
ospf |
啟用ospf |
network ip 反碼 area <area-id> |
area <area-id> |
area <area-id> |
配置OSPF區(qū)域 |
no auto-summary |
rip split-horizon |
rip split-horizon |
配置RIP V2水平分割 |
show ip protocol |
display ip protocol |
display ip protocol |
查看路由協(xié)議 |
access-list 1-99 permit/deny IP |
rule id permit source IP |
rule id permit source IP |
標(biāo)準(zhǔn)訪問控制列表 |
access-list 100-199 permit/deny protocol source IP+反碼 destination IP+反碼 operator operan |
rule {normal|special}{permit|deny}{tcp|udp}source {<ip wild>|any}destination <ip wild>|any}[operate] |
rule {normal|special}{permit|deny}{tcp|udp}source {<ip wild>|any}destination <ip wild>|any}[operate] |
擴(kuò)展訪問控制列表 |
standby group-number ip virtual-ip |
vrrp vrid number virtual-ip |
vrrp vrid number virtual-ip |
配置HSRP組 |
standby group-number priority |
vrrp vrid number priority |
vrrp vrid number priority |
配置HSRP優(yōu)先級 |
standby group-number preempt |
vrrp vrid number preempt-mode |
vrrp vrid number preempt-mode |
配置HSRP占先權(quán) |
standby group-number track |
|
|
配置端口跟蹤 |
ip nat inside source static |
nat server global <ip> [port] inside <ip> port [protocol] |
nat server global <ip> [port] inside <ip> port [protocol] |
配置靜態(tài)地址轉(zhuǎn)換
|