【RDMA】H3C交换机 抓包


摘自:https://cshihong.github.io/2020/11/20/%E5%A6%82%E4%BD%95%E5%9C%A8%E4%BA%A4%E6%8D%A2%E6%9C%BA%E4%B8%8A%E6%8A%93%E5%8C%85/

H3C交换机抓包:

在华三交换机上可使用:packet-capture 命令,在用户视图下执行。

具体操作可查看这:https://www.h3c.com/cn/d_202009/1327093_30005_0.htm

相关命令:查看端口

display interface

先停止抓包:

packet-capture stop 

进入系统视图:sys

<Device> sys

#做流统匹配抓包流量:acl http://blog.sina.com.cn/s/blog_165c04adb0102yens.html

创建acl (记得先删除之前创建的--方法见文章末尾,或者取别号码3001等)
acl advanced 3000
description test 
#rule 0 permit ip source 192.168.1.1 0 destination 192.168.2.1 0

rule 0 deny ip destination 172.16.30.0 0.0.0.255    #禁止访问30段,允许其它

rule 5 permit ip                                                       #允许所有IP数据

#rule 10 permit source-mac xxxx-xxxx-xxxx          #过滤mac,运行源macxxxx-xxxx-xxxx的数据


traffic classifier class_test operator and

if-match acl 3000

#traffic classifier c2 operator and if-match acl 3002
#流量分类器 C2 算子 如果匹配ACL 3002
#定义一个类,名为c2;报文只有匹配了访问控制列表acl 3002的规则,设备才认为报文属于这个类

#
traffic behavior behavior_test
 accounting packet # 做流量统计
 mirror-to cpu # 镜像到CPU,必须镜像到CPU才能抓包
#
qos policy policy_test
 classifier class_test behavior behavior_test
#
interface HundredGigE1/0/4
qos apply policy policy_test inbound 

检查配置状况:

display qos policy interface

退出系统视图Ctrl+Z
packet-capture local  interface  HundredGigE1/0/4  autostop  filesize  50000 write  flash:/isp1.cap

#packet-capture local interface HundredGigE1/0/4 autostop filesize 50000 write flash:/isp4.cap
packet-capture stop # 及时停止。

远程抓包:packet-capture remote  interface HundredGigE1/0/4 port 2014

 

需要注意的几点:

  1. 抓包时尽量使用acl匹配精确的流
  2. 在traffic behavior中,必须配置流量镜向到CPU。mirror-to cpu, 否则不能抓到包。
  3. 抓包时做好文件大小限制,autostop filesze 50000, 因为交换机的硬盘都很小,防止把交换机硬盘打满。
  4. 抓包时尽量选择流量低峰期。
  5. 配置accounting packet 流量统计后,可通过display qos policy interface 查看匹配情况。

 

packet-capture remote interface HundredGigE1/0/4 port 2015

display packet-capture status

 

删除策略

  1. 查看当前策略:

[H3C]sys

[H3C]display qos policy interface
Interface: HundredGigE1/0/4
  Direction: Inbound
  Policy: policy_test
   Classifier: class_test
     Operator: AND
     Rule(s) :
      If-match acl 3000
     Behavior: behavior_test
      Accounting enable:
        0 (Packets)

进入对应端口的视图:

[H3C]sys

[H3C]interface HundredGigE1/0/6

解除策略:undo + ****
[H3C-HundredGigE1/0/6]undo qos apply policy policy_test inbound

 

  1. 解除数据镜像

mirror-to cpu命令用来配置流镜像到CPU。

undo mirror-to命令用来取消流镜像到CPU。

更多见后面的章节。

 

H3C简单FTP上传和下载文件

:首先单独创建个FTP的账号 

<HY-ACCESS-E>system-view 
System View: return to User View with Ctrl+Z.
[HY-ACCESS-E]ftp  server enable 
[HY-ACCESS-E]local-user test1
New local user added.
[HY-ACCESS-E-luser-test1]service-type ftp 
[HY-ACCESS-E-luser-test1]password simple Admin@123
[HY-ACCESS-E-luser-test1]quit 

[HY-ACCESS-E-luser-test1]authorization-attribute user-role level-15  //设置该用户权限级别

(V7版本交换机需要在local-user “用户名” 下设置authorization-attribute user-role level-15权限与user-interface下设置 user-role level-15权限才可以,否则通过ftp上传下载文件时提示“permission denied”)


//然后在cmd命令行直接输入:
>D:                  //dos到D盘目录下
 ftp 192.168.252.247 //交换机的管理地址
//dir //显示所有文件
//get XX.bin //下载到D盘目录下


原文链接:https://blog.csdn.net/NeverGUM/article/details/100895607

 

流镜像配置(数据流导向CPU)

 

 流镜像配置命令

摘自:http://www.h3c.com/cn/d_202101/1377407_30005_0.htm

           http://www.h3c.com/cn/d_202005/1299029_30005_0.htm

           http://www.h3c.com/cn/d_201704/983902_30005_0.htm

          http://www.h3c.com/cn/d_202011/1358689_30005_0.htm

        http://www.h3c.com/cn/d_202010/1345902_30005_0.htm

 

2.1.1  mirror-to cpu

mirror-to cpu命令用来配置流镜像到CPU。

undo mirror-to命令用来取消流镜像到CPU。

【命令】

mirror-to cpu

undo mirror-to cpu

【缺省情况】

未配置流镜像到CPU。

【视图】

流行为视图

【缺省用户角色】

network-admin

【举例】

# 配置流行为1,并在该流行为中配置流镜像到CPU。

<Sysname> system-view

[Sysname] traffic behavior 1

[Sysname-behavior-1] mirror-to cpu

2.1.2  mirror-to interface

mirror-to interface命令用来配置流镜像到接口。

undo mirror-to interface命令用来取消流镜像到接口。

【命令】

mirror-to interface interface-type interface-number [ destination-ip destination-ip-address source-ip source-ip-address [ dscp dscp-value | vlan vlan-id | vrf-instance vrf-name ] * ]

undo mirror-to interface interface-type interface-number

【缺省情况】

未配置流镜像到接口。

【视图】

流行为视图

【缺省用户角色】

network-admin

【参数】

interface-type interface-number:表示流镜像接口的接口类型和接口编号。

destination-ip destination-ip-address:表示流镜像到接口时,镜像报文封装的目的IP地址,destination-ip-address表示封装的目的IP地址。

source-ip source-ip-address:表示流镜像到接口时,镜像报文封装的源IP地址,source-ip-address表示封装的源IP地址。

dscp dscp-value:表示流镜像到接口时,镜像报文封装的DSCP优先级,dscp-value表示封装的DSCP优先级,取值范围为0~63,也可以是关键字,如表2-1所示。

表2-1 DSCP关键字与值的对应表

关键字

DSCP值(二进制)

DSCP值(十进制)

af11

001010

10

af12

001100

12

af13

001110

14

af21

010010

18

af22

010100

20

af23

010110

22

af31

011010

26

af32

011100

28

af33

011110

30

af41

100010

34

af42

100100

36

af43

100110

38

cs1

001000

8

cs2

010000

16

cs3

011000

24

cs4

100000

32

cs5

101000

40

cs6

110000

48

cs7

111000

56

default

000000

0

ef

101110

46

 

vlan vlan-id:镜像报文所属的VLAN,vlan-id表示镜像报文所属VLAN的编号,取值范围为1~4094。

vrf-instance vrf-instance-name:表示流镜像到接口时,镜像报文由该VPN实例对应出接口的路由信息指导转发。vrf-instance-name表示VPN实例名称,为1~31个字符的字符串,区分大小写。

【使用指导】

同一流行为中只能配置一个目的接口,多次执行该命令,仅最后一次执行的命令生效。

【举例】

# 配置流行为1,并在该流行为中配置流镜像到接口Ten-GigabitEthernet1/0/1。

<Sysname> system-view

[Sysname] traffic behavior 1

[Sysname-behavior-1] mirror-to interface ten-gigabitethernet 1/0/1

# 配置流行为1,在该流行为中配置流镜像到接口Ten-GigabitEthernet1/0/1时,镜像报文封装的目的IP地址为1.1.1.1、源IP地址为2.2.2.2、DSCP优先级为20、VLAN ID为100,镜像报文所属的VPN实例名称为vrf1。

<Sysname> system-view

[Sysname] traffic behavior 1

[Sysname-behavior-1] mirror-to interface ten-gigabitethernet 1/0/1 destination-ip 1.1.1.1 source-ip 2.2.2.2 dscp 20 vlan 100 vrf-instance vrf1

 

 

相关命令

 

查看H3C交换机端口信息的:display interface GigabitEthernet1/0/1 。

下面的一些命令提供参考:

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

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

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

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

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

 

更多ACL例子

https://blog.csdn.net/eighteenxu/article/details/78532130

 

  1. acl advanced 3000
  2. step 10
  3. rule 0 permit icmp
  4. rule 50 deny ip destination 175.***.***.*** 0 logging counting
  5. rule 100 deny tcp destination-port eq telnet
  6. rule 300 deny tcp destination-port eq 3389
  7. rule 400 permit tcp destination-port eq 1723

 

创建二层ACL 4000,并定义两条规则,分别为在time1和time2时间段内拒绝源MAC地址前缀为000f-e2的所有报文通过。

acl number 4000

 rule 0 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-rang working_time1

 rule 5 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-rang working_time2

 

定义流video,匹配acl 4000

traffic classifier video operator and

 if-match acl 4000

 

定义流行为video,拒绝通过

traffic behavior video

 filter deny

 

定义qos策略video,关联相应的流和流行为

qos policy video

 classifier video behavior video

 

应用qos

int g1/0/1

 qos apply policy video inbound

int g1/0/2

 qos apply policy video inbound

 

完整配置
#
 time-range time1 00:00 to 08:30 daily
 time-range time1 18:00 to 24:00 daily  
#
acl number 4000
 rule 0 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-range time1
 rule 5 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-range time2
#
interface GigabitEthernet1/0/1
 packet-filter 4000 inbound

 

 

2.包过滤方式

time_range working_time1 0:00 to 8:30 daily

time_range working_time2 18:00 to 24:00 daily

 

 

acl number 4000

 rule 0 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-rang working_time1

 rule 5 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-rang working_time2

 

int gi1/0/1

 packet-filter 4000 inbound

int gi 1/0/2

 packet-filter 4000 inbound

 

完整配置
#
 time-range time1 00:00 to 08:30 daily
 time-range time1 18:00 to 24:00 daily  
#
acl number 4000
 rule 0 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-range time1
 rule 5 deny source-mac 000f-e200-0000 ffff-ff00-0000 time-range time2
#
interface GigabitEthernet1/0/1
 packet-filter 4000 inbound

 

ACL显示和维护

删除ACL

删除 advanced 3000这个acl

1进入sys view:

sys

2删除

undo acl advanced 3000

删除规则

进入sys视图:

sys

显示acl 3000 的规则

display acl  3000

Advanced IPv4 ACL 3000, 3 rules,
test
ACL's step is 5, start ID is 0
 rule 1 permit ip source 182.200.31.54 0 destination 182.200.31.53 0
 rule 2 permit ip source 192.169.31.54 0 destination 192.169.31.53 0
 rule 5 permit icmp
 

进入acl  3000 视图:

[H3C]acl advanced 3000
[H3C-acl-ipv4-adv-3000]
 

删除规则 1:

[H3C-acl-ipv4-adv-3000]undo rule 1

删除classer

sys

进入policy_test

qos policy policy_test

删除policy_test的

undo classifier class_test

清楚统计信息

 

reset acl counter 3000

原文:http://www.h3c.com/cn/d_201212/768464_30005_0.htm#_Toc298159112

在完成上述配置后,在任意视图下执行display命令可以显示ACL配置后的运行情况,通过查看显示信息验证配置的效果。

在用户视图下执行reset命令可以清除ACL的统计信息。

表1-15 ACL显示和维护

配置

命令

显示IPv4 ACL的配置和运行情况

display acl { acl-number | all name acl-name } [ | { begin | exclude | include } regular-expression ]

显示IPv6 ACL的配置和运行情况

display acl ipv6 { acl6-number | all | name acl6-name } [ | { begin | exclude | include } regular-expression ]

显示时间段的配置和状态信息

display time-range { time-range-name | all } [ | { begin | exclude | include } regular-expression ]

清除IPv4 ACL统计信息

reset acl counter { acl-number | all name acl-name }

清除IPv6 ACL统计信息

reset acl ipv6 counter { acl6-number | all name acl6-name }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM