等保建设|系统集成|机房建设|综合布线 | 全国服务热线:13808203880 | 移动电话:13808203880

华为交换机最常用的基础命令汇总大全

作者成都华为代理商 发表日期:2023-01-03 10:17:33 浏览次数:

交换机的基础命令汇总


system-view     进入系统视图


quit     退到系统视图


sysname     交换机命名


vlan 20     创建vlan(进入vlan20)


display vlan    显示vlan


undo vlan 20    删除vlan20


display vlan 20 显示vlan里的端口20


Interface e1/0/24 进入端口24


portlink-type access     vlan 20 把当前端口放入vlan20


undo porte1/0/10 删除当前VLAN端口10


display current-configuration 显示当前配置


02


配置交换机支持TELNET


interfacevlan 1 进入VLAN1


ip address192.168.3.100 255.255.255.0 配置IP地址


user-interfacevty 0 4 进入虚拟终端


authentication-modepassword (aut password) 设置口令模式


setauthentication password simple 222 (set aut pass sim 222) 设置口令


userprivilege level 3(use priv lev 3) 配置用户级别


dispcurrent-configuration (disp cur) 查看当前配置


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端口设为TRUNK端口


port trunkpermit vlan all 所有端口都能经过此路径


在SW2上:


vlan 10建立VLAN 10


interfacee1/0/20 进入端口20


portdefault vlan 10 把端口20放入VLAN10


interfacee1/0/24 进入端口24


portlink-type trunk 把24端口设为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


路由器的基础命令汇总


dispaly version 显示系统软件版本及硬件信息


system-view 切换到系统视图


quit 返回


interface +接口 进入接口视图


ip address +IP +mask 配置IP和子网掩码


return 返回用户视图


返回用户视图


sysname R1 修改路由器名称为R1


display current-configuration 查看路由器当前配置


dispaly interface +接口查看路由器接口的状态信息


save 保存当前配置


display ip interface brief 查看接口与IP相关摘要信息


display ip routing-table 查看路由表


05


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


q 退回到用户视图


user-interface vty 0 4 进入到VTY用户视图


authentication-mode aaa 设置验证方式aaa


06


配置Stelnet


配置SSHserver:rsalocal-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


q 返回到系统视图


aaa 进入aaa视图


local-user huawei1 password cipher huawei1 创建用户和设置用户密码


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 设置huawei1用户级别为3级别范围0~15


stelnet server enable 开启ssh功能


display ssh user-information huawei1 查看ssh用户配置信息不指定用户默认查看所有用户


display ssh server status 查看ssh服务器全局配置信息


07


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的ForwardDelay时间为3000cs也就是30s


stp bridge-diameter 3 命令设置网络的直径为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 查看交换机上当前生效的MST域配置信息


dis stp instance 0 brief 查看实例0中的生成树状态和统计的摘要信息


stp instance 2 priority 0 配置交换机成位实例2中的根交换机


09


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


10


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路由表


11


配置OSPF区域明文认证


ospf 1


area 1


authentication-mode simple plain huawei plain是口令以明文方式显示


authentication-mode md5 1 huawei 配置区域密文认证


12


配置链路认证


int g0/0/1


ospf authentication-mode md5 1 huawei 在一条链路中的两个接口配置要相同


13


配置抑制接口


ospf 1


silent-interface GigabitEthernet 0/0/1 禁止接口g0/0/1接收和发送ospf报文


14


技巧对多个接口配置接口抑制


ospf 1


silent-interface all 抑制所有接口


un


display ip routing-table 10.0.1.1 查看10.0.1.1所在网段的路由条目


15


基于接口修改


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值越大优先级越低


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进程中发布默认路由


17


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的工作状态


18


配置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 开启非抢占方式


19


配置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 认证配置


20


配置基本的访问控制表


acl 2000 创建一个编号型ACL,基本ACL的范围是2000~29999


rule 5 permit source 1.1.1.1 0指定规则ID为5,允许数据源地址为1.1.1.1的报文通过,反掩码全为0,即精确匹配


rule 10 deny source any 指定ID为10,拒绝任意源地址的数据包通过


display acl all 查看设备上所有的访问控制列表。

————————————————

版权声明:本文为CSDN博主「深圳连讯达」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/faxytech/article/details/120322188


联系我们
地址:成都市新南路8号
手机:13808203880
座机:13808203880
联系人:先生
邮箱:Qiu_np@aochinese.com
关注奥华信息