华为交换机命令配置⼤全,看完赶快收藏
最近整理了⼀份关于华为交换机配置的命令⼤全,现在分享给⼤家,还请各位记得点赞收藏哦!内容有些多,但都是纯纯的⼲货,现在整理分享给⼤家,希望对学习⽹络的同⾏有所帮助。
#配置交换机名称、管理vlan、IP地址
//⽤户视图
system-view //进⼊系统视图配置
[Huawei]sysname Switch1 //修改设备名称为SW1
[Switch1]vlan X //设置交换机管理vlan x
[Switch1-vlan x]management-vlan
[Switch1-vlan x]quit //退出
[Switch1] interface vlanif X //创建交换机管理vlanif
[Switch1-vlanifX]in //配置配置vlanif接⼝IP地址
[Switch1-vlanifX]quit //退出
#配置交换机远程登录管理Telnet
[Switch1]telnet server enable //telnet默认是关闭的,需打开
[Switch1]user-interface vty 0 4 //开启VTY线路模式
[Switch1-ui-vty0-4]protocol inbound telnet //配置telnet协议
[Switch1-ui-vty0-4]authentication-mode xxx //配置认证⽅式
[Switch1-ui-vty0-4]quit //退出
[Switch1]xxx
[Switch1-xxx]local-user admin password cipher xxxx //配置⽤户名和密码,⽤户名不区分⼤⼩写,密码区分⼤⼩写
[Switch1-xxx]local-user admin privilege level 15 //将管理员账号权限设置为15
[Switch1-xxx]quit //退出
[Switch1]quit //退出
< Switch1>save //在⽤户视图下保存配置
#配置交换机端⼝隔离、速率、双⼯等
#配置接⼝GE1/0/1和GE1/0/2的端⼝隔离功能,实现两个接⼝之间的⼆层数据隔离,三层数据互通
< Switch1>system-view //进⼊系统视图配置
[Switch1]port-isolate mode 12
[Switch1]interface gigabitethernet 1/0/1
[Switch1- gigabitethernet 1/0/1]port-isolate enable group 1
[Switch1- gigabitethernet 1/0/1]quit
[Switch1]interface gigabitethernet 1/0/2
[Switch1- gigabitethernet 1/0/2]port-isolate enable group 1
[Switch1- gigabitethernet 1/0/2]quit
#配置以太⽹接⼝GE0/0/1在⾃协商模式下协商速率为100Mb/s
< Switch1>system-view
[Switch1]interface gigabitethernet 0/0/1
[Switch1- gigabitethernet 0/0/1]negotiation auto
[Switch1- gigabitethernet 0/0/1]auto speed 100
#配置以太⽹接⼝GE0/0/1在⾃协商模式下双⼯模式为全双⼯模式
< Switch1>sys-view
[Switch1] interface gigabitethernet 0/0/1
[Switch1- gigabitethernet 0/0/1]negotiation auto
#查看交换机MAC、vlan下MAC绑定
#执⾏命令 display mac-addresss,可查看所有MAC地址表项
#在MAC地址表中增加静态MAC地址表项,⽬的MAC地址为xxxx-xxxx-xxxx,vlan Xd的报⽂从接⼝gigabitethernet X/X/X转发出去[Switch1]mac-address static xxxx-xxxx-xxxx gigabitethernet X/X/X vlan X
cipher命令#执⾏命令 display interface vlanif X,显⽰vlanif接⼝的MAC地址
#交换机接⼝划分vlan:静态vlan
//⽤户视图
system-view //进⼊系统视图配置
[Huawei]sysname Switch1 //修改设备名称为SW1
[Switch1]vlan batch X //批量⽅式建⽴vlan X
[Switch1]interface gigabitethernet X/X/1 //进⼊交换机接⼝视图
[Switch1- gigabitethernet x/x/1]port link-type access //配置接⼝类型
[Switch1- gigabitethernet x/x/1]port default vlan X //将接⼝加⼊vlan X
[Switch1- gigabitethernet x/x/1]quit
[Switch1]interface gigabitethernet X/X/2
[Switch1- gigabitethernet x/x/2]port link-type trunk
[Switch1- gigabitethernet x/x/2]port trunk allow-pass vlan X
[Switch1- gigabitethernet x/x/2]quit
#交换机基于mac划分vlan:动态vlan
[Switch1]vlan batch X //批量⽅式建⽴vlan X
[Switch1]interface gigabitethernet X/X/1 //在接⼝视图配置上联接⼝
[Switch1- gigabitethernet x/x/1]port link-type hybrid //配置上联接⼝类型
[Switch1- gigabitethernet x/x/1]port hybrid tagged vlan X //通过vlanX
[Switch1- gigabitethernet x/x/1]quit
[Switch1]interface gigabitethernet X/X/2 //进⼊交换机接⼝视图
[Switch1- gigabitethernet x/x/2]port link-type hybrd //配置接⼝类型
[Switch1- gigabitethernet x/x/2]port hybrid untagged vlan X //将接⼝加⼊vlanX
[Switch1- gigabitethernet x/x/2]quit
[Switch1]vlan X
[Switch1-vlanX]mac-vlan mac-address xx-xx-xx //pc的mac地址与vlanX关联
[Switch1-vlanX]quit
[Switch1]interface gigabitethernet X/X/2
[Switch1- gigabitethernet x/x/2]mac-vlan enable //基于MAC地址启⽤接⼝
[Switch1- gigabitethernet x/x/2]quit
#基于GVER的vlan实验:可在交换机1创建vlanX,交换机2可以学到,ping通
//交换机基本配置
system-view
[Huawei]un in en //关闭控制台提⽰信息
[Huawei]sysname Switch1
[Switch1]gvrp
[Switch1]quit
[Switch1]vlan X
[Switch1]interface vlan X
[Switch1-vlanifX]ip x.xxx xx
[Switch1-vlanifX]quit
[Switch1]interface gigabitethernet X/X/1
[Switch1- gigabitethernet x/x/1]port link-type access
[Switch1-gigabitethernetx/x/1]port default vlanX //配置交换机端⼝
[Switch1]interface gigabitethernet X/X/2
[Switch1- gigabitethernet x/x/2]port link-type trunk
[Switch1- gigabitethernet x/x/2]port trunk allow-pass vlan all
[Switch1- gigabitethernet x/x/2]quit
[Switch1] interface gigabitethernet X/X/2
[Switch1-gigabitethernetx/x/2]gvrp //配置交换机gvrp
[Switch1-gigabitethernetx/x/2]quit
Ps:配置完Pc的IP后,可以进⾏ping验证,或者⽤命令在交换机上查看:dis gvrp statistics,dis vlan #交换机⽣成树协议stp配置:优先级
配置stp基本功能,配置环⽹中的设备⽣成树协议⼯作在STP模式
#配置交换机1的STP⼯作模式,交换机2、3、4、的配置相同
system-view
[Huawei]sysname Switch1
[Switch1]stp mode stp //stp模式为stp
[Switch1]stp root primary //配置交换机1为根桥
[Switch2]stp root secondary //配置交换机2为备份根桥(交换机⼆与交换机1配置⼀样)
#交换机⽣成树协议STP配置:路径值
#配置交换机1的端⼝路径开销计算⽅法为计算⽅法,2、4配置相同
system-view
[Huawei]sysname Switch1
[Switch1]stp pathcost-standard legacy
#配置交换机3端⼝gigabitethernet x/x/x的端⼝路径开销值为20000
system-view
[Huawei]sysname Switch3
[Switch3]stp pathcost-standard legacy
[Switch3]interface gigabitethernet x/x/x
[Switch3- gigabitethernet x/x/x]stp cost 20000
[Switch3- gigabitethernet x/x/x]quit
#配置交换机4端⼝gigabitethernet x/x/x为边缘端⼝并启⽤端⼝的BPDU报⽂过滤功能
system-view
[Huawei]sysname Switch4
[Switch4]interface gigabitethernet x/x/x
[Switch4- gigabitethernet x/x/x]stp edged-port enable
[Switch4- gigabitethernet x/x/x]stp bpdu-filter enable
[Switch4- gigabitethernet x/x/x]quit
#配置交换机3端⼝gigabitethernet x/x/x为边缘端⼝并启⽤端⼝的BPDU报⽂过滤功能
system-view
[Huawei]sysname Switch3
[Switch3]interface gigabitethernet x/x/x
[Switch3- gigabitethernet x/x/x]stp edged-port enable
[Switch3- gigabitethernet x/x/x]stp bpdu-filter enable
[Switch3- gigabitethernet x/x/x]quit
Ps:设备全局启⽤STP,所有设备配置相同
#交换机1全局启⽤STP
内容到这⾥就结束了,写的不好,还请各位指点。如果有不懂的可以在评论区⾥进⾏讨论,相信那⾥会带给你答案和惊喜!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论