华为和思科各数通设备的常用命令

本文基于华为和思科各数通设备的常用命令来对比学习,这两个命令体系是网络项目中常见的,其他一些厂家也是基于类似的命令体系.下面也会根据公司业务需求列举部分网络设备厂家,比如H3C,盛科的命令不同之处.

1. 查看命令

华为:

<Quidway>dis cur                                      显示所有配置命令

<Quidway>display interfaces                      显示所有接口状态

<Quidway>display interface gigabitethernet 0/0/1 //查看某接口配置是否正确

<Quidway> display this                                或者进入该端口查看接口配置是否正确

<Quidway>display vlan all                          显示所有VLAN的信息

<Quidway>display version                          显示版本信息

<Quidway>display arp [| include X.X.X.X] //查看设备上的arp信息

<Quidway>display ip routing-table [X.X.X.X] //显示路由表

<Quidway>display mac-address               查看设备上学习到的MAC表项以及MAC学习的源物理端口的对应关系

<Quidway>display stp brief                        查看物理端口的二层协议状态

<Quidway> display traffic policy statistics interface GigabitEthernet X/X/X inbound

//查看物理端口X/X/X上入方向的流量统计信息结果

<Quidway> display traffic policy statistics interface GigabitEthernet X/X/X outbound

查看物理端口X/X/X上出方向的流量统计信息结果

<Quidway> display transceiver interface gigabitethernet 0/0/1 verbose 查看端口光模块的常规、制造、告警以及诊断信息

思科:

Switch#show  run                                     显示所有配置命令

Switch#show   ip   inter   brief                   显示所有接口状态

Switch#show vlan  brief                            显示所有VLAN的信息

Switch#show   version                              显示版本信息

2.接口配置命令

华为:

端口IP

[Quidway]interface e0/1                    进入接口视图

[Quidway]undo  shutdown                         此命令开启接口/端口使能

[Quidway]description  to server02             端口描述

[Quidway]ip add 192.168.1.102 255.255.255.0   设置接口IP

[Quidway]interface g0/0/13

[Quidway-GigabitEthernet0/0/13]undo negotiation auto        关闭自协商

[Quidway-GigabitEthernet0/0/13]duplex { full | half }            更改双工状态

[Quidway-GigabitEthernet0/0/13]undo duplex                      恢复默认双工状态

[Quidway-GigabitEthernet0/0/13]negotiation auto                使能自协商

配置端口隔离

< Quidway >system-view 进入系统视图

[Quidway] port-isolate mode { l2 | all } 配置端口隔离模式,缺省为二层隔离三层互通

[Quidway] interface GigabitEthernet 0/0/1

[Quidway-GigabitEthernet0/0/1] port-isolate enable [ group group-id ] 启用端口隔离

同一端口隔离组的端口之间互相隔离,不同端口隔离组的端口之间不隔离。如果不指定 group-id参数时,默认加入的端口隔离组为 1

链路聚合

配置手工负载分担模式链路聚合

<Quidway> system-view

[Quidway] interface eth-trunk 1 创建Eth-Trunk

[Quidway-Eth-Trunk1] quit

[Quidway] interface Ethernet0/0/1

[Quidway -Ethernet0/0/1] eth-trunk 1 成员接口加入Eth-Trunk

[Quidway -Ethernet0/0/1] quit

配置静态LACP 模式链路聚合

<Quidway> system-view

[Quidway] interface eth-trunk 1 创建Eth-Trunk

[Quidway-Eth-Trunk1]mode lacp-static 配置工作模式为静态LACP 模式

[Quidway-Eth-Trunk1] quit

[Quidway] interface Ethernet0/0/1 进入端口e0/0/1

[Quidway -Ethernet0/0/1] eth-trunk 1 成员接口加入Eth-Trunk (多个接口加入trunk组)

[Quidway -Ethernet0/0/1] quit

[Quidway] interface eth-trunk 1 进入Eth-Trunk1

[Quidway-Eth-Trunk1] bpdu enable 配置接口Eth-Trunk 处理BPDU 报文

[Quidway-Eth-Trunk1]max bandwidth-affected-linknumber 2 配置活动接口上限阈值M2

[Quidway-Eth-Trunk1] quit

[Quidway] lacp priority 100 配置系统优先级为100确定主动端

[Quidway] interface Ethernet0/0/1 进入端口e0/0/1

[Quidway -Ethernet0/0/1] lacp priority 100 配置接口优先级确定活动链路(多个接口中选定一定数量接口)

[Quidway-Eth-Trunk1] quit

思科:

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

3.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}

4.端口镜像配置

思科:

配置镜像源端口

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    删除镜像

配置基于接口的本地镜像

< Quidway > system-view

[Quidway] vlan 10

[Quidway -vlan10] quit

[Quidway] interface GigabitEthernet 0/0/1

[Quidway -GigabitEthernet0/0/1] port link-type trunk

[Quidway -GigabitEthernet0/0/1] port trunk allow-pass vlan 10

[Quidway -GigabitEthernet0/0/1] quit //创建 VLAN,g0/0/1以Trunk 方式加入 VLAN

[Quidway] interface GigabitEthernet 0/0/3

[Quidway -GigabitEthernet0/0/3] port link-type trunk

[Quidway -GigabitEthernet0/0/3] port trunk allow-pass vlan 10

[Quidway -GigabitEthernet0/0/3] quit // g0/0/3以Trunk 方式加入 VLAN

[Quidway] observe-port 1 interface GigabitEthernet 0/0/24 //将g0/0/24 接口配置为观察接口

[Quidway] interface GigabitEthernet 0/0/1

[Quidway -GigabitEthernet0/0/1] port-mirroring to observe-port 1 inbound //将g0/0/1 接口配置为镜像接口

[Quidway -GigabitEthernet0/0/1] quit

配置基于 VLAN 的本地镜像

< Quidway > system-view

[Quidway] interface gigabitethernet 0/0/1

[Quidway -GigabitEthernet0/0/1] port link-type access

[Quidway -GigabitEthernet0/0/1] port default vlan 10

[Quidway -GigabitEthernet0/0/1] quit //将g0/0/1 以 Access 方式加入 VLAN10

[Quidway] interface gigabitethernet 0/0/2

[Quidway -GigabitEthernet0/0/2] port link-type access

[Quidway -GigabitEthernet0/0/2] port default vlan 10

[Quidway -GigabitEthernet0/0/2] quit //将g0/0/2 以 Access 方式加入 VLAN10

[Quidway] observe-port 1 interface GigabitEthernet 0/0/3 //将g0/0/3 接口配置为观察接口

[Quidway] VLAN 10

[Quidway -VLAN10] mirroring to observe-port 1 inbound //将 VLAN10 配置为镜像 VLAN

[Quidway -VLAN10] quit

5.冗余配置

思科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

六、设置安全远程访问

思科设置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

6.NTP配置

思科:

Cisco6509#show clock    显示时间

Cisco6509#clock set 14:00:00 30 Sep 2011 设置时间

Cisco6509(config)#ntp server 202.198.0.102 设置与其他时间服务器同步

Cisco6509(config)#clock timezone beijing +8  设置时区

华为:

[Quidway]dis clock  显示时间

[Quidway]clock datetime 23:30:00 2011/11/16  设置时间

[Quidway]ntp-service unicast-server 202.198.0.102  设置与其他时间服务器同步

[Quidway]clock timezone  E8  add  08:00:00  设置时区

7.静态路由配置

思科:

ip route <目的网段> <目的网段掩码><下一跳>

Cisco6509# ip   route       0.0.0.0  0.0.0.0   10.65.1.2      静态路由

Cisco6509#ip route  0.0.0.0  0.0.0.0  192.168.3.1 150  浮动静态路由管理距离为150

华为:

[Quidway] ip  route-static   0.0.0.0  0.0.0.0   10.65.1.2

[Quidway]ip route-static 0.0.0.0  0.0.0.0 192.168.3.1   preference  150

8.可网管配置

思科:

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作为字串

9.保存备份配置

华为:

<Quidway>save                           保存配置信息 

思科:

switch#write                          保存配置信息

10.其它交换机命令的一些坑(不同点)

H3C

H3C华三的交换机大部分命令都和华为的相同,有部分不同的记录下来.比如在做交换机zabbix监控的时候需要配置snmp需要保证时间的准确性

时钟设置

有两种时钟获取方式

1.开取NTP ,由网络时钟服务器获取时间 clock protocol ntp mdc mdc-id

2.不置时钟服务器, clock protocol none

clock protocol none

<H3C>clock protocol none              #关闭protocol ,缺省情况下,默认开启,由缺省MDC获取系统时间

<H3C>clock datetime 10:45:20 11/9/2018   #设置时间

[H3C]clock timezone beijing add 8          #设置时区 北京 在UTC偏移8小时

[H3C]quit

这里不同点是在日期的日月顺序,华为的是 2019-06-03或者2019/6/3,年在前面.而华三是年在后面,如果按照华为的来就会报错.

  • 5
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值