当前位置:   article > 正文

华为配置通过流策略实现流量统计

华为配置通过流策略实现流量统计

配置通过流策略实现流量统计示例

组网图形

图1 配置流策略实现流量统计组网图
 

设备

接口

接口所属VLAN

对应的三层接口

IP地址

SwitchA

GigabitEthernet1/0/1

VLAN 10

-

-

GigabitEthernet1/0/2

VLAN 20

-

-

GigabitEthernet1/0/3

VLAN 10、VLAN 20

-

-

Switch

GigabitEthernet1/0/1

VLAN 10、VLAN 20

VLANIF10、VLANIF20

VLANIF10:192.168.1.1/24

VLANIF20:192.168.2.1/24

GigabitEthernet1/0/2

VLAN 30

VLANIF30

10.1.20.2/24

  • 简介
  • 配置注意事项
  • 组网需求
  • 配置思路
  • 操作步骤
  • 配置文件

简介

配置MQC实现流量统计后,设备将对符合流分类规则的报文进行报文数和字节数的统计,可以帮助用户了解应用流策略后流量通过和被丢弃的情况,由此分析和判断流策略的应用是否合理,也有助于进行相关的故障诊断与排查。

入方向与出方向的统计属于并列关系,用户可以根据需要同时配置,也可以单独配置,流量分开统计,互不影响。

配置注意事项
  1. 本举例适用的产品包括:
  2. S2752EIS2710-SIS2720-EIS2750-EI
  3. S3700-SIS3700-EIS3700-HI
  4. S5700-LIS5700S-LIS5700-SIS5700-EIS5700-HIS5710-C-LIS5710-X-LIS5710-EIS5710-HIS5720-LIS5720S-LIS5720-SIS5720S-SIS5720I-SIS5720-EIS5720-HIS5730-HIS5730-SIS5730S-EIS5731-H、S5731-S、S5731S-S、S5731S-H、S5731-H-K、S5732-H、S5732-H-K、S2730S-S、S5735-L-I、S5735-L1S300S5735-L、S5735S-L1S5735S-L、S5735S-L-M、S500S5735-S、S5735S-S、S5735-S-I、S5735S-H、S5736-S
  5. S6700-EIS6720-LIS6720S-LIS6720-SIS6720S-SIS6720-EIS6720S-EIS6720-HIS6730-H、S6730-S、S6730S-S、S6730S-H、S6730-H-K
  6. S7703S7706S7712S7710S7703 PoES7706 PoES7905S7908S9703S9706S9712

如需了解交换机软件配套详细信息,请点击Info-Finder,在选择产品系列或产品型号后,在“硬件中心”进行查询。

S5731-L和S5731S-L属于远端模块,不支持Web管理、YANG和命令行,仅支持通过中心交换机对其下发配置,相关操作请参见《S300, S500, S2700, S5700, S6700 V200R022C00 配置指南-设备管理》中的“智能极简园区网络配置(小行星方案)”。

组网需求

图1所示,企业内部有两个部门,分别属于VLAN 10和VLAN 20。网络管理员想确认VLAN 20中IP地址为192.168.2.200/24的主机是否有访问VLAN 10中IP地址为192.168.1.100/24的服务器的流量。

配置思路

采用如下的思路配置针对不同网段用户限速:

  1. 创建VLAN,配置各接口和路由协议,实现网络互通。
  2. 在Switch上配置ACL,匹配指定流量。
  3. 在Switch上配置流分类,按照ACL对报文进行分类。
  4. 在Switch上配置流行为,对匹配报文进行流量统计。
  5. 在Switch上配置流策略,绑定流分类和流行为,并应用到与SwitchA相连的GE1/0/1接口的入方向。

操作步骤
  1. 创建VLAN并配置各接口

    1. # 配置Switch
    2. <HUAWEI> system-view
    3. [HUAWEI] sysname Switch
    4. [Switch] vlan batch 10 20 30 //创建VLAN 10、VLAN 20、VLAN 30
    5. [Switch] interface gigabitethernet 1/0/1
    6. [Switch-GigabitEthernet1/0/1] port link-type trunk //设置接口接入类型为trunk
    7. [Switch-GigabitEthernet1/0/1] port trunk allow-pass vlan 10 20 //将接口划分到VLAN 10和VLAN 20
    8. [Switch-GigabitEthernet1/0/1] quit
    9. [Switch] interface gigabitethernet 1/0/2
    10. [Switch-GigabitEthernet1/0/2] port link-type access //设置接口接入类型为access
    11. [Switch-GigabitEthernet1/0/2] port default vlan 30 //将接口划分到VLAN 30
    12. [Switch-GigabitEthernet1/0/2] quit
    13. [Switch] interface vlanif 10 //创建VLANIF接口
    14. [Switch-Vlanif10] ip address 192.168.1.1 255.255.255.0 //配置VLANIF接口的IP地址,此IP地址为192.168.1.0/24网段的网关
    15. [Switch-Vlanif10] quit
    16. [Switch] interface vlanif 20
    17. [Switch-Vlanif20] ip address 192.168.2.1 255.255.255.0
    18. [Switch-Vlanif20] quit
    19. [Switch] interface vlanif 30 //创建VLANIF接口
    20. [Switch-Vlanif30] ip address 10.1.20.2 255.255.255.0 //配置VLANIF接口的IP地址,用于与Router互连
    21. [Switch-Vlanif30] quit
    22. [Switch] ip route-static 0.0.0.0 0 10.1.20.1 //配置静态路由指向外网,实现网络互通
    23. # 配置SwitchA
    24. <HUAWEI> system-view
    25. [HUAWEI] sysname SwitchA
    26. [SwitchA] vlan batch 10 20 //创建VLAN 10和VLAN 20
    27. [SwitchA] interface gigabitethernet 1/0/1
    28. [SwitchA-GigabitEthernet1/0/1] port link-type access //设置接口接入类型为access
    29. [SwitchA-GigabitEthernet1/0/1] port default vlan 10 //将接口划分到VLAN 10
    30. [SwitchA-GigabitEthernet1/0/1] quit
    31. [SwitchA] interface gigabitethernet 1/0/2
    32. [SwitchA-GigabitEthernet1/0/2] port link-type access
    33. [SwitchA-GigabitEthernet1/0/2] port default vlan 20
    34. [SwitchA-GigabitEthernet1/0/2] quit
    35. [SwitchA] interface gigabitethernet 1/0/3
    36. [SwitchA-GigabitEthernet1/0/3] port link-type trunk //设置接口接入类型为trunk
    37. [SwitchA-GigabitEthernet1/0/3] port trunk allow-pass vlan 10 20 //将接口划分到VLAN 10和VLAN 20
    38. [SwitchA-GigabitEthernet1/0/3] quit
    39. # 配置路由器。
    40. 配置路由器上与Switch相连的接口的IP地址为10.1.20.1/24

  2. 配置ACL

    1. # 在Switch上配置ACL规则,匹配源IP地址为192.168.2.200、目的IP地址为192.168.1.100的流量。
    2. [Switch] acl 3000
    3. [Switch-acl-adv-3000] rule permit ip source 192.168.2.200 0.0.0.0 destination 192.168.1.100 0.0.0.0
    4. [Switch-acl-adv-3000] quit

  3. 配置流分类

    1. # 在Switch上配置流分类,按照ACL对报文进行分类。
    2. [Switch] traffic classifier c1 operator and
    3. [Switch-classifier-c1] if-match acl 3000
    4. [Switch-classifier-c1] quit

  4. 配置流行为

    1. # 在Switch上配置流行为,并配置流量统计动作。
    2. [Switch] traffic behavior b1
    3. [Switch-behavior-b1] statistic enable
    4. [Switch-behavior-b1] quit

  5. 配置流策略并应用到接口上

    1. # 在Switch上创建流策略,将流分类和对应的流行为进行绑定,并将流策略应用到与SwitchA相连的接口GE1/0/1的入方向上。
    2. [Switch] traffic policy p1
    3. [Switch-trafficpolicy-p1] classifier c1 behavior b1
    4. [Switch-trafficpolicy-p1] quit
    5. [Switch] interface gigabitethernet 1/0/1
    6. [Switch-GigabitEthernet1/0/1] traffic-policy p1 inbound
    7. [Switch-GigabitEthernet1/0/1] quit

  6. 验证配置结果

    1. # 查看ACL规则的配置信息。
    2. [Switch] display acl 3000
    3. Advanced ACL 3000, 1 rule
    4. Acl's step is 5
    5. rule 5 permit ip source 192.168.2.200 0 destination 192.168.1.100 0 (match-counter 0)
    6. # 查看流策略的配置信息。
    7. [Switch] display traffic policy user-defined p1
    8. User Defined Traffic Policy Information:
    9. Policy: p1
    10. Classifier: c1
    11. Operator: AND
    12. Behavior: b1
    13. Permit
    14. Statistic: enable
    15. # 查看流量统计信息。
    16. [Switch] display traffic policy statistics interface gigabitethernet 1/0/1 inbound
    17. Interface: GigabitEthernet1/0/1
    18. Traffic policy inbound: p1
    19. Rule number: 1
    20. Current status: success
    21. Statistics interval: 300
    22. ---------------------------------------------------------------------
    23. Board : 1
    24. ---------------------------------------------------------------------
    25. Matched | Packets: 0
    26. | Bytes: 0
    27. | Rate(pps): 0
    28. | Rate(bps): 0
    29. ---------------------------------------------------------------------
    30. Passed | Packets: 0
    31. | Bytes: 0
    32. | Rate(pps): 0
    33. | Rate(bps): 0
    34. ---------------------------------------------------------------------
    35. Dropped | Packets: 0
    36. | Bytes: 0
    37. | Rate(pps): 0
    38. | Rate(bps): 0
    39. ---------------------------------------------------------------------
    40. Filter | Packets: 0
    41. | Bytes: 0
    42. ---------------------------------------------------------------------
    43. Car | Packets: 0
    44. | Bytes: 0
    45. ---------------------------------------------------------------------

    回显信息中,Matched显示匹配流分类规则的报文数和字节数,Passed显示匹配流分类规则的报文中通过的报文数和字节数。如果MatchedPassed显示的统计结果不为0,表示VLAN 20中IP地址为192.168.2.200主机有访问VLAN 10中IP地址为192.168.1.100的服务器的流量。

配置文件
  1. Switch的配置文件
  2. #
  3. sysname Switch
  4. #
  5. vlan batch 10 20 30
  6. #
  7. acl number 3000
  8. rule 5 permit ip source 192.168.2.200 0 destination 192.168.1.100 0
  9. #
  10. traffic classifier c1 operator and precedence 5
  11. if-match acl 3000
  12. #
  13. traffic behavior b1
  14. permit
  15. statistic enable
  16. #
  17. traffic policy p1 match-order config
  18. classifier c1 behavior b1
  19. #
  20. interface Vlanif10
  21. ip address 192.168.1.1 255.255.255.0
  22. #
  23. interface Vlanif20
  24. ip address 192.168.2.1 255.255.255.0
  25. #
  26. interface Vlanif30
  27. ip address 10.1.20.2 255.255.255.0
  28. #
  29. interface GigabitEthernet1/0/1
  30. port link-type trunk
  31. port trunk allow-pass vlan 10 20
  32. traffic-policy p1 inbound
  33. #
  34. interface GigabitEthernet1/0/2
  35. port link-type access
  36. port default vlan 30
  37. #
  38. ip route-static 0.0.0.0 0.0.0.0 10.1.20.1
  39. #
  40. return
  41. SwitchA的配置文件
  42. #
  43. sysname SwitchA
  44. #
  45. vlan batch 10 20
  46. #
  47. interface GigabitEthernet1/0/1
  48. port link-type access
  49. port default vlan 10
  50. #
  51. interface GigabitEthernet1/0/2
  52. port link-type access
  53. port default vlan 20
  54. #
  55. interface GigabitEthernet1/0/3
  56. port link-type trunk
  57. port trunk allow-pass vlan 10 20
  58. #
  59. return
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/466121
推荐阅读
相关标签
  

闽ICP备14008679号