华为、华三、锐捷、飞塔、山石的抓包命令

一、华为的抓包命令

1、基本概念

华为的抓包行为称之为镜像端口,也就是说将需要抓取的接口上(称为镜像端口)的流量复制一份到另一个接口上(工程师进行流量观察的端口,称为观察端口),如下图所示:

2、华为镜像端口分类

1)、本地镜像端口(也就是观察端口和镜像端口在同一设备上),对抓取的流量不进行限制,即抓取镜像端口的所有流量;

配置:

第一步:配置观察端口

system                                                                                        //进入系统视图下

observe-port interface interface-type interface-number     //全局下配置本地观察端口

第二步:配置镜像端口

interface interface-type interface-number                                //进入观察接口视图下

mirror to observe-port { both | inbound | outbound } [ exclude-link-head ]              //将镜像端口绑定到观察端口

 { both | inbound | outbound }为流量方向 {所有方向 | 入方向 | 出方向}

[ exclude-link-head ] 表示对报文进行镜像前先去除非以太链路层信息

对于一些承载特殊链路层的IP报文(如IPOA等),镜像时可能会由于工具无法解析这些非以太链路层的信息而导致不能分析报文。通过使用exclude-link-layer参数,可以使设备去除报文中的非以太链路层信息,从而使工具可以正常分析报文。

2)、流镜像(使用traffic工具精确抓取流量),可以将流量观察端口设置在任一可以网络互通的设备接口上。

配置示例:

 本地镜像端口配置:

[SW1] observing-port 1 interface g0/0/24             //指定观察端口1为G0/24口

[SW1] interface g0/0/1                                          //进入到镜像端口视图下

[SW1-G0/0/1] mirror to observe-port 1 inbound         //将该接口的入方向流量复制一份到观察端口1上

流镜像配置:

[SW1] observing-port 1 interface g0/0/24             //指定观察端口1为G0/24口

acl number 3000                                                 //配置ACL匹配需要抓取的流量
 rule 5 permit ip source 10.0.0.0 0.0.0.255 destination 1.1.1.1 0

traffic classifier to_1.1.1.1 operator and            //配置流分类
 if-match acl 3000

traffic behavior to_1.1.1.1                                //配置流行为
 mirroring to observe-port 1

traffic policy to_1.1.1.1                                    //配置流策略
 classifier to_1.1.1.1 behavior to_1.1.1.1

interface GigabitEthernet0/0/1                         //在镜像端口应用抓取所有方向的流量
 traffic-policy to_1.1.1.1 inbound
 traffic-policy to_1.1.1.1 outbound

二、华三的抓包命令

1、基本概念

华三将镜像端口中的需要抓取流量的端口称之为源端口,将对流量进行观察的端口称为目的端口,

和华为抓包的理论逻辑类似,仅仅是配置上有细微的区别。

2、配置示例

1)、本地镜像端口

mirroring-group 1 local              //系统视图下全局配置镜像组1

mirroring-group 1 mirroring-port gigabitethernet 1/0/1 gigabitethernet 1/0/2 both        //源端口为G0/1和G0/2加入到组1

mirroring-group 1 monitor-port gigabitethernet 1/0/3                //目的端口为G0/3加入到组1

 display mirroring-group all                     //验证命令

2)、远程镜像端口

Device A上配置:

interface tunnel 0 mode gre                  //配置GRE隧道

ip address 50.1.1.1 24

source 20.1.1.1

destination 30.1.1.2

mirroring-group 1 local                     //镜像组1

mirroring-group 1 mirroring-port gigabitethernet 1/0/1 both     //源端口为G0/1

mirroring-group 1 monitor-port tunnel 0                                   //目的端口为tunnel 0

Device A上配置:

interface tunnel 0 mode gre                  //配置GRE隧道

ip address 50.1.1.2 24

source 30.1.1.2

destination 20.1.1.1

mirroring-group 1 local                     //镜像组1

mirroring-group 1 mirroring-port gigabitethernet 1/0/1 both            //源端口为G0/1

mirroring-group 1 monitor-port gigabitethernet 1/0/2                       //目的端口为G0/2

三、锐捷的抓包命令

1、基本概念

锐捷的抓包也是通过将流量镜像进行抓包,与华为华三类似,锐捷称为SPAN 协议,分为本地抓包和远程抓包。

2、配置示例
1)、SPAN本地抓包

 交换机上配置如下:

抓G0/1口所有报文配置如下:

monitor session 1 source interface gigabitEthernet 0/1                        //G0/1为镜像端口
 
monitor session 1 destination interface gigabitEthernet 0/2                 //G0/2为目的端口
基于流的方式进行精确抓包配置如下:
ip access-list standard test                               //创建ACL精确匹配流量
10 permit host 192.168.0.1

monitor session 1 source interface gigabitEthernet 0/1 acl test         //G0/1为镜像端口匹配acl流量

monitor session 1 destination interface gigabitEthernet 0/2                 //G0/2为目的端口

基于VLAN的方式进行抓包配置如下:

monitor session 1 source vlan 10 rx                         //镜像进入VLAN10的流量
monitor session 1 destination interface gigabitEthernet 0/2                 //G0/2为目的端口

注意:如果镜像目的口没有开启 switch 功能,则目的口只能接收镜像报文,其它流经该端口的报文将被丢弃。开启后可以接收非镜像报文。monitor session 1 destination interface gigabitEthernet 0/2 switch     跟上Switch参数后,可以正常收发业务报文与镜像报文,建议不开启。

2)、Rspan远程抓包(一对多)

适用于二层环境下抓包,需要占用一个VLAN,通过该VLAN进行镜像报文的传输。

 Switch A上配置如下:

vlan 10

 remote-span               //配置远程VLAN
monitor session 1 remote-source                  //源端口为远程源端口模式
monitor session 1 source interface fa 0/1 both          //源端口为F0/1接口,抓取出入流量
monitor session 1 destination remote vlan 10 interface fa 0/2 switch      //远程目的端口为F0/2
interface fa0/2                                 //进入F0/2接口下
 mac-loopback                                //配置为MAC环回口进行流量反射
 switchport access vlan 10             //加入VLAN 10
interface range fa0/3-4                 //将F0/3-4放通VLAN
  switchport mode trunck
注意:当进行一对多远程镜像端口配置时,需要配置反射端口(MAC环回口) 该端口为闲置端口,无接入设备 ,相当于将所有镜像流量发送给了一个端口,再由这个端口将镜像流量反射给镜像流量承载VLAN的所有接口下,是一种二层环路泛洪行为。         

Switch B.C上配置如下:

vlan 10

 remote-span               //配置远程VLAN
monitor session 1 remote-destination       //目的端口为远程目的端口模式
monitor session 1 destination remote vlan 10 interface fa 0/2  //目的端口为F0/2,经VLAN10 传递
interface fa0/1          //放通VLAN
switchport mode trunck
注意:源设备、中间设备、目的设备均要配置远程 VLAN VID 必须一致,一般源设备远程目的端口都需要配置Switch参数,不影响业务流量交互。

工作太累其它的抽空再补充。。。。。未完待续

  • 5
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值