干货 | 思科和华为交换机命令对比,快收藏!!!

思科和华为交换机应该是网络项目中大家接触比较多的了,这两种交换机的常用命令各有不同,

本文结合网络项目中两种交换机的常用命令从对比的角度帮助大家来学习

01

调试命令

思科:
  Switch#show  run   显示所有配置命令
  Switch#show   ip   inter   brief   显示所有接口状态
  Switch#show vlan  brief   显示所有VLAN的信息
  Switch#show   version   显示版本信息
华为:
        [Quidway]dis cur  显示所有配置命令

        [Quidway]display interfaces   显示所有接口状态

        [Quidway]display vlan all     显示所有VLAN的信息

        [Quidway]display version    显示版本信息 


02

接口配置命令

思科:
  Switch(config)#interface f0/8  进入接口视图
  Switch(config-if)#no shut  此命令开启接口
  Switch(config-if)#description to server01 端口描述
  Switch(config-if)#ip add 192.168.1.100 255.255.255.0 设置接口IP
华为:
  [Quidway]interface e0/1  进入接口视图
  [Quidway]undo  shutdown  此命令开启接口
  [Quidway]description  to server02   端口描述
  [Quidway]ip add 192.168.1.102 255.255.255.0   设置接口IP


03

VLAN配置命令

思科:
  建立和删除VLAN
  Switch# vlan database
  Switch(vlan)# vlan 20 name test20
  Switch(vlan)# no vlan 20
  Switch(vlan)# exit
  将端口分配给一个VLAN
  Switch(config)# interface f0/1
  Switch(config-if)# switchport mode access
  Switch(config-if)# switchport access vlan 20
  设置VLAN TRUNK
  Switch(config)# interface f0/24
  Switch(config-if)# switchport mode trunk
  Switch(config-if)#switchport trunk allow vlan {ID|All}
  Switch(config-if)# switchport trunk encapsulation dot1q
华为:
  建立和删除VLAN
  [Quidway]vlan 30
  [Quidway]undo  vlan 30
  将端口分配给一个VLAN
  [Quidway]int ethernet0/1
  [Quidway-Ethernet0/1]port access vlan 30( port default vlan 30)
  或[Quidway]vlan 30
  [Quidway-vlan3]port ethernet 0/1  在VLAN中增加端口
  [Quidway-vlan3]port ethernet 0/1 to ethernet 0/4   在VLAN中增加多个连续端口
  设置VLAN TRUNK
  [Quidway]int e0/24
  [Quidway-Ethernet0/24] port link-type trunk
  [Quidway-Ethernet0/24]port trunk permit vlan {ID|All}


04

端口镜像配置命令

思科:
  配置镜像源端口
  Switch(config)#monitor session 1 source interface gigabitEthernet 0/2 - 5 rx
  上面命令最后一个参数:
  both  监听双向数据,默认为both
  rx    接收
  tx    发送
  配置镜像目的端口
  Switch(config)#monitor session 1 destination interface gigabitEthernet 0/6
  删除镜像端口
  Switch(config)#no monitor session 1
华为:
  将端口E0/2配置为监控端口

        [Quidway]monitor-port Ethernet 0/2
  端口E0/1配置为镜像端口
  [Quidway]port mirror Ethernet 0/1
  或者直接配置监控端口和镜像端口
  [Quidway]port mirror Ethernet 0/1 observing-port Ethernet 0/2
  删除镜像[Quidway]undo    monitor-port


05

冗余配置

思科HSRP:
  Switch# interface Vlan20
  ip address 172.29.197.33  255.255.255.248
  standby 20 ip 172.29.197.53
  standby 20 priority 105   优先级
  standby 20 preempt        抢占
  standby 20 track GigabitEthernet0/25  decrement 10   跟踪端口如果DOWN了优先级减10
华为VRRP:
  [Quidway]interface Vlanif30
  ip address 172.29.197.9   255.255.255.248
  vrrp vrid 30 virtual-ip 172.29.141.11
  vrrp vrid 30 priority 150  优先级
  vrrp vrid 30 preempt-mode   抢占
  vrrp vrid 30 track interface GigabitEthernet0/0/18 reduced 60  跟踪端口如果DOWN了优先级减60


06

设置安全远程访问

思科设置vty安全访问:
  R1(config)# access-list 1 permit 192.168.2.5
  R1(config)# line vty 0 4
  R1(config)# access-class 1 in
华为设置vty安全访问:
  [Quidway]acl number 2000
  rule 1 permit source 172.29.181.150  0
  rule 2 deny
  [Quidway]user-interface vty 0 4
  acl 2000 inbound


07

网管配置

思科:
  Switch(config)#snmp-server community sunion ro 配置本交换机的只读字串为sunion
  Switch(config)#snmp-server community sunion rw 配置本交换机的读写字串为sunion
  Switch(config)#snmp-server enable traps 允许交换机将所有类型SNMP Trap发送出去
  Switch(config)#snmp-server host 192.168.190.1  traps sunion 指定交换机SNMP Trap的接收者为192.168.190.1,发送Trap时采用sunion作为字串
华为:
  [Quidway]snmp-agent community read  datanms 配置本交换机的只读字串为datanms
  [Quidway]snmp-agent community write  datanms 配置本交换机的读写字串为datanms
  [Quidway]snmp-agent sys-info location BeiJing China 设置交换机的位置信息
  [Quidway]snmp-agent sys-info version all  设置交换机支持所有的SNMP协议版本
  [Quidway]snmp-agent target-host trap  address udp-domain 192.168.190.121 params securityname datanms  指定交换机SNMP Trap的接收者为192.168.190.121 ,发送Trap时采用datanms作为字串

 好了,通过以上七点的举例,相信大家对项目中两种交换机的常用命令应该比较清晰了,当然更多的命令使用和技巧需要我们不断的积累。

    如需学习更多网络技术,请持续关注网络技术联盟站!


猜你喜欢

转载自blog.51cto.com/10291361/2161192