华为交换机常用命令

时间:2023-01-22 15:17:37 H3C认证 我要投稿
  • 相关推荐

华为交换机常用命令大全

  华为交换机有什么常用命令,为帮助同学们更好学习华为交换机知识,yjbys小编为大家分享以下华为交换机常用配置命令,希望对大家有所帮助!

  dis vlan 显示vlan

  name text 指定当前vlan的名称

  undo name 取消

  [h3c] vlan 2

  [h3c-vlan2]name test vlan

  dis users 显示用户

  dis startup 显示启动配置文件的信息

  dis user-interface 显示用户界面的相关信息

  dis web users 显示web用户的相关信息。

  header login 配置登陆验证是显示信息

  header shell

  undo header

  lock 锁住当前用户界面

  acl 访问控制列表 acl number inbound/outbound

  [h3c]user-interface vty 0 4

  [h3c-vty0-4] acl 2000 inbound

  shutdown:关闭vlan接口

  undo shutdown 打开vlan接口

  关闭vlan1 接口

  [h3c] interface vlan-interface 1

  [h3c-vlan-interface] shutdown

  vlan vlan-id 定义vlan

  undo valn vlan-id

  display ip routing-table

  display ip routing-table protocol static

  display ip routing-table statistics

  display ip routing-table verbose 查看路由表的全部详细信息

  interface vlan-interface vlan-id 进入valn

  management-vlan vlan-id 定义管理vlan号

  reset ip routing-table statistics protocol all 清除所有路由协议的路由信息.

  display garp statistics interface GigabitEthernet 1/0/1 显示以太网端口上的garp统计信息

  display voice vlan status 查看语音vlan状态

  [h3c-GigabitEthernet1/0/1] broadcast-suppression 20 允许接受的最大广播流量为该端口传输能力的20%.超出部分丢弃.

  [h3c-GigabitEthernet1/0/1] broadcast-suppression pps 1000 每秒允许接受的最大广播数据包为1000传输能力的20%.超出部分丢弃.

  display interface GigabitEthernet1/0/1 查看端口信息

  display brief interface GigabitEthernet1/0/1 查看端口简要配置信息

  display loopback-detection 用来测试环路测试是否开启

  display transceiver-information interface GigabitEthernet1/0/50 显示光口相关信息

  duplex auto/full/half

  [h3c]interface GigabitEthernet1/0/1

  [h3c-GigabitEthernet1/0/1]duplux auto 设置端口双工属性为自协商

  port link-type access/hybrid/trunk 默认为access

  port trunk permit vlan all 将trunk扣加入所有vlan中

  reset counters interface GigabitEthernet1/0/1 清楚端口的统计信息

  speed auto 10/100/1000

  display port-security 查看端口安全配置信息

  am user-bind mac-addr 00e0-fc00-5101 ip-addr 10.153.1.2 interface GigabitEthernet1/0/1 端口ip绑定

  display arp 显示arp

  display am user-bind 显示端口绑定的配置信息

  display mac-address 显示交换机学习到的mac地址

  display stp 显示生成树状态与统计信息

  [h3c-GigabitEthernet1/0/1]stp instance 0 cost 200 设置生成树实例0上路径开销为200

  stp cost 设置当前端口在指定生成树实例上路径开销。instance-id 为0-16 0表cist 取值范围1-200000

   display system-guard ip-record 显示防攻击记录信息.

  system-guard enable 启用系统防攻击功能

  display icmp statistics icmp流量统计

  display ip socket

  display ip statistics

  display acl all

  acl number acl-number match-order auto/config

  acl-number (2000-2999 是基本acl 3000-3999是高级acl为管理员预留的编号)

  rule deny/permit protocal

  访问控制

  [h3c] acl number 3000

  [h3c-acl-adv-3000]rule permit tcp source 129.9.0.0 0.0.255.255 destination 202.38.160.0 0.0.255.255 destination-port eq 80 (

  定义高级acl 3000,允许129.0.0/16网段的主机向202.38.160/24网段主机访问端口80)

  rule permit source 211.100.255.0 0.255.255.255

  rule deny cos 3 souce 00de-bbef-adse ffff-ffff-fff dest 0011-4301-9912 ffff-ffff-ffff

  (禁止mac地址00de-bbef-adse发送到mac地址0011-4301-9912且802.1p优先级为3的报文通过)

  display qos-interface GigabitEthernet1/0/1 traffic-limit 查看端口上流量

  端口速率限制

  line-rate inbound/outbound target-rate

  inbound:对端口接收报文进行速率限制

  outbound: 对端口发送报文进行速率限制

  target-rate 对报文限制速率,单位kbps 千兆口 inbound范围1-1000000 outbound范围20-1000000

  undo line-rate取消限速.

  [h3c]interface GigabitEthernet1/0/1

  [h3c-GigabitEthernet1/0/1]line-rate outbound 128 限制出去速率为128kbps

  display arp | include 77

  display arp count 计算arp表的记录数

  display ndp 显示交换机端口的详细配置信息。

  display ntdp device-list verbose 收集设备详细信息

  display lock

  display users

  display cpu

  display memory

  display fan

  display device

  display power

  ----------------------------------------

  交换机命令

  ~~~~~~~~~~

  [Quidway]dis cur       ;显示当前配置

  [Quidway]display current-configuration       ;显示当前配置

  [Quidway]display interfaces       ;显示接口信息

  [Quidway]display vlan all       ;显示路由信息

  [Quidway]display version       ;显示版本信息

  [Quidway]super password simple ;修改特权用户密码

  [Quidway]sysname ;交换机命名

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

  [Quidway]int e0/1 ;简写方式

  [Quidway]interface vlan-interface ;进入接口视图

  [Quidway]int vlan ;简写方式,n<6

  [Quidway-Vlan-interfacen]ip address 10.65.1.1 255.255.0.0 ;配置VLAN的IP地址

  [Quidway]ip route-static 0.0.0.0 0.0.0.0 10.65.1.2 ;静态路由=网关

  [Quidway]rip ;三层交换支持

  [Quidway]local-user ftp ;建立ftp用户

  [Quidway]user-interface vty 0 4 ;进入虚拟终端

  [S3026-ui-vty0-4]authentication-mode password ;设置口令模式

  [S3026-ui-vty0-4]set authentication-mode password simple 222 ;设置口令

  [S3026-ui-vty0-4]user privilege level 3 ;用户级别

  [Quidway]interface ethernet0/1 ;进入端口模式

  [Quidway]int e0/1 ;进入端口模式

  [Quidway-Ethernet0/1]duplex {half|full|auto} ;配置端口工作状态

  [Quidway-Ethernet0/1]speed {10|100|auto} ;配置端口工作速率

  [Quidway-Ethernet0/1]flow-control ;配置端口流控

  [Quidway-Ethernet0/1]mdi {across|auto|normal} ;配置端口平接扭接

  [Quidway-Ethernet0/1]port link-type {trunk|access|hybrid} ;设置端口工作模式

  [Quidway-Ethernet0/1]port access vlan 3      ;当前端口加入到VLAN

  [Quidway-Ethernet0/1]port trunk permit vlan {ID|All}   ;设trunk允许的VLAN

  [Quidway-Ethernet0/1]port trunk pvid vlan 3      ;设置trunk端口的PVID

  [Quidway-Ethernet0/1]undo shutdown ;激活端口

  [Quidway-Ethernet0/1]shutdown ;关闭端口

  [Quidway-Ethernet0/1]quit ;返回

  [Quidway]vlan 3       ;创建VLAN

  [Quidway-vlan3]port ethernet 0/1               ;在VLAN中增加端口

  [Quidway-vlan3]port e0/1       ;简写方式

  [Quidway-vlan3]port ethernet 0/1 to ethernet 0/4      ;在VLAN中增加端口

  [Quidway-vlan3]port e0/1 to e0/4       ;简写方式

  [Quidway]monitor-port  ;指定镜像端口

  [Quidway]port mirror    ;指定被镜像端口

  [Quidway]port mirror observing-port ;指定镜像和被镜像

  例如:

  [Quidway]port mirror e0/1 to e0/4 observing-port e0/7 ;指定镜像和被镜像

  [Quidway]description string      ;指定VLAN描述字符

  [Quidway]description         ;删除VLAN描述字符

  [Quidway]display vlan [vlan_id] ;查看VLAN设置

  [Quidway]stp {enable|disable} ;设置生成树,默认关闭

  [Quidway]stp priority 4096      ;设置交换机的优先级

  [Quidway]stp root {primary|secondary}      ;设置为根或根的备份

  [Quidway-Ethernet0/1]stp cost 200      ;设置交换机端口的花费

  [Quidway]link-aggregation e0/1 to e0/4 ingress|both ; 端口的聚合

  [Quidway]undo link-aggregation e0/1|all ; 始端口为通道号

  [SwitchA-vlanx]isolate-user-vlan enable      ;设置主vlan

  [SwitchA]isolate-user-vlan secondary      ;设主vlan包括的子vlan

  [Quidway-Ethernet0/2]port hybrid pvid vlan      ;设置vlan的pvid

  [Quidway-Ethernet0/2]undo port hybrid pvid      ;删除vlan的pvid

  [Quidway-Ethernet0/2]port hybrid vlan vlan_id_list untagged  ;设置无标识的vlan

  如果数据包的vlan id与PVId一致,则去掉vlan信息. 默认PVID=1。

  所以设置PVID为所属vlan id, 设置可以互通的vlan为untagged。

  ----------------------------------------

  路由器命令

  ~~~~~~~~~~

  [Quidway]display version       ;显示版本信息

  [Quidway]display current-configuration       ;显示当前配置

  [Quidway]display interfaces       ;显示接口信息

  [Quidway]display ip route       ;显示路由信息

  [Quidway]sysname       ;更改主机名

  [Quidway]super passwrod       ;设置口令

  [Quidway]int s0/0       ;进入接口

  [Quidway-serial0/0]clock rate 64000      ;设置同步时钟

  [Quidway-serial0/0]ip address      ;配置端口IP地址

  例:

  [Quidway-serial0/0]ip address 10.65.1.1 255.255.0.0      ;或

  [Quidway-serial0/0]ip address 10.65.1.1 16      ;

  [Quidway-serial0/0]undo shutdown      ;激活端口

  [Quidway]link-protocol hdlc       ;绑定hdlc协议

  [Quidway]user-interface vty 0 4

  [Quidway-ui-vty0-4]authentication-mode password

  [Quidway-ui-vty0-4]set authentication-mode password simple 222

  [Quidway-ui-vty0-4]user privilege level 3

  [Quidway-ui-vty0-4]quit

  [Quidway]debugging hdlc all serial0       ;显示所有信息

  [Quidway]debugging hdlc event serial0       ;调试事件信息

  [Quidway]debugging hdlc packet serial0       ;显示包的信息

  静态路由:

  [Quidway]ip route-static {interface number|nexthop}[value][reject|blackhole]

  例如:

  [Quidway]ip route-static 129.1.0.0 16 10.0.0.2

  [Quidway]ip route-static 129.1.0.0 255.255.0.0 10.0.0.2

  [Quidway]ip route-static 129.1.0.0 16 Serial 2

  [Quidway]ip route-static 0.0.0.0 0.0.0.0 10.0.0.2

  动态路由:

  [Quidway]rip ;设置动态路由

  [Quidway]rip work ;设置工作允许

  [Quidway]rip input ;设置入口允许

  [Quidway]rip output ;设置出口允许

  [Quidway-rip]network 10.0.0.0       ;设置交换路由网络

  [Quidway-rip]network all ;设置与所有网络交换

  [Quidway-rip]peer ip-address ;指定交换点

  [Quidway-rip]summary ;路由聚合

  [Quidway]rip version 1 ;设置工作在版本1

  [Quidway]rip version 2 multicast ;设版本2,多播方式

  [Quidway-Ethernet0/0]rip split-horizon ;水平分隔

  [Quidway]router id A.B.C.D ;配置路由器的ID

  [Quidway]ospf enable ;启动OSPF协议

  [Quidway-ospf]import-route direct ;引入直联路由

  [Quidway-Serial0/0]ospf enable area ;配置OSPF区域

  标准访问列表命令格式如下:

  acl number [match-order config|auto] ;默认前者顺序匹配。

  rule [normal|special]{permit|deny} source

  例:

  [Quidway]acl number 2001

  [Quidway-acl-basic-2001]rule normal permit source 10.0.0.0 0.0.0.255

  [Quidway-acl-basic-2001]rule normal deny source any

  扩展访问控制列表配置命令

  配置TCP/UDP协议的扩展访问列表:

  rule {normal|special}{permit|deny}{tcp|udp}source {|any}destination |any}

  [operate]

  配置ICMP协议的扩展访问列表:

  rule {normal|special}{permit|deny}icmp source {|any]destination {|any]

  [icmp-code] [logging]

  扩展访问控制列表操作符的含义

  equal portnumber ;等于

  greater-than portnumber ;大于

  less-than portnumber ;小于

  not-equal portnumber ;不等

  range portnumber1 portnumber2 ;区间

  扩展访问控制列表举例

  [Quidway]acl number 3001

  [Quidway-acl-3001]rule deny souce any destination any

  [Quidway-acl-3001]rule permit icmp source any destination any icmp-type echo

  [Quidway-acl-3001]rule permit icmp source any destination any icmp-type echo-reply

  [Quidway]acl number 3002

  [Quidway-acl-3002]rule permit ip source 10.0.0.1 0.0.0.0 destination 202.0.0.1 0.0.0.0

  [Quidway-acl-3002]rule deny ip source any destination any

  [Quidway]acl number 103

  [Quidway-acl-103]rule permit tcp source any destination 10.0.0.1 0.0.0.0 destination-port equal ftp

  [Quidway-acl-103]rule permit tcp source any destination 10.0.0.2 0.0.0.0 destination-port equal www

  [Quidway]firewall enable

  [Quidway]firewall default permit|deny

  [Quidway]int e0/0

  [Quidway-Ethernet0/0]firewall packet-filter 2001 inbound|outbound

  地址转换配置举例

  [Quidway]firewall enable

  [Quidway]firewall default permit

  [Quidway]acl 2001 ;内部指定主机可以进入e0

  [Quidway-acl-basic-2001]rule deny ip source any destination any

  [Quidway-acl-basic-2001]rule permit ip source 129.38.1.1 0 destination any

  [Quidway-acl-basic-2001]rule permit ip source 129.38.1.2 0 destination any

  [Quidway-acl-basic-2001]rule permit ip source 129.38.1.3 0 destination any

  [Quidway-acl-basic-2001]rule permit ip source 129.38.1.4 0 destination any

  [Quidway-acl-basic-2001]quit

  [Quidway]int e0/0

  [Quidway-Ethernet0]firewall packet-filter 2001 inbound

  [Quidway]acl 3002 ;外部特定主机和大于1024端口的数据包允许进入S0

  [Quidway-acl-adv-3002]rule deny ip source any destination any

  [Quidway-acl-adv-3002]rule permit tcp source 202.39.2.3 0 destination 202.38.160.1 0

  [Quidway-acl-adv-3002]rule permit tcp source any destination 202.38.160.1 0 destination-port

  great-than

  1024

  [Quidway-acl-adv-3002]quit

  [Quidway]int s0/0

  [Quidway-Serial0/0]firewall packet-filter 102 inbound

  [Quidway-Serial0/0]nat outbound 3002 interface ;是Easy ip,将acl允许的IP从本接口出时变换源地址。

  内部服务器地址转换配置命令(静态nat):

  nat server global [port] inside port [protocol]

  [Quidway-Serial0/0]nat server global 202.38.160.1 inside 129.38.1.1 ftp tcp

  [Quidway-Serial0/0]nat server global 202.38.160.1 inside 129.38.1.2 telnet tcp

  [Quidway-Serial0/0]nat server global 202.38.160.1 inside 129.38.1.3 www tcp

  设有公网IP:202.38.160.101~202.38.160.103 ;对外访问

  [Quidway]nat address-group 202.38.160.101 202.38.160.103 pool1 ;建立地址池

  [Quidway]acl 2001

  [Quidway-acl-basic-2001]rule permit source 10.110.10.0 0.0.0.255 ;指定允许的内部网络

  [Quidway-acl-basic-2001]rule deny source any

  [Quidway-acl-basic-2001]int s0/0

  [Quidway-Serial0/0]nat outbound 2001 address-group pool1 ;在s0口从地址池取出IP对外访问

  [Quidway-Serial0/0]nat server global 202.38.160.101 inside 10.110.10.1 ftp tcp

  [Quidway-Serial0/0]nat server global 202.38.160.102 inside 10.110.10.2 www tcp

  [Quidway-Serial0/0]nat server global 202.38.160.102 8080 inside 10.110.10.3 www tcp

  [Quidway-Serial0/0]nat server global 202.38.160.103 inside 10.110.10.4 smtp udp

  PPP设置:

  [Quidway-Serial0/0]link-protocol ppp ;默认的协议

  PPP验证:

  主验方:pap|chap

  [Quidway]local-user q2 password {simple|cipher} hello ;路由器1

  [Quidway]interface s0/0

  [Quidway-serial0/0]ppp authentication-mode {pap|chap}

  [Quidway-serial0/0]ppp chap user q1 ;pap时,没有此句

  pap被验方:

  [Quidway]interface s0/0 ;路由器2

  [Quidway-serial0/0]ppp pap local-user q2 password {simple|cipher} hello

  chap被验方:

  [Quidway]interface s0/0 ;路由器2

  [Quidway-serial0/0]ppp chap user q2 ;自己路由器名

  [Quidway-serial0/0]local-user q1 password {simple|cipher} hello ;对方路由器名

  帧中继frame-relay (二分册6-61)

  [q1]fr switching

  [q1]int s0/1

  [q1-Serial0/1]ip address 192.168.34.51 255.255.255.0

  [q1-Serial0/1]link-protocol fr ;封装帧中继协议

  [q1-Serial0/1]fr interface-type dce

  [q1-Serial0/1]fr dlci 100

  [q1-Serial0/1]fr inarp

  [q1-Serial0/1]fr map ip 192.168.34.52 dlci 100

  [q2]int s0/1

  [q2-Serial0/1]ip address 192.168.34.52 255.255.255.0

  [q2-Serial0/1]link-protocol fr

  [q2-Serial0/1]fr interface-type dte

  [q2-Serial0/1]fr dlci 100

  [q2-Serial0/1]fr inarp

  [q2-Serial0/1]fr map ip 192.168.34.51 dlci 100

  帧中继监测

  [q1]display fr lmi-info[]interface type number]

  [q1]display fr map

  [q1]display fr pvc-info[serial interface-number][dlci dlci-number]

  [q1]display fr dlci-switch

  [q1]display fr interface

  [q1]reset fr inarp-info

  [q1]debugging fr all[interface type number]

  [q1]debugging fr arp[interface type number]

  [q1]debugging fr event[interface type number]

  [q1]debugging fr lmi[interface type number]

  启动ftp服务:

  [Quidway]local-user ftp password {simple|cipher} aaa service-type ftp

  [Quidway]ftp server enable

【华为交换机常用命令】相关文章:

华为交换机常用命令汇总08-11

华为交换机常用命令2016最新08-12

华为交换机配置命令08-12

华为交换机配置命令大全08-10

华为交换机基本配置命令06-18

H3C交换机常用命令注释12-06

华为交换机的启动及基本配置实验10-26

华为交换机基本配置命令汇总08-10

华为交换机基本配置命令大全06-17